Changeset - 61dbe60cfad0
[Not reviewed]
0 2 1
Christopher Neugebauer - 8 years ago 2016-04-11 09:23:38
chrisjrn@gmail.com
Renames the admin-visible names for many model classes, and adds a default ordering where they’re useful too.
3 files changed with 78 insertions and 6 deletions:
0 comments (0 inline, 0 general)
registrasion/admin.py
Show inline comments
...
 
@@ -16,7 +16,6 @@ class EffectsDisplayMixin(object):
 

	
 
class ProductInline(admin.TabularInline):
 
    model = rego.Product
 
    ordering = ("order", )
 

	
 

	
 
@admin.register(rego.Category)
...
 
@@ -25,7 +24,6 @@ class CategoryAdmin(admin.ModelAdmin):
 
    fields = ("name", "description", "required", "render_type",
 
              "limit_per_user", "order",)
 
    list_display = ("name", "description")
 
    ordering = ("order", )
 
    inlines = [
 
        ProductInline,
 
    ]
...
 
@@ -36,7 +34,6 @@ class ProductAdmin(admin.ModelAdmin):
 
    model = rego.Product
 
    list_display = ("name", "category", "description")
 
    list_filter = ("category", )
 
    ordering = ("category__order", "order", )
 

	
 

	
 
# Discounts
registrasion/migrations/0021_auto_20160411_0820.py
Show inline comments
 
new file 100644
 
# -*- coding: utf-8 -*-
 
# Generated by Django 1.9.2 on 2016-04-11 08:20
 
from __future__ import unicode_literals
 

	
 
from django.db import migrations
 

	
 

	
 
class Migration(migrations.Migration):
 

	
 
    dependencies = [
 
        ('registrasion', '0020_auto_20160411_0258'),
 
    ]
 

	
 
    operations = [
 
        migrations.AlterModelOptions(
 
            name='category',
 
            options={'ordering': ('order',), 'verbose_name': 'inventory - category', 'verbose_name_plural': 'inventory - categories'},
 
        ),
 
        migrations.AlterModelOptions(
 
            name='discountitem',
 
            options={'ordering': ('product',)},
 
        ),
 
        migrations.AlterModelOptions(
 
            name='includedproductdiscount',
 
            options={'verbose_name': 'discount (product inclusions)', 'verbose_name_plural': 'discounts (product inclusions)'},
 
        ),
 
        migrations.AlterModelOptions(
 
            name='lineitem',
 
            options={'ordering': ('id',)},
 
        ),
 
        migrations.AlterModelOptions(
 
            name='paymentbase',
 
            options={'ordering': ('time',)},
 
        ),
 
        migrations.AlterModelOptions(
 
            name='product',
 
            options={'ordering': ('category__order', 'order'), 'verbose_name': 'inventory - product'},
 
        ),
 
        migrations.AlterModelOptions(
 
            name='productitem',
 
            options={'ordering': ('product',)},
 
        ),
 
        migrations.AlterModelOptions(
 
            name='timeorstocklimitdiscount',
 
            options={'verbose_name': 'discount (time/stock limit)', 'verbose_name_plural': 'discounts (time/stock limit)'},
 
        ),
 
        migrations.AlterModelOptions(
 
            name='voucherdiscount',
 
            options={'verbose_name': 'discount (enabled by voucher)', 'verbose_name_plural': 'discounts (enabled by voucher)'},
 
        ),
 
    ]
registrasion/models.py
Show inline comments
...
 
@@ -89,7 +89,9 @@ class Category(models.Model):
 
    ''' Registration product categories '''
 

	
 
    class Meta:
 
        verbose_name_plural = _("categories")
 
        verbose_name = _("inventory - category")
 
        verbose_name_plural = _("inventory - categories")
 
        ordering = ("order", )
 

	
 
    def __str__(self):
 
        return self.name
...
 
@@ -138,6 +140,10 @@ class Category(models.Model):
 
class Product(models.Model):
 
    ''' Registration products '''
 

	
 
    class Meta:
 
        verbose_name = _("inventory - product")
 
        ordering = ("category__order", "order")
 

	
 
    def __str__(self):
 
        return "%s - %s" % (self.category.name, self.name)
 

	
...
 
@@ -310,7 +316,8 @@ class TimeOrStockLimitDiscount(DiscountBase):
 
    usage count. This is for e.g. Early Bird discounts. '''
 

	
 
    class Meta:
 
        verbose_name = _("Promotional discount")
 
        verbose_name = _("discount (time/stock limit)")
 
        verbose_name_plural = _("discounts (time/stock limit)")
 

	
 
    start_time = models.DateTimeField(
 
        null=True,
...
 
@@ -336,6 +343,10 @@ class VoucherDiscount(DiscountBase):
 
    ''' Discounts that are enabled when a voucher code is in the current
 
    cart. '''
 

	
 
    class Meta:
 
        verbose_name = _("discount (enabled by voucher)")
 
        verbose_name_plural = _("discounts (enabled by voucher)")
 

	
 
    voucher = models.OneToOneField(
 
        Voucher,
 
        on_delete=models.CASCADE,
...
 
@@ -349,7 +360,8 @@ class IncludedProductDiscount(DiscountBase):
 
    e.g. A conference ticket includes a free t-shirt. '''
 

	
 
    class Meta:
 
        verbose_name = _("Product inclusion")
 
        verbose_name = _("discount (product inclusions)")
 
        verbose_name_plural = _("discounts (product inclusions)")
 

	
 
    enabling_products = models.ManyToManyField(
 
        Product,
...
 
@@ -530,6 +542,9 @@ class Cart(models.Model):
 
class ProductItem(models.Model):
 
    ''' Represents a product-quantity pair in a Cart. '''
 

	
 
    class Meta:
 
        ordering = ("product", )
 

	
 
    def __str__(self):
 
        return "product: %s * %d in Cart: %s" % (
 
            self.product, self.quantity, self.cart)
...
 
@@ -543,6 +558,9 @@ class ProductItem(models.Model):
 
class DiscountItem(models.Model):
 
    ''' Represents a discount-product-quantity relation in a Cart. '''
 

	
 
    class Meta:
 
        ordering = ("product", )
 

	
 
    def __str__(self):
 
        return "%s: %s * %d in Cart: %s" % (
 
            self.discount, self.product, self.quantity, self.cart)
...
 
@@ -618,6 +636,9 @@ class LineItem(models.Model):
 
    and DiscountItems that belong to a cart (for consistency), but also allow
 
    for arbitrary line items when required. '''
 

	
 
    class Meta:
 
        ordering = ("id", )
 

	
 
    def __str__(self):
 
        return "Line: %s * %d @ %s" % (
 
            self.description, self.quantity, self.price)
...
 
@@ -634,6 +655,9 @@ class PaymentBase(models.Model):
 
    ''' The base payment type for invoices. Payment apps should subclass this
 
    class to handle implementation-specific issues. '''
 

	
 
    class Meta:
 
        ordering = ("time", )
 

	
 
    objects = InheritanceManager()
 

	
 
    def __str__(self):
0 comments (0 inline, 0 general)