conditional labels in second form
This commit is contained in:
parent
f1c66f1411
commit
58924235ff
2 changed files with 11 additions and 4 deletions
|
@ -40,10 +40,12 @@ class Grant(Volunteer):
|
||||||
abstract = True
|
abstract = True
|
||||||
|
|
||||||
# same model is used for Library, ELitStip and Software!
|
# same model is used for Library, ELitStip and Software!
|
||||||
class Library(Grant):
|
TYPE_CHOICES = [('BIB', 'Bibliotheksstipendium'),
|
||||||
TYPE_CHOICES = [('LIB', 'Bibliotheksstipendium'),
|
|
||||||
('ELIT', 'eLiteraturstipendium'),
|
('ELIT', 'eLiteraturstipendium'),
|
||||||
('SOFT', 'Softwarestipendium')]
|
('SOFT', 'Softwarestipendium')]
|
||||||
|
|
||||||
|
class Library(Grant):
|
||||||
|
|
||||||
type = models.CharField(
|
type = models.CharField(
|
||||||
max_length=4,
|
max_length=4,
|
||||||
choices=TYPE_CHOICES,
|
choices=TYPE_CHOICES,
|
||||||
|
|
|
@ -8,7 +8,7 @@ from django.template.loader import get_template
|
||||||
from django.template import Context
|
from django.template import Context
|
||||||
|
|
||||||
from .forms import ProjectForm, VolunteerForm, LibraryForm, IFGForm
|
from .forms import ProjectForm, VolunteerForm, LibraryForm, IFGForm
|
||||||
from .models import Project
|
from .models import Project, TYPE_CHOICES
|
||||||
|
|
||||||
def project(request):
|
def project(request):
|
||||||
# return HttpResponse("Hello, world. You're at the input form")
|
# return HttpResponse("Hello, world. You're at the input form")
|
||||||
|
@ -68,7 +68,11 @@ 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
|
||||||
else:
|
else:
|
||||||
print('ERROR! UNKNOWN FORMTYPE!')
|
print('ERROR! UNKNOWN FORMTYPE!')
|
||||||
else:
|
else:
|
||||||
|
@ -91,6 +95,7 @@ class ExternView(CookieWizardView):
|
||||||
form.realname = data['realname']
|
form.realname = data['realname']
|
||||||
form.username = data['username']
|
form.username = data['username']
|
||||||
form.email = data['email']
|
form.email = data['email']
|
||||||
|
# write type of form in some cases
|
||||||
if data['choice'] in ('BIB', 'ELIT', 'SOFT'):
|
if data['choice'] in ('BIB', 'ELIT', 'SOFT'):
|
||||||
form.type = data['choice']
|
form.type = data['choice']
|
||||||
form.save()
|
form.save()
|
||||||
|
|
Loading…
Reference in a new issue