2012-02-05 20:03:30 +00:00
|
|
|
from django.contrib import admin
|
|
|
|
|
2012-07-12 19:17:42 +00:00
|
|
|
from symposion.sponsorship.models import SponsorLevel, Sponsor, Benefit, BenefitLevel, SponsorBenefit
|
2012-02-05 20:03:30 +00:00
|
|
|
|
|
|
|
|
2012-07-12 19:17:42 +00:00
|
|
|
class BenefitLevelInline(admin.TabularInline):
|
|
|
|
model = BenefitLevel
|
|
|
|
extra = 0
|
|
|
|
|
|
|
|
|
|
|
|
class SponsorBenefitInline(admin.StackedInline):
|
|
|
|
model = SponsorBenefit
|
|
|
|
extra = 0
|
|
|
|
fieldsets = [
|
|
|
|
(None, {
|
|
|
|
"fields": [
|
|
|
|
("benefit", "active"),
|
|
|
|
("max_words", "other_limits"),
|
|
|
|
"text",
|
|
|
|
"upload",
|
|
|
|
]
|
|
|
|
})
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
class SponsorAdmin(admin.ModelAdmin):
|
|
|
|
|
|
|
|
save_on_top = True
|
|
|
|
fieldsets = [
|
|
|
|
(None, {
|
|
|
|
"fields": [
|
|
|
|
("name", "applicant"),
|
|
|
|
("level", "active"),
|
|
|
|
"external_url",
|
|
|
|
"annotation",
|
|
|
|
("contact_name", "contact_email")
|
|
|
|
]
|
|
|
|
}),
|
|
|
|
("Metadata", {
|
|
|
|
"fields": ["added"],
|
|
|
|
"classes": ["collapse"]
|
|
|
|
})
|
|
|
|
]
|
|
|
|
inlines = [SponsorBenefitInline]
|
2012-07-18 23:22:41 +00:00
|
|
|
list_display = ["name", "external_url", "level", "active"]
|
2012-07-12 19:17:42 +00:00
|
|
|
|
|
|
|
def get_form(self, *args, **kwargs):
|
|
|
|
# @@@ kinda ugly but using choices= on NullBooleanField is broken
|
|
|
|
form = super(SponsorAdmin, self).get_form(*args, **kwargs)
|
|
|
|
form.base_fields["active"].widget.choices = [
|
|
|
|
(u"1", "unreviewed"),
|
|
|
|
(u"2", "approved"),
|
|
|
|
(u"3", "rejected")
|
|
|
|
]
|
|
|
|
return form
|
|
|
|
|
|
|
|
|
|
|
|
class BenefitAdmin(admin.ModelAdmin):
|
|
|
|
|
2012-07-18 23:22:41 +00:00
|
|
|
list_display = ["name", "type", "description"]
|
2012-07-12 19:17:42 +00:00
|
|
|
inlines = [BenefitLevelInline]
|
|
|
|
|
|
|
|
|
|
|
|
class SponsorLevelAdmin(admin.ModelAdmin):
|
|
|
|
|
|
|
|
inlines = [BenefitLevelInline]
|
|
|
|
|
|
|
|
|
|
|
|
admin.site.register(SponsorLevel, SponsorLevelAdmin)
|
|
|
|
admin.site.register(Sponsor, SponsorAdmin)
|
|
|
|
admin.site.register(Benefit, BenefitAdmin)
|