Changeset - c4c8a7ab8296
[Not reviewed]
0 1 1
Christopher Neugebauer - 8 years ago 2016-04-11 08:12:37
chrisjrn@gmail.com
Tidies up the admin interface for flags
2 files changed with 47 insertions and 3 deletions:
0 comments (0 inline, 0 general)
registrasion/migrations/0022_auto_20160411_0806.py
Show inline comments
 
new file 100644
 
# -*- coding: utf-8 -*-
 
# Generated by Django 1.9.2 on 2016-04-11 08:06
 
from __future__ import unicode_literals
 

	
 
from django.db import migrations
 

	
 

	
 
class Migration(migrations.Migration):
 

	
 
    dependencies = [
 
        ('registrasion', '0021_auto_20160411_0748'),
 
    ]
 

	
 
    operations = [
 
        migrations.AlterModelOptions(
 
            name='categoryflag',
 
            options={'verbose_name': 'flag (dependency on product from category)', 'verbose_name_plural': 'flags (dependency on product from category)'},
 
        ),
 
        migrations.AlterModelOptions(
 
            name='productflag',
 
            options={'verbose_name': 'flag (dependency on product)', 'verbose_name_plural': 'flags (dependency on product)'},
 
        ),
 
        migrations.AlterModelOptions(
 
            name='timeorstocklimitflag',
 
            options={'verbose_name': 'flag (time/stock limit)', 'verbose_name_plural': 'flags (time/stock limit)'},
 
        ),
 
        migrations.AlterModelOptions(
 
            name='voucherflag',
 
            options={'verbose_name': 'flag (dependency on voucher)', 'verbose_name_plural': 'flags (dependency on voucher)'},
 
        ),
 
    ]
registrasion/models.py
Show inline comments
...
 
@@ -372,14 +372,14 @@ class EnablingConditionBase(models.Model):
 
    be made visible. If there is at least one mandatory enabling condition
 
    defined on a Product or Category, it will only be enabled if *all*
 
    mandatory conditions are met, otherwise, if there is at least one enabling
 
    condition defined on a Product or Category, it will only be enabled if at
 
    least one condition is met. '''
 

	
 
    # TODO: rename to EnablingConditionBase once https://code.djangoproject.com/ticket/26488
 
    # is solved.
 
    # TODO: rename to EnablingConditionBase once
 
    # https://code.djangoproject.com/ticket/26488 is solved.
 

	
 
    objects = InheritanceManager()
 

	
 
    def __str__(self):
 
        return self.description
 

	
...
 
@@ -409,13 +409,14 @@ class EnablingConditionBase(models.Model):
 

	
 

	
 
class TimeOrStockLimitFlag(EnablingConditionBase):
 
    ''' Registration product ceilings '''
 

	
 
    class Meta:
 
        verbose_name = _("ceiling")
 
        verbose_name = _("flag (time/stock limit)")
 
        verbose_name_plural = _("flags (time/stock limit)")
 

	
 
    start_time = models.DateTimeField(
 
        null=True,
 
        blank=True,
 
        help_text=_("Products included in this condition will only be "
 
                    "available after this time."),
...
 
@@ -435,12 +436,16 @@ class TimeOrStockLimitFlag(EnablingConditionBase):
 

	
 

	
 
@python_2_unicode_compatible
 
class ProductFlag(EnablingConditionBase):
 
    ''' The condition is met because a specific product is purchased. '''
 

	
 
    class Meta:
 
        verbose_name = _("flag (dependency on product)")
 
        verbose_name_plural = _("flags (dependency on product)")
 

	
 
    def __str__(self):
 
        return "Enabled by products: " + str(self.enabling_products.all())
 

	
 
    enabling_products = models.ManyToManyField(
 
        Product,
 
        help_text=_("If one of these products are purchased, this condition "
...
 
@@ -450,12 +455,16 @@ class ProductFlag(EnablingConditionBase):
 

	
 
@python_2_unicode_compatible
 
class CategoryFlag(EnablingConditionBase):
 
    ''' The condition is met because a product in a particular product is
 
    purchased. '''
 

	
 
    class Meta:
 
        verbose_name = _("flag (dependency on product from category)")
 
        verbose_name_plural = _("flags (dependency on product from category)")
 

	
 
    def __str__(self):
 
        return "Enabled by product in category: " + str(self.enabling_category)
 

	
 
    enabling_category = models.ForeignKey(
 
        Category,
 
        help_text=_("If a product from this category is purchased, this "
...
 
@@ -465,12 +474,16 @@ class CategoryFlag(EnablingConditionBase):
 

	
 
@python_2_unicode_compatible
 
class VoucherFlag(EnablingConditionBase):
 
    ''' The condition is met because a Voucher is present. This is for e.g.
 
    enabling sponsor tickets. '''
 

	
 
    class Meta:
 
        verbose_name = _("flag (dependency on voucher)")
 
        verbose_name_plural = _("flags (dependency on voucher)")
 

	
 
    def __str__(self):
 
        return "Enabled by voucher: %s" % self.voucher
 

	
 
    voucher = models.OneToOneField(Voucher)
 

	
 

	
0 comments (0 inline, 0 general)