conditional hiding of address textfield in literature form added
This commit is contained in:
parent
e9de3fcb99
commit
1050308712
5 changed files with 44 additions and 5 deletions
|
@ -107,7 +107,7 @@ class LiteratureForm(CheckForm):
|
|||
self.fields['selfbuy_give_data'].required = True
|
||||
class Meta:
|
||||
model = Literature
|
||||
fields = ['cost', 'info', 'source', 'notes', 'selfbuy', 'selfbuy_give_data']
|
||||
fields = ['cost', 'info', 'source', 'notes', 'selfbuy', 'selfbuy_data', 'selfbuy_give_data']
|
||||
exclude = ['intern_notes']
|
||||
class Media:
|
||||
js = ('dropdown/js/base.js',)
|
||||
|
|
18
input/migrations/0075_literature_selfbuy_data.py
Normal file
18
input/migrations/0075_literature_selfbuy_data.py
Normal file
|
@ -0,0 +1,18 @@
|
|||
# Generated by Django 4.1.2 on 2022-11-21 13:49
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('input', '0074_project_intern_notes'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='literature',
|
||||
name='selfbuy_data',
|
||||
field=models.TextField(default='', help_text='Bitte gib hier alle persönlichen Daten an, und zwar genau so,<br> wie sie (auch in der entsprechenden Reihenfolge) auf den Visitenkarten stehen sollen<br> (z.B. Vorname Nachname, Benutzer:/Benutzerin:, Benutzer-/-innenname, Anschrift,<br> Telefonnummer, E-Mail-Adresse usw.). Trenne die einzelnen Angaben durch Zeilenumbrüche.<br> Hinweis: Telefonnummern bilden wir üblicherweise im internationalen Format gemäß<br> DIN 5008 ab. Als anzugebende E-Mail-Adresse empfehlen wir dir eine Wikimedia-Projekt-<br> Adresse, die du ebenfalls beantragen kannst, sofern du nicht bereits eine besitzt.', max_length=1000, verbose_name='Persönliche Daten für die Visitenkarten'),
|
||||
),
|
||||
]
|
|
@ -209,7 +209,14 @@ class Literature(Grant):
|
|||
source = models.CharField(max_length=200, verbose_name='Bezugsquelle',
|
||||
help_text="Bitte gib an, wo du das Werk kaufen möchtest.")
|
||||
selfbuy = models.CharField( max_length=10, verbose_name='Selbstkauf?', choices=SELFBUY_CHOICES.items(), default='TRUE')
|
||||
selfbuy_give_data = models.BooleanField(default='NONE', verbose_name=format_html('Datenweitergabe erlauben'), help_text=format_html('Weitergabe meiner Daten (Name, Postadresse) an den von mir angegebenen Anbieter/Dienstleister.'))
|
||||
selfbuy_give_data = models.BooleanField(verbose_name=format_html('Datenweitergabe erlauben'), help_text=format_html('Weitergabe meiner Daten (Name, Postadresse) an den von mir angegebenen Anbieter/Dienstleister.'))
|
||||
selfbuy_data = models.TextField(max_length=1000, verbose_name='Persönliche Daten sowie Adresse', default='',
|
||||
help_text=format_html("Bitte gib hier alle persönlichen Daten an, die wir benötigen, um das Werk<br>\
|
||||
für dich zu kaufen und es dir anschließend zu schicken (z.B. Vorname Nachname, Anschrift, <br>\
|
||||
Telefonnummer, E-Mail-Adresse usw.). Trenne die einzelnen Angaben durch Zeilenumbrüche. <br>\
|
||||
Hinweis: Telefonnummern bilden wir üblicherweise im internationalen Format gemäß<br>\
|
||||
DIN 5008 ab. Als anzugebende E-Mail-Adresse empfehlen wir dir eine Wikimedia-Projekt-<br>\
|
||||
Adresse, die du ebenfalls beantragen kannst, sofern du nicht bereits eine besitzt."))
|
||||
intern_notes = models.TextField(max_length=1000, blank=True)
|
||||
|
||||
class IFG(Grant):
|
||||
|
|
|
@ -7,16 +7,23 @@ window.addEventListener("load", function() {
|
|||
|
||||
var selectField_selfbuy = $('#id_selfbuy'),
|
||||
verified_selfbuy_div = $('#id_selfbuy_give_data').parent().parent(),
|
||||
verified_selfbuy = $('#id_selfbuy_give_data');
|
||||
|
||||
verified_selfbuy = $('#id_selfbuy_give_data'),
|
||||
data_selfbuy_div = $('#id_selfbuy_data').parent().parent(),
|
||||
data_selfbuy = $('#id_selfbuy_data');
|
||||
|
||||
|
||||
|
||||
// make checked to get through the required
|
||||
function toggleVerified_selfbuy(value) {
|
||||
if (value === "FALSE") {
|
||||
verified_selfbuy_div.show();
|
||||
data_selfbuy_div.show();
|
||||
data_selfbuy.val("");
|
||||
verified_selfbuy.prop("checked", false);
|
||||
} else {
|
||||
verified_selfbuy_div.hide();
|
||||
data_selfbuy_div.hide();
|
||||
data_selfbuy.val("NONE");
|
||||
verified_selfbuy.prop("checked", true);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -124,6 +124,10 @@ class InternView(LoginRequiredMixin, CookieWizardView):
|
|||
form.email = data['email']
|
||||
form.granted = True
|
||||
form.granted_date = date.today()
|
||||
|
||||
if data['choice'] == 'LIT':
|
||||
form.selfbuy_give_data = data['selfbuy_give_data']
|
||||
|
||||
form.save()
|
||||
|
||||
return done(self.request)
|
||||
|
@ -204,7 +208,6 @@ 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)
|
||||
|
@ -213,6 +216,10 @@ class ExternView(CookieWizardView):
|
|||
modell = form.save(commit=False)
|
||||
# we have to copy the data from the first form here
|
||||
# this is a bit ugly code. can we copy this without explicit writing?
|
||||
|
||||
if data['choice'] == 'LIT':
|
||||
modell.selfbuy_give_data = data['selfbuy_give_data']
|
||||
|
||||
modell.realname = data['realname']
|
||||
modell.username = data['username']
|
||||
modell.email = data['email']
|
||||
|
|
Loading…
Reference in a new issue