Browse Source

changed fields in Travel to required, changed saving of value of selfbuy_give_data when person wants to selfbuy to false

master
corsaronero 2 years ago
parent
commit
2501bb0866
3 changed files with 23 additions and 3 deletions
  1. +12
    -0
      input/forms.py
  2. +6
    -2
      input/static/dropdown/js/base.js
  3. +5
    -1
      input/views.py

+ 12
- 0
input/forms.py View File

@ -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):

+ 6
- 2
input/static/dropdown/js/base.js View File

@ -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();

+ 5
- 1
input/views.py View File

@ -202,8 +202,11 @@ 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
modell = form.save(commit=False) modell = form.save(commit=False)
# we have to copy the data from the first form here # 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 # 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…
Cancel
Save