Renames the admin-visible names for many model classes, and adds a default ordering where they’re useful too.
This commit is contained in:
		
							parent
							
								
									eefdb41cfc
								
							
						
					
					
						commit
						61dbe60cfa
					
				
					 3 changed files with 78 additions and 6 deletions
				
			
		|  | @ -16,7 +16,6 @@ class EffectsDisplayMixin(object): | ||||||
| 
 | 
 | ||||||
| class ProductInline(admin.TabularInline): | class ProductInline(admin.TabularInline): | ||||||
|     model = rego.Product |     model = rego.Product | ||||||
|     ordering = ("order", ) |  | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| @admin.register(rego.Category) | @admin.register(rego.Category) | ||||||
|  | @ -25,7 +24,6 @@ class CategoryAdmin(admin.ModelAdmin): | ||||||
|     fields = ("name", "description", "required", "render_type", |     fields = ("name", "description", "required", "render_type", | ||||||
|               "limit_per_user", "order",) |               "limit_per_user", "order",) | ||||||
|     list_display = ("name", "description") |     list_display = ("name", "description") | ||||||
|     ordering = ("order", ) |  | ||||||
|     inlines = [ |     inlines = [ | ||||||
|         ProductInline, |         ProductInline, | ||||||
|     ] |     ] | ||||||
|  | @ -36,7 +34,6 @@ class ProductAdmin(admin.ModelAdmin): | ||||||
|     model = rego.Product |     model = rego.Product | ||||||
|     list_display = ("name", "category", "description") |     list_display = ("name", "category", "description") | ||||||
|     list_filter = ("category", ) |     list_filter = ("category", ) | ||||||
|     ordering = ("category__order", "order", ) |  | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| # Discounts | # Discounts | ||||||
|  |  | ||||||
							
								
								
									
										51
									
								
								registrasion/migrations/0021_auto_20160411_0820.py
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										51
									
								
								registrasion/migrations/0021_auto_20160411_0820.py
									
										
									
									
									
										Normal file
									
								
							|  | @ -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)'}, | ||||||
|  |         ), | ||||||
|  |     ] | ||||||
|  | @ -89,7 +89,9 @@ class Category(models.Model): | ||||||
|     ''' Registration product categories ''' |     ''' Registration product categories ''' | ||||||
| 
 | 
 | ||||||
|     class Meta: |     class Meta: | ||||||
|         verbose_name_plural = _("categories") |         verbose_name = _("inventory - category") | ||||||
|  |         verbose_name_plural = _("inventory - categories") | ||||||
|  |         ordering = ("order", ) | ||||||
| 
 | 
 | ||||||
|     def __str__(self): |     def __str__(self): | ||||||
|         return self.name |         return self.name | ||||||
|  | @ -138,6 +140,10 @@ class Category(models.Model): | ||||||
| class Product(models.Model): | class Product(models.Model): | ||||||
|     ''' Registration products ''' |     ''' Registration products ''' | ||||||
| 
 | 
 | ||||||
|  |     class Meta: | ||||||
|  |         verbose_name = _("inventory - product") | ||||||
|  |         ordering = ("category__order", "order") | ||||||
|  | 
 | ||||||
|     def __str__(self): |     def __str__(self): | ||||||
|         return "%s - %s" % (self.category.name, self.name) |         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. ''' |     usage count. This is for e.g. Early Bird discounts. ''' | ||||||
| 
 | 
 | ||||||
|     class Meta: |     class Meta: | ||||||
|         verbose_name = _("Promotional discount") |         verbose_name = _("discount (time/stock limit)") | ||||||
|  |         verbose_name_plural = _("discounts (time/stock limit)") | ||||||
| 
 | 
 | ||||||
|     start_time = models.DateTimeField( |     start_time = models.DateTimeField( | ||||||
|         null=True, |         null=True, | ||||||
|  | @ -336,6 +343,10 @@ class VoucherDiscount(DiscountBase): | ||||||
|     ''' Discounts that are enabled when a voucher code is in the current |     ''' Discounts that are enabled when a voucher code is in the current | ||||||
|     cart. ''' |     cart. ''' | ||||||
| 
 | 
 | ||||||
|  |     class Meta: | ||||||
|  |         verbose_name = _("discount (enabled by voucher)") | ||||||
|  |         verbose_name_plural = _("discounts (enabled by voucher)") | ||||||
|  | 
 | ||||||
|     voucher = models.OneToOneField( |     voucher = models.OneToOneField( | ||||||
|         Voucher, |         Voucher, | ||||||
|         on_delete=models.CASCADE, |         on_delete=models.CASCADE, | ||||||
|  | @ -349,7 +360,8 @@ class IncludedProductDiscount(DiscountBase): | ||||||
|     e.g. A conference ticket includes a free t-shirt. ''' |     e.g. A conference ticket includes a free t-shirt. ''' | ||||||
| 
 | 
 | ||||||
|     class Meta: |     class Meta: | ||||||
|         verbose_name = _("Product inclusion") |         verbose_name = _("discount (product inclusions)") | ||||||
|  |         verbose_name_plural = _("discounts (product inclusions)") | ||||||
| 
 | 
 | ||||||
|     enabling_products = models.ManyToManyField( |     enabling_products = models.ManyToManyField( | ||||||
|         Product, |         Product, | ||||||
|  | @ -530,6 +542,9 @@ class Cart(models.Model): | ||||||
| class ProductItem(models.Model): | class ProductItem(models.Model): | ||||||
|     ''' Represents a product-quantity pair in a Cart. ''' |     ''' Represents a product-quantity pair in a Cart. ''' | ||||||
| 
 | 
 | ||||||
|  |     class Meta: | ||||||
|  |         ordering = ("product", ) | ||||||
|  | 
 | ||||||
|     def __str__(self): |     def __str__(self): | ||||||
|         return "product: %s * %d in Cart: %s" % ( |         return "product: %s * %d in Cart: %s" % ( | ||||||
|             self.product, self.quantity, self.cart) |             self.product, self.quantity, self.cart) | ||||||
|  | @ -543,6 +558,9 @@ class ProductItem(models.Model): | ||||||
| class DiscountItem(models.Model): | class DiscountItem(models.Model): | ||||||
|     ''' Represents a discount-product-quantity relation in a Cart. ''' |     ''' Represents a discount-product-quantity relation in a Cart. ''' | ||||||
| 
 | 
 | ||||||
|  |     class Meta: | ||||||
|  |         ordering = ("product", ) | ||||||
|  | 
 | ||||||
|     def __str__(self): |     def __str__(self): | ||||||
|         return "%s: %s * %d in Cart: %s" % ( |         return "%s: %s * %d in Cart: %s" % ( | ||||||
|             self.discount, self.product, self.quantity, self.cart) |             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 |     and DiscountItems that belong to a cart (for consistency), but also allow | ||||||
|     for arbitrary line items when required. ''' |     for arbitrary line items when required. ''' | ||||||
| 
 | 
 | ||||||
|  |     class Meta: | ||||||
|  |         ordering = ("id", ) | ||||||
|  | 
 | ||||||
|     def __str__(self): |     def __str__(self): | ||||||
|         return "Line: %s * %d @ %s" % ( |         return "Line: %s * %d @ %s" % ( | ||||||
|             self.description, self.quantity, self.price) |             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 |     ''' The base payment type for invoices. Payment apps should subclass this | ||||||
|     class to handle implementation-specific issues. ''' |     class to handle implementation-specific issues. ''' | ||||||
| 
 | 
 | ||||||
|  |     class Meta: | ||||||
|  |         ordering = ("time", ) | ||||||
|  | 
 | ||||||
|     objects = InheritanceManager() |     objects = InheritanceManager() | ||||||
| 
 | 
 | ||||||
|     def __str__(self): |     def __str__(self): | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		
		Reference in a new issue
	
	 Christopher Neugebauer
						Christopher Neugebauer