From 61dbe60cfad0f4a9f6f3770b7e83dd36ed2b88f1 Mon Sep 17 00:00:00 2001 From: Christopher Neugebauer Date: Mon, 11 Apr 2016 19:23:38 +1000 Subject: [PATCH 1/2] =?UTF-8?q?Renames=20the=20admin-visible=20names=20for?= =?UTF-8?q?=20many=20model=20classes,=20and=20adds=20a=20default=20orderin?= =?UTF-8?q?g=20where=20they=E2=80=99re=20useful=20too.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- registrasion/admin.py | 3 -- .../migrations/0021_auto_20160411_0820.py | 51 +++++++++++++++++++ registrasion/models.py | 30 +++++++++-- 3 files changed, 78 insertions(+), 6 deletions(-) create mode 100644 registrasion/migrations/0021_auto_20160411_0820.py diff --git a/registrasion/admin.py b/registrasion/admin.py index 7155e177..21c62e3b 100644 --- a/registrasion/admin.py +++ b/registrasion/admin.py @@ -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 diff --git a/registrasion/migrations/0021_auto_20160411_0820.py b/registrasion/migrations/0021_auto_20160411_0820.py new file mode 100644 index 00000000..b6fc4367 --- /dev/null +++ b/registrasion/migrations/0021_auto_20160411_0820.py @@ -0,0 +1,51 @@ +# -*- 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)'}, + ), + ] diff --git a/registrasion/models.py b/registrasion/models.py index 6e625887..baf7cec3 100644 --- a/registrasion/models.py +++ b/registrasion/models.py @@ -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): From ffa1ca678332bc5c6418d685f523367380bd72cc Mon Sep 17 00:00:00 2001 From: Christopher Neugebauer Date: Tue, 12 Apr 2016 11:43:38 +1000 Subject: [PATCH 2/2] Fixes flags admin --- registrasion/admin.py | 4 ++-- registrasion/migrations/0022_merge.py | 16 ++++++++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 registrasion/migrations/0022_merge.py diff --git a/registrasion/admin.py b/registrasion/admin.py index 7065b0a2..ff9b0ec4 100644 --- a/registrasion/admin.py +++ b/registrasion/admin.py @@ -151,7 +151,7 @@ class ProductFlagAdmin( return list(obj.enabling_products.all()) model = rego.ProductFlag - fields = ("description", "enabling_products", "mandatory", "products", + fields = ("description", "enabling_products", "condition", "products", "categories"), list_display = ("description", "enablers", "effects") @@ -164,7 +164,7 @@ class CategoryFlagAdmin( EffectsDisplayMixin): model = rego.CategoryFlag - fields = ("description", "enabling_category", "mandatory", "products", + fields = ("description", "enabling_category", "condition", "products", "categories"), list_display = ("description", "enabling_category", "effects") diff --git a/registrasion/migrations/0022_merge.py b/registrasion/migrations/0022_merge.py new file mode 100644 index 00000000..e3c30039 --- /dev/null +++ b/registrasion/migrations/0022_merge.py @@ -0,0 +1,16 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.2 on 2016-04-12 01:40 +from __future__ import unicode_literals + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('registrasion', '0021_auto_20160411_0748_squashed_0024_auto_20160411_2230'), + ('registrasion', '0021_auto_20160411_0820'), + ] + + operations = [ + ]