changed TYPE_CHOICES to dict to simplify some code
This commit is contained in:
parent
74eacb26c5
commit
9e0903ca0e
|
@ -17,7 +17,7 @@ class ProjectForm(ModelForm):
|
||||||
|
|
||||||
class VolunteerForm(ModelForm):
|
class VolunteerForm(ModelForm):
|
||||||
|
|
||||||
choice = ChoiceField(choices=TYPE_CHOICES, widget=RadioSelect,
|
choice = ChoiceField(choices=TYPE_CHOICES.items(), widget=RadioSelect,
|
||||||
label='Was möchtest Du beantragen?')
|
label='Was möchtest Du beantragen?')
|
||||||
|
|
||||||
check = BooleanField(required=True,
|
check = BooleanField(required=True,
|
||||||
|
|
|
@ -49,21 +49,21 @@ class Grant(Volunteer):
|
||||||
abstract = True
|
abstract = True
|
||||||
|
|
||||||
|
|
||||||
TYPE_CHOICES = [('BIB', 'Bibliotheksstipendium'),
|
TYPE_CHOICES = {'BIB': 'Bibliotheksstipendium',
|
||||||
('ELIT', 'eLiteraturstipendium'),
|
'ELIT': 'eLiteraturstipendium',
|
||||||
('SOFT', 'Softwarestipendium'),
|
'SOFT': 'Softwarestipendium',
|
||||||
('VIS', 'Visitenkarten'),
|
'VIS': 'Visitenkarten',
|
||||||
('LIST', 'Mailingliste'),
|
'LIST': 'Mailingliste',
|
||||||
('MAIL', 'E-Mail-Adresse'),
|
'MAIL': 'E-Mail-Adresse',
|
||||||
('IFG', 'Kostenübernahme IFG-Anfrage'),
|
'IFG': 'Kostenübernahme IFG-Anfrage',
|
||||||
('LIT', 'Literaturstipendium'),]
|
'LIT': 'Literaturstipendium',}
|
||||||
|
|
||||||
# same model is used for Library, ELitStip and Software!
|
# same model is used for Library, ELitStip and Software!
|
||||||
class Library(Grant):
|
class Library(Grant):
|
||||||
|
|
||||||
type = models.CharField(
|
type = models.CharField(
|
||||||
max_length=4,
|
max_length=4,
|
||||||
choices=TYPE_CHOICES, #attention: actually only BIB, ELIT, SOFT should be used here
|
choices=TYPE_CHOICES.items(), #attention: actually only BIB, ELIT, SOFT should be used here
|
||||||
default='LIB',
|
default='LIB',
|
||||||
)
|
)
|
||||||
library = models.CharField(max_length=200)
|
library = models.CharField(max_length=200)
|
||||||
|
|
|
@ -106,11 +106,8 @@ class ExternView(CookieWizardView):
|
||||||
form = IFGForm(data)
|
form = IFGForm(data)
|
||||||
elif choice in ('BIB', 'SOFT', 'ELIT'):
|
elif choice in ('BIB', 'SOFT', 'ELIT'):
|
||||||
print ('one of the famous three detected!')
|
print ('one of the famous three detected!')
|
||||||
for (k,v) in TYPE_CHOICES:
|
|
||||||
if k == choice:
|
|
||||||
break
|
|
||||||
form = LibraryForm(data)
|
form = LibraryForm(data)
|
||||||
form.fields['library'].label = v
|
form.fields['library'].label = TYPE_CHOICES[choice]
|
||||||
else:
|
else:
|
||||||
raise RuntimeError(f'ERROR! UNKNOWN FORMTYPE {choice}')
|
raise RuntimeError(f'ERROR! UNKNOWN FORMTYPE {choice}')
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in New Issue