diff --git a/bikeshop_project/registration/templates/edit_member_form.html b/bikeshop_project/registration/templates/edit_member_form.html new file mode 100644 index 0000000..e1ca6b2 --- /dev/null +++ b/bikeshop_project/registration/templates/edit_member_form.html @@ -0,0 +1,197 @@ +{% extends 'base.html' %} +{% load staticfiles %} + +{% block styles %} + +{% endblock %} + +{% block scripts %} + + + + + +{% endblock %} + +{% block content %} +
+

{{ form.instance.first_name }} {{ form.instance.last_name }}

+

+ The Bridge City Bicycle Co-operative (herein referred to as The BCBC and The Community) is a nonprofit, + community bicycle repair education and resource co-operative. We offer our members nonjudgmental repair + space, tools and instruction during business hours (hours on website) by donation, and educational + workshops. We also offer reconditioned/recycled low cost bikes and parts for sale. + The BCBC is operated by volunteers; a medley of professionals, students, bike enthusiasts, activists, + and other community members who share a love for cycling in Saskatoon. Membership is open to all + individuals and costs $20 per year. A receipt will be issued to you once your membership fee has been paid. +

+
+ {% csrf_token %} + + {% if form.non_field_errors %} +
+ {{ form.errors }} +
+ {% endif %} +
+ {{ form.email }} + + {% if form.email.errors %} + {{ form.email.errors }} + {% else %} + Invalid email. + {% endif %} +
+
+ +
+
+ {{ form.first_name }} + + {% if form.first_name.errors %} + {{ form.first_name.errors }} + {% else %} + Name too long. + {% endif %} +
+
+ {{ form.last_name }} + + {% if form.last_name.errors %} + {{ form.last_name.errors }} + {% else %} + Name too long. + {% endif %} +
+
+ {{ form.preferred_name }} + + {% if form.preferred_name.errors %} + {{ form.preferred_name.errors }} + {% else %} + Name too long. + {% endif %} +
+
+ {{ form.date_of_birth }} + + {% if form.date_of_birth.errors %} + {{ form.date_of_birth.errors }} + {% else %} + Incorrect date. + {% endif %} +
+
+ {{ form.guardian_name }} + + {% if form.guardian_name.errors %} + {{ form.guardian_name.errors }} + {% else %} + Name too long. + {% endif %} +
+
+ {{ form.phone }} + + {% if form.phone.errors %} + {{ form.phone.errors }} + {% else %} + Digits only. + {% endif %} +
+
+ {{ form.post_code }} + + {% if form.post_code.errors %} + {{ form.post_code.errors }} + {% else %} + Format: A0A 0A0 + {% endif %} +
+
+ {{ form.street }} + + {% if form.street.errors %} + {{ form.street.errors }} + {% endif %} +
+
+ {{ form.city }} + + {% if form.city.errors %} + {{ form.city.errors }} + {% endif %} +
+
+ {{ form.province }} + + {% if form.province.errors %} + {{ form.province.errors }} + {% endif %} +
+
+ {{ form.country }} + + {% if form.country.errors %} + {{ form.country.errors }} + {% endif %} +
+
+ +
+
+
+ {% if not form.instance.membership %} +
+

No membership found.

+
+ {% endif %} +{% endblock %} diff --git a/bikeshop_project/registration/urls.py b/bikeshop_project/registration/urls.py index 84781dd..07024cb 100644 --- a/bikeshop_project/registration/urls.py +++ b/bikeshop_project/registration/urls.py @@ -3,4 +3,5 @@ from django.conf.urls import url from .views import MemberFormView urlpatterns = [ url(r'^new/$', MemberFormView.as_view(), name='signup'), + url(r'^edit/(?P[0-9]+)/$', MemberFormView.as_view(), name='member_edit') ] diff --git a/bikeshop_project/registration/views.py b/bikeshop_project/registration/views.py index cfc8342..3fad6e2 100644 --- a/bikeshop_project/registration/views.py +++ b/bikeshop_project/registration/views.py @@ -1,14 +1,26 @@ +from django.shortcuts import get_object_or_404 from django.template.response import TemplateResponse from django.utils import timezone from django.views.generic import View from .forms import MemberForm +from .models import Member +import logging +logger = logging.getLogger(__file__) class MemberFormView(View): - def get(self, request): - form = MemberForm() - context = {'form': form} + def get(self, request, member_id=None): + try: + logger.debug(member_id) + member = Member.objects.get(id=member_id) + form = MemberForm(instance=member) + except Member.DoesNotExist: + form = MemberForm() + + context = dict(form=form) + if form.instance: + return TemplateResponse(request, 'edit_member_form.html', context=context) return TemplateResponse(request, 'member_form.html', context=context) def post(self, request):