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
34857ccf03
commit
2254b77a0d
|
@ -56,11 +56,23 @@ class InternForm(FdbForm):
|
||||||
|
|
||||||
class TravelForm(FdbForm):
|
class TravelForm(FdbForm):
|
||||||
# TODO: add some javascript to show/hide other-field
|
# 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:
|
class Meta:
|
||||||
model = Travel
|
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' )
|
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(),
|
widgets = {'checkin': AdminDateWidget(),
|
||||||
'checkout': AdminDateWidget(),}
|
'checkout': AdminDateWidget(),}
|
||||||
|
fields = ['project_name', 'transport', 'travelcost', 'checkin', 'checkout', 'hotel', 'notes']
|
||||||
|
|
||||||
class LibraryForm(FdbForm):
|
class LibraryForm(FdbForm):
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,16 @@
|
||||||
window.addEventListener("load", function() {
|
window.addEventListener("load", function() {
|
||||||
(function($) {
|
(function($) {
|
||||||
$(function() {
|
$(function() {
|
||||||
|
|
||||||
|
|
||||||
|
// selfbuy section
|
||||||
|
|
||||||
var selectField_selfbuy = $('#id_selfbuy'),
|
var selectField_selfbuy = $('#id_selfbuy'),
|
||||||
verified_selfbuy_div = $('#id_selfbuy_give_data').parent().parent(),
|
verified_selfbuy_div = $('#id_selfbuy_give_data').parent().parent(),
|
||||||
verified_selfbuy = $('#id_selfbuy_give_data');
|
verified_selfbuy = $('#id_selfbuy_give_data');
|
||||||
|
|
||||||
|
|
||||||
|
// make checked to get through the required
|
||||||
function toggleVerified_selfbuy(value) {
|
function toggleVerified_selfbuy(value) {
|
||||||
if (value === "FALSE") {
|
if (value === "FALSE") {
|
||||||
verified_selfbuy_div.show();
|
verified_selfbuy_div.show();
|
||||||
|
@ -23,8 +29,6 @@ window.addEventListener("load", function() {
|
||||||
toggleVerified_selfbuy($(this).val());
|
toggleVerified_selfbuy($(this).val());
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var selectField = $('#id_variant'),
|
var selectField = $('#id_variant'),
|
||||||
verified = $('#id_url_of_pic').parent().parent();
|
verified = $('#id_url_of_pic').parent().parent();
|
||||||
|
|
||||||
|
|
|
@ -202,6 +202,9 @@ class ExternView(CookieWizardView):
|
||||||
data = {}
|
data = {}
|
||||||
for form in form_list:
|
for form in form_list:
|
||||||
data = {**data, **form.cleaned_data}
|
data = {**data, **form.cleaned_data}
|
||||||
|
|
||||||
|
if data['selfbuy'] == 'TRUE':
|
||||||
|
data['selfbuy_give_data'] = 'False'
|
||||||
print(data)
|
print(data)
|
||||||
|
|
||||||
# write data to database
|
# write data to database
|
||||||
|
@ -214,6 +217,7 @@ class ExternView(CookieWizardView):
|
||||||
# write type of form in some cases
|
# write type of form in some cases
|
||||||
if data['choice'] in ('BIB', 'ELIT', 'SOFT'):
|
if data['choice'] in ('BIB', 'ELIT', 'SOFT'):
|
||||||
modell.type = data['choice']
|
modell.type = data['choice']
|
||||||
|
|
||||||
form.save()
|
form.save()
|
||||||
|
|
||||||
# add some data to context for mail templates
|
# add some data to context for mail templates
|
||||||
|
|
Loading…
Reference in New Issue