From 1518463a942c153a49ee5e2b22dc1cf8822c2407 Mon Sep 17 00:00:00 2001 From: mhewel <58829786+mhewel@users.noreply.github.com> Date: Fri, 20 Sep 2024 19:04:07 +0200 Subject: [PATCH] temporary commit --- .../admin/volunteerrequestdepartment_admin.py | 13 +- members/forms/__init__.py | 2 + members/forms/volunteer_request_new_form.py | 139 +++++++++--------- members/models/volunteerrequestdepartment.py | 2 + members/templates/members/base.html | 2 +- members/urls.py | 8 +- members/views/VolunteerRequestNew.py | 26 ++-- members/views/__init__.py | 1 + 8 files changed, 99 insertions(+), 94 deletions(-) diff --git a/members/admin/volunteerrequestdepartment_admin.py b/members/admin/volunteerrequestdepartment_admin.py index 72fba580..6cdc4d01 100644 --- a/members/admin/volunteerrequestdepartment_admin.py +++ b/members/admin/volunteerrequestdepartment_admin.py @@ -42,23 +42,24 @@ class VolunteerRequestDepartmentAdmin(admin.ModelAdmin): "status", ) - fieldsets = [ ( "Forespørgsel", { "description": "Information fra person om at blive frivillig", - "fields": ("volunteer_request", "department","whishes", - "reference", - ), + "fields": ( + "volunteer_request", + "department", + "whishes", + "reference", + ), }, ), ( "Dato og status", { "description": "Information om oprettelse og status", - "fields": ("created", "finished", "status") -, + "fields": ("created", "finished", "status"), }, ), ] diff --git a/members/forms/__init__.py b/members/forms/__init__.py index 2dc586c1..be92b7cb 100644 --- a/members/forms/__init__.py +++ b/members/forms/__init__.py @@ -14,4 +14,6 @@ vol_signupForm, adminSignupForm, volunteerRequestNewForm, + volunteer_request_new_form, + ] diff --git a/members/forms/volunteer_request_new_form.py b/members/forms/volunteer_request_new_form.py index 9e19ac70..038c84f3 100644 --- a/members/forms/volunteer_request_new_form.py +++ b/members/forms/volunteer_request_new_form.py @@ -1,14 +1,12 @@ from django import forms - -# from django.conf import settings +from django.conf import settings from crispy_forms.helper import FormHelper from crispy_forms.layout import Layout, Fieldset, Submit, Field, Hidden, Div from members.models.department import Department +from members.models.person import Person -# from members.models.person import Person - -# from django.contrib.auth.password_validation import validate_password +from django.contrib.auth.password_validation import validate_password class volunteerRequestNewForm(forms.Form): @@ -24,7 +22,7 @@ def __init__(self, *args, **kwargs): Fieldset( "Frivilliges oplysninger", Div( - # Div(Field("volunteer_gender"), css_class="col-md-2"), + Div(Field("volunteer_gender"), css_class="col-md-2"), Div(Field("volunteer_name"), css_class="col-md-10"), Div( Field( @@ -34,80 +32,82 @@ def __init__(self, *args, **kwargs): ), Div(Field("volunteer_email"), css_class="col-md-3"), Div(Field("volunteer_phone"), css_class="col-md-3"), - # Div(Field("volunteer_department"), css_class="col-md-3"), + Div(Field("volunteer_department"), css_class="col-md-3"), css_class="row", ), ), - # Fieldset( - # "Adgangskode", - # Div( - # Div(Field("password1"), css_class="col"), - # Div(Field("password2"), css_class="col"), - # css_class="row", - # ), - # ), + Fieldset( + "Adgangskode", + Div( + Div(Field("password1"), css_class="col"), + Div(Field("password2"), css_class="col"), + css_class="row", + ), + ), Fieldset( "Adresse oplysninger", Div( - # Div( - # Field("search_address", id="search-address"), - # css_class="col-md-10", - # ), - # Div(Field("manual_entry", id="manual-entry"), css_class="col-md-2"), - # Div( - # Field( - # "streetname", readonly=True, css_class="autofilled-address" - # ), - # css_class="col-md-9", - # ), - # Div( - # Field( - # "housenumber", readonly=True, css_class="autofilled-address" - # ), - # css_class="col-md-1", - # ), - # Div( - # Field("floor", readonly=True, css_class="autofilled-address"), - # css_class="col-md-1", - # ), - # Div( - # Field("door", readonly=True, css_class="autofilled-address"), - # css_class="col-md-1", - # ), + # + Div( + Field("search_address", id="search-address"), + css_class="col-md-10", + ), + Div(Field("manual_entry", id="manual-entry"), css_class="col-md-2"), + Div( + Field( + "streetname", readonly=True, css_class="autofilled-address" + ), + css_class="col-md-9", + ), + Div( + Field( + "housenumber", readonly=True, css_class="autofilled-address" + ), + css_class="col-md-1", + ), + Div( + Field("floor", readonly=True, css_class="autofilled-address"), + css_class="col-md-1", + ), + Div( + Field("door", readonly=True, css_class="autofilled-address"), + css_class="col-md-1", + ), + # Div( Field("zipcode", readonly=True, css_class="autofilled-address"), - css_class="col-md-2", + css_class="col-md-1", + ), + Div( + Field("city", readonly=True, css_class="autofilled-address"), + css_class="col-md-5", ), - # Div( - # Field("city", readonly=True, css_class="autofilled-address"), - # css_class="col-md-5", - # ), - # Div( - # Field( - # "placename", readonly=True, css_class="autofilled-address" - # ), - # css_class="col-md-5", - # ), - # Hidden("dawa_id", "", id="id_dawa_id"), + Div( + Field( + "placename", readonly=True, css_class="autofilled-address" + ), + css_class="col-md-5", + ), + Hidden("dawa_id", "", id="id_dawa_id"), css_class="row", ), ), Submit("submit", "Opret", css_class="btn-success"), ) - # volunteer_gender = forms.ChoiceField( - # label="Køn", required=True, choices=Person.MEMBER_ADULT_GENDER_CHOICES - # ) + volunteer_gender = forms.ChoiceField( + label="Køn", required=True, choices=Person.MEMBER_ADULT_GENDER_CHOICES + ) volunteer_name = forms.CharField(label="Fulde navn", required=True, max_length=200) volunteer_email = forms.EmailField(label="Email", required=True) volunteer_phone = forms.CharField(label="Telefon", required=True, max_length=50) - # volunteer_birthday = forms.DateField( - # label="Fødselsdato", - # required=True, - # input_formats=(settings.DATE_INPUT_FORMATS), - # error_messages={"invalid": "Indtast en gyldig dato."}, - # widget=forms.DateInput(attrs={"type": "date"}), - # ) + volunteer_birthday = forms.DateField( + label="Fødselsdato", + required=True, + input_formats=(settings.DATE_INPUT_FORMATS), + error_messages={"invalid": "Indtast en gyldig dato."}, + widget=forms.DateInput(attrs={"type": "date"}), + ) volunteer_department = forms.ModelChoiceField( queryset=Department.objects.filter(closed_dtm__isnull=True).order_by("name"), required=True, @@ -115,7 +115,7 @@ def __init__(self, *args, **kwargs): empty_label="-", ) - """ + password1 = forms.CharField( widget=forms.PasswordInput(), label="Adgangskode", @@ -138,20 +138,19 @@ def __init__(self, *args, **kwargs): floor = forms.CharField(label="Etage", required=False, max_length=3) door = forms.CharField(label="Dør", required=False, max_length=5) placename = forms.CharField(label="Stednavn", required=False, max_length=200) - """ zipcode = forms.CharField(label="Postnummer", max_length=4.0, required=True) - # city = forms.CharField(label="By", max_length=200, required=True) - # dawa_id = forms.CharField( - # label="Dawa ID", max_length=200, widget=forms.HiddenInput(), required=False - # ) + city = forms.CharField(label="By", max_length=200, required=True) + dawa_id = forms.CharField( + label="Dawa ID", max_length=200, widget=forms.HiddenInput(), required=False + ) form_id = forms.CharField( label="Form ID", max_length=10, widget=forms.HiddenInput(), initial="signup" ) - """ + manual_entry = forms.ChoiceField( label="Indtast felter manuelt", widget=forms.CheckboxInput, required=False, choices=((True, "True"), (False, "False")), ) - """ + diff --git a/members/models/volunteerrequestdepartment.py b/members/models/volunteerrequestdepartment.py index 1622cd3b..d3cf470f 100644 --- a/members/models/volunteerrequestdepartment.py +++ b/members/models/volunteerrequestdepartment.py @@ -39,10 +39,12 @@ class Meta: def whishes(self): return self.volunteer_request.info_whishes + whishes.short_description = "Ønsker" def reference(self): return self.volunteer_request.info_reference + reference.short_description = "Reference" def __str__(self): diff --git a/members/templates/members/base.html b/members/templates/members/base.html index db8719c6..cd9936c1 100644 --- a/members/templates/members/base.html +++ b/members/templates/members/base.html @@ -20,7 +20,7 @@ - {% if request.path == "/" or request.path == "/volunteer" or "/family/Person/" or "/admin_signup/" or "/voilunteer_request" in request.path %} + {% if request.path == "/" or request.path == "/volunteer/" or "/family/Person/" or "/admin_signup/" or "/new_vr/" in request.path %} {% load crispy_forms_tags %} diff --git a/members/urls.py b/members/urls.py index d9612b5f..8468c2f4 100644 --- a/members/urls.py +++ b/members/urls.py @@ -20,6 +20,7 @@ paymentGatewayErrorView, userCreated, volunteerSignup, + VolunteerRequestNew, ) from django.contrib.auth import views as auth_views from graphene_django.views import GraphQLView @@ -75,9 +76,10 @@ re_path(r"^membership/$", Membership, name="membership"), re_path(r"^support_membership/$", SupportMembership, name="support_membership"), re_path(r"^volunteer$", volunteerSignup, name="volunteer_signup"), - # re_path( - # r"^volunteer_request_new/$", VolunteerRequestNew, name="volunteer_request_new" - # ), + # re_path(r"^volunteer_request_new/$", VolunteerRequestNew, name="volunteer_request_new"), + re_path( + r"^new_vr/$", VolunteerRequestNew, name="volunteer_request_new_form" + ), # name="volunteer_request_new"), re_path(r"^user_created/$", userCreated, name="user_created"), re_path(r"^admin_signup/$", AdminSignup, name="admin_signup"), re_path(r"^family/$", FamilyDetails, name="family_detail"), diff --git a/members/views/VolunteerRequestNew.py b/members/views/VolunteerRequestNew.py index b2bca68d..eae12d33 100644 --- a/members/views/VolunteerRequestNew.py +++ b/members/views/VolunteerRequestNew.py @@ -1,27 +1,24 @@ from django.urls import reverse from django.http import HttpResponseRedirect from django.shortcuts import render - -# from django.utils import timezone +from django.utils import timezone from django.views.decorators.clickjacking import xframe_options_exempt from members.forms import volunteer_request_new_form - -# from members.models.department import Department +from members.models.department import Department from members.models.family import Family - -# from members.models.person import Person -# from members.models.volunteer import Volunteer +from members.models.person import Person +from members.models.volunteer import Volunteer from members.models.volunteerrequest import VolunteerRequest - -# from django.contrib.auth.models import User +from members.models.volunteerrequestdepartment import VolunteerRequestDepartment +from django.contrib.auth.models import User @xframe_options_exempt -def volunteerRequestNew(request): +def VolunteerRequestNew(request): if request.method == "POST": # which form was filled out ? - if request.POST["form_id"] == "new_vol_request": + if request.POST["form_id"] == "volunteer_request_new_form": vol_request_form = volunteer_request_new_form(request.POST) if vol_request_form.is_valid(): ######################################### @@ -70,12 +67,13 @@ def volunteerRequestNew(request): return render( request, "members/volunteer_request.html", - {"vol_requestform": vol_req_form}, + {"volunteer_request_new_form": vol_request_form}, ) - vol_req_form = volunteer_request_new_form() + # initial load (if we did not return above) + vol_request_form = volunteer_request_new_form() return render( request, "members/volunteer_request.html", - {"volunteer_request_new_form": vol_req_form}, + {"volunteer_request_new_form": vol_request_form}, ) diff --git a/members/views/__init__.py b/members/views/__init__.py index c8a003e7..daa19ac0 100644 --- a/members/views/__init__.py +++ b/members/views/__init__.py @@ -19,3 +19,4 @@ from members.views.paymentGatewayErrorView import paymentGatewayErrorView from members.views.userCreated import userCreated from members.views.volunteerSignup import volunteerSignup +from members.views.VolunteerRequestNew import VolunteerRequestNew