Skip to content

Commit

Permalink
temporary commit
Browse files Browse the repository at this point in the history
  • Loading branch information
mhewel committed Sep 20, 2024
1 parent 8cfd699 commit 1518463
Show file tree
Hide file tree
Showing 8 changed files with 99 additions and 94 deletions.
13 changes: 7 additions & 6 deletions members/admin/volunteerrequestdepartment_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
},
),
]
2 changes: 2 additions & 0 deletions members/forms/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,6 @@
vol_signupForm,
adminSignupForm,
volunteerRequestNewForm,
volunteer_request_new_form,

]
139 changes: 69 additions & 70 deletions members/forms/volunteer_request_new_form.py
Original file line number Diff line number Diff line change
@@ -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):
Expand All @@ -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(
Expand All @@ -34,88 +32,90 @@ 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,
label="Afdeling",
empty_label="-",
)

"""

password1 = forms.CharField(
widget=forms.PasswordInput(),
label="Adgangskode",
Expand All @@ -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")),
)
"""

2 changes: 2 additions & 0 deletions members/models/volunteerrequestdepartment.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion members/templates/members/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<script src="{% static "members/js/better-dom.min.js" %}"></script>
<script src="{% static "members/js/better-dateinput-polyfill.min.js" %}"></script>
<script src="{% static "members/js/tablesearch.js" %}"></script>
{% 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 %}
<script src="{% static "members/js/dawa-autocomplete.js" %}"></script>
<script src="{% static "members/js/dawa-form-fill.js" %}"></script>
Expand Down
8 changes: 5 additions & 3 deletions members/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
paymentGatewayErrorView,
userCreated,
volunteerSignup,
VolunteerRequestNew,
)
from django.contrib.auth import views as auth_views
from graphene_django.views import GraphQLView
Expand Down Expand Up @@ -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"),
Expand Down
26 changes: 12 additions & 14 deletions members/views/VolunteerRequestNew.py
Original file line number Diff line number Diff line change
@@ -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():
#########################################
Expand Down Expand Up @@ -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},
)
1 change: 1 addition & 0 deletions members/views/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 1518463

Please sign in to comment.