Merge branch 'admin_models_cleanup'

This commit is contained in:
Christopher Neugebauer 2016-04-12 19:41:31 +10:00
commit 278ca23c29
4 changed files with 96 additions and 8 deletions

View file

@ -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
@ -154,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")
@ -167,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")

View 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)'},
),
]

View file

@ -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 = [
]

View file

@ -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,
@ -582,6 +594,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)
@ -595,6 +610,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)
@ -670,6 +688,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)
@ -686,6 +707,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):