Adds admin and migration for speaker tickets.

This commit is contained in:
Christopher Neugebauer 2016-09-04 14:21:30 +10:00
parent af30063a92
commit c2a702d699
2 changed files with 115 additions and 18 deletions

View file

@ -12,6 +12,7 @@ class EffectsDisplayMixin(object):
def effects(self, obj):
return list(obj.effects())
# Inventory admin
@ -69,14 +70,11 @@ class TimeOrStockLimitDiscountAdmin(admin.ModelAdmin, EffectsDisplayMixin):
@admin.register(conditions.IncludedProductDiscount)
class IncludedProductDiscountAdmin(admin.ModelAdmin):
class IncludedProductDiscountAdmin(admin.ModelAdmin, EffectsDisplayMixin):
def enablers(self, obj):
return list(obj.enabling_products.all())
def effects(self, obj):
return list(obj.effects())
list_display = ("description", "enablers", "effects")
inlines = [
@ -84,6 +82,20 @@ class IncludedProductDiscountAdmin(admin.ModelAdmin):
DiscountForCategoryInline,
]
@admin.register(conditions.SpeakerDiscount)
class SpeakerDiscountAdmin(admin.ModelAdmin, EffectsDisplayMixin):
fields = ("description", "is_presenter", "is_copresenter", "proposal_kind")
list_display = ("description", "is_presenter", "is_copresenter", "effects")
ordering = ("-is_presenter", "-is_copresenter")
inlines = [
DiscountForProductInline,
DiscountForCategoryInline,
]
# Vouchers
@ -172,18 +184,13 @@ class CategoryFlagAdmin(
ordering = ("enabling_category",)
# Enabling conditions
@admin.register(conditions.TimeOrStockLimitFlag)
class TimeOrStockLimitFlagAdmin(
nested_admin.NestedAdmin,
EffectsDisplayMixin):
model = conditions.TimeOrStockLimitFlag
@admin.register(conditions.SpeakerFlag)
class SpeakerFlagAdmin(nested_admin.NestedAdmin, EffectsDisplayMixin):
list_display = (
"description",
"start_time",
"end_time",
"limit",
"effects",
)
ordering = ("start_time", "end_time", "limit")
model = conditions.SpeakerFlag
fields = ("description", "is_presenter", "is_copresenter", "proposal_kind",
"products", "categories")
list_display = ("description", "is_presenter", "is_copresenter", "effects")
ordering = ("-is_presenter", "-is_copresenter")

View file

@ -0,0 +1,90 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.2 on 2016-09-04 02:35
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('symposion_proposals', '0001_initial'),
('registrasion', '0002_auto_20160822_0034'),
]
operations = [
migrations.CreateModel(
name='SpeakerDiscount',
fields=[
('discountbase_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='registrasion.DiscountBase')),
('is_presenter', models.BooleanField(help_text='This condition is met if the user is the primary presenter of a presentation.')),
('is_copresenter', models.BooleanField(help_text='This condition is met if the user is a copresenter of a presentation.')),
('proposal_kind', models.ManyToManyField(help_text='The types of proposals that these users may be presenters of.', to='symposion_proposals.ProposalKind')),
],
options={
'verbose_name': 'discount (speaker)',
'verbose_name_plural': 'discounts (speaker)',
},
bases=('registrasion.discountbase', models.Model),
),
migrations.CreateModel(
name='SpeakerFlag',
fields=[
('flagbase_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='registrasion.FlagBase')),
('is_presenter', models.BooleanField(help_text='This condition is met if the user is the primary presenter of a presentation.')),
('is_copresenter', models.BooleanField(help_text='This condition is met if the user is a copresenter of a presentation.')),
('proposal_kind', models.ManyToManyField(help_text='The types of proposals that these users may be presenters of.', to='symposion_proposals.ProposalKind')),
],
options={
'verbose_name': 'flag (speaker)',
'verbose_name_plural': 'flags (speaker)',
},
bases=('registrasion.flagbase', models.Model),
),
migrations.AlterField(
model_name='includedproductdiscount',
name='enabling_products',
field=models.ManyToManyField(help_text='If one of these products are purchased, this condition is met.', to='registrasion.Product', verbose_name='Including product'),
),
migrations.AlterField(
model_name='productflag',
name='enabling_products',
field=models.ManyToManyField(help_text='If one of these products are purchased, this condition is met.', to='registrasion.Product', verbose_name='Including product'),
),
migrations.AlterField(
model_name='timeorstocklimitdiscount',
name='end_time',
field=models.DateTimeField(blank=True, help_text='When the condition should stop being true.', null=True, verbose_name='End time'),
),
migrations.AlterField(
model_name='timeorstocklimitdiscount',
name='limit',
field=models.PositiveIntegerField(blank=True, help_text='How many times this condition may be applied for all users.', null=True, verbose_name='Limit'),
),
migrations.AlterField(
model_name='timeorstocklimitdiscount',
name='start_time',
field=models.DateTimeField(blank=True, help_text='When the condition should start being true', null=True, verbose_name='Start time'),
),
migrations.AlterField(
model_name='timeorstocklimitflag',
name='end_time',
field=models.DateTimeField(blank=True, help_text='When the condition should stop being true.', null=True, verbose_name='End time'),
),
migrations.AlterField(
model_name='timeorstocklimitflag',
name='limit',
field=models.PositiveIntegerField(blank=True, help_text='How many times this condition may be applied for all users.', null=True, verbose_name='Limit'),
),
migrations.AlterField(
model_name='timeorstocklimitflag',
name='start_time',
field=models.DateTimeField(blank=True, help_text='When the condition should start being true', null=True, verbose_name='Start time'),
),
migrations.AlterField(
model_name='voucherflag',
name='voucher',
field=models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to='registrasion.Voucher', verbose_name='Voucher'),
),
]