sponsor benefit type richitext, simple and option

Signed-off-by: Hiroshi Miura <miurahr@linux.com>
This commit is contained in:
Hiroshi Miura 2015-07-11 11:22:15 +09:00
parent 0d7df4db00
commit d174008149
2 changed files with 6 additions and 2 deletions

View file

@ -47,6 +47,9 @@ class SponsorDetailsForm(forms.ModelForm):
class SponsorBenefitsInlineFormSet(BaseInlineFormSet): class SponsorBenefitsInlineFormSet(BaseInlineFormSet):
def __init__(self, *args, **kwargs):
kwargs['queryset'] = kwargs.get('queryset', self.model._default_manager).exclude(benefit__type="option")
super(SponsorBenefitsInlineFormSet, self).__init__(*args, **kwargs)
def _construct_form(self, i, **kwargs): def _construct_form(self, i, **kwargs):
form = super(SponsorBenefitsInlineFormSet, self)._construct_form(i, **kwargs) form = super(SponsorBenefitsInlineFormSet, self)._construct_form(i, **kwargs)

View file

@ -258,7 +258,8 @@ class SponsorBenefit(models.Model):
ordering = ["-active"] ordering = ["-active"]
def __unicode__(self): def __unicode__(self):
return u"%s - %s" % (self.sponsor, self.benefit) return u"%s - %s (%s)" % (self.sponsor, self.benefit,
self.benefit.type)
def save(self, *args, **kwargs): def save(self, *args, **kwargs):
# Validate - save() doesn't clean your model by default, so call # Validate - save() doesn't clean your model by default, so call
@ -281,7 +282,7 @@ class SponsorBenefit(models.Model):
""" """
if self.benefit.type == "file" or self.benefit.type == "weblogo": if self.benefit.type == "file" or self.benefit.type == "weblogo":
return ["upload"] return ["upload"]
elif self.benefit.type == "text": elif self.benefit.type in ("text", "richtext", "simple", "option"):
return ["text"] return ["text"]
return [] return []