Ønsker du at være frivillig - og ikke allerede oprettet i medlemssystemet ?
-
Hvis du har børn der er tilmeldt i systemet og allerede er oprettet som familie, så log blot på jeres familie side med den email du opskrev dig med, da du tilmeldte dig. Her kan du også tilføje flere personer, hvis det f.eks. er din partner der har tilmeldt børnene men du nu selv vil være med som frivillig.
+
Hvis du har børn der er tilmeldt i systemet og allerede er oprettet som familie,
+ så log blot på jeres familie side med den email du opskrev dig med, da du tilmeldte dig
+ Her kan du også tilføje flere personer, hvis det f.eks. er din partner der har tilmeldt børnene men du nu selv vil være med som frivillig.
Denne formular er tænkt til frivillige, der ikke har børn der er medlemmer i Coding Pirates.
-
-
- {% crispy vol_signupform %}
-
+
+
+ {% if messages %}
+ {% for message in messages %}
+
+ {{ message }}
+
+ {% endfor %}
+ {% endif %}
+
+
+
{% endblock %}
\ No newline at end of file
diff --git a/members/templates/members/volunteer_request_created.html b/members/templates/members/volunteer_request_created.html
new file mode 100644
index 00000000..04d04180
--- /dev/null
+++ b/members/templates/members/volunteer_request_created.html
@@ -0,0 +1,7 @@
+{% extends 'members/base.html' %}
+{% block content %}
+
+
Volunteer Request Submitted
+
Your volunteer request has been submitted successfully!
+
+{% endblock %}
\ No newline at end of file
diff --git a/members/urls.py b/members/urls.py
index 8468c2f4..2241e848 100644
--- a/members/urls.py
+++ b/members/urls.py
@@ -1,4 +1,6 @@
from django.urls import re_path
+from django.views.generic import TemplateView
+
from members.views import (
AccountCreate,
Activities,
@@ -14,13 +16,12 @@
PersonUpdate,
QuickpayCallback,
SupportMembership,
- VolunteerRequestNew,
+ volunteer_request_view,
WaitingListSetSubscription,
departmentView,
paymentGatewayErrorView,
userCreated,
volunteerSignup,
- VolunteerRequestNew,
)
from django.contrib.auth import views as auth_views
from graphene_django.views import GraphQLView
@@ -76,10 +77,12 @@
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/$", volunteer_request_view, name="volunteer_request"),
re_path(
- r"^new_vr/$", VolunteerRequestNew, name="volunteer_request_new_form"
- ), # name="volunteer_request_new"),
+ r"^volunteer_request_created/$",
+ TemplateView.as_view(template_name="members/volunteer_request_created.html"),
+ name="volunteer_request_created",
+ ),
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/VolunteerRequest.py b/members/views/VolunteerRequest.py
new file mode 100644
index 00000000..40836a63
--- /dev/null
+++ b/members/views/VolunteerRequest.py
@@ -0,0 +1,42 @@
+from django.shortcuts import render
+from django.http import HttpResponseRedirect
+from django.urls import reverse
+from django.contrib import messages
+from members.forms import VolunteerRequestForm
+from members.models.volunteerrequestdepartment import VolunteerRequestDepartment
+
+
+def volunteer_request_view(request):
+ if request.method == "POST":
+ volunteer_request_form = VolunteerRequestForm(request.POST)
+
+ if volunteer_request_form.is_valid():
+ vol_req_obj = volunteer_request_form.save()
+ departments = volunteer_request_form.cleaned_data["department_list"]
+ for department in departments:
+ VolunteerRequestDepartment.objects.create(
+ volunteer_request=vol_req_obj, department=department
+ )
+
+ messages.success(
+ request, "Your volunteer request has been submitted successfully!"
+ )
+ return HttpResponseRedirect(reverse("volunteer_request_created"))
+ else:
+ return render(
+ request,
+ "members/volunteer_request.html",
+ {
+ "volunteer_request_form": volunteer_request_form,
+ },
+ )
+ else:
+ volunteer_request_form = VolunteerRequestForm()
+
+ return render(
+ request,
+ "members/volunteer_request.html",
+ {
+ "volunteer_request_form": volunteer_request_form,
+ },
+ )
diff --git a/members/views/VolunteerRequestNew.py b/members/views/VolunteerRequestNew.py
deleted file mode 100644
index eae12d33..00000000
--- a/members/views/VolunteerRequestNew.py
+++ /dev/null
@@ -1,79 +0,0 @@
-from django.urls import reverse
-from django.http import HttpResponseRedirect
-from django.shortcuts import render
-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.family import Family
-from members.models.person import Person
-from members.models.volunteer import Volunteer
-from members.models.volunteerrequest import VolunteerRequest
-from members.models.volunteerrequestdepartment import VolunteerRequestDepartment
-from django.contrib.auth.models import User
-
-
-@xframe_options_exempt
-def VolunteerRequestNew(request):
- if request.method == "POST":
- # which form was filled out ?
- if request.POST["form_id"] == "volunteer_request_new_form":
- vol_request_form = volunteer_request_new_form(request.POST)
- if vol_request_form.is_valid():
- #########################################
- # Check for minimum 1 department selected
- #########################################
-
- # Check if email already exist for a user
- try:
- family = Family.objects.get(
- email__iexact=request.POST["volunteer_email"]
- )
- vol_request_form.add_error(
- "volunteer_email",
- f"Denne email addresse ({family.email}) er allerede oprettet. Log ind ovenfor, for at få adgang.",
- )
- # using family.email to ensure family is used, to avoid warning from flake8
- return render(
- request,
- "members/volunteer_request.html",
- {"volunteer_request_new_form": vol_request_form},
- )
- except: # noqa: E722
- # all is fine - we did not expect any
- pass
-
- # Create record for the request
- vol_req_obj = VolunteerRequest.objects.create(
- person=None,
- name=vol_request_form.cleaned_data["volunteer_name"],
- email=None,
- phone=None,
- age=None,
- zip=None,
- info_reference=None,
- info_whishes=None,
- token=None,
- )
- vol_req_obj.save()
-
- # Loop through all the selected departments and make records for them
-
- # Send email(s) to department(s) and requestor ?
-
- return HttpResponseRedirect(reverse("user_created")) # THIS IS WRONG!
- else:
- return render(
- request,
- "members/volunteer_request.html",
- {"volunteer_request_new_form": vol_request_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_request_form},
- )
diff --git a/members/views/__init__.py b/members/views/__init__.py
index daa19ac0..c64a6180 100644
--- a/members/views/__init__.py
+++ b/members/views/__init__.py
@@ -19,4 +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
+from members.views.VolunteerRequest import volunteer_request_view