forked from beba/foerderbarometer
changed fields in Travel to required, changed saving of value of selfbuy_give_data when person wants to selfbuy to false
This commit is contained in:
parent
7a99176b23
commit
2501bb0866
|
@ -56,11 +56,23 @@ class InternForm(FdbForm):
|
|||
|
||||
class TravelForm(FdbForm):
|
||||
# TODO: add some javascript to show/hide other-field
|
||||
|
||||
# this is the code, to change required to false if needed
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
self.fields['project_name'].required = True
|
||||
self.fields['transport'].required = True
|
||||
self.fields['travelcost'].required = True
|
||||
self.fields['checkin'].required = True
|
||||
self.fields['checkout'].required = True
|
||||
self.fields['hotel'].required = True
|
||||
|
||||
class Meta:
|
||||
model = Travel
|
||||
exclude = ('granted', 'granted_date', 'survey_mail_send', 'realname', 'email', 'survey_mail_date', 'project', 'request_url', 'payed_for_hotel_by', 'payed_for_travel_by', 'intern_notes' )
|
||||
widgets = {'checkin': AdminDateWidget(),
|
||||
'checkout': AdminDateWidget(),}
|
||||
fields = ['project_name', 'transport', 'travelcost', 'checkin', 'checkout', 'hotel', 'notes']
|
||||
|
||||
class LibraryForm(FdbForm):
|
||||
|
||||
|
|
|
@ -1,10 +1,16 @@
|
|||
window.addEventListener("load", function() {
|
||||
(function($) {
|
||||
$(function() {
|
||||
|
||||
|
||||
// selfbuy section
|
||||
|
||||
var selectField_selfbuy = $('#id_selfbuy'),
|
||||
verified_selfbuy_div = $('#id_selfbuy_give_data').parent().parent(),
|
||||
verified_selfbuy = $('#id_selfbuy_give_data');
|
||||
|
||||
|
||||
// make checked to get through the required
|
||||
function toggleVerified_selfbuy(value) {
|
||||
if (value === "FALSE") {
|
||||
verified_selfbuy_div.show();
|
||||
|
@ -23,8 +29,6 @@ window.addEventListener("load", function() {
|
|||
toggleVerified_selfbuy($(this).val());
|
||||
});
|
||||
|
||||
|
||||
|
||||
var selectField = $('#id_variant'),
|
||||
verified = $('#id_url_of_pic').parent().parent();
|
||||
|
||||
|
|
|
@ -202,8 +202,11 @@ class ExternView(CookieWizardView):
|
|||
data = {}
|
||||
for form in form_list:
|
||||
data = {**data, **form.cleaned_data}
|
||||
|
||||
if data['selfbuy'] == 'TRUE':
|
||||
data['selfbuy_give_data'] = 'False'
|
||||
print(data)
|
||||
|
||||
|
||||
# write data to database
|
||||
modell = form.save(commit=False)
|
||||
# we have to copy the data from the first form here
|
||||
|
@ -214,6 +217,7 @@ class ExternView(CookieWizardView):
|
|||
# write type of form in some cases
|
||||
if data['choice'] in ('BIB', 'ELIT', 'SOFT'):
|
||||
modell.type = data['choice']
|
||||
|
||||
form.save()
|
||||
|
||||
# add some data to context for mail templates
|
||||
|
|
Loading…
Reference in New Issue