Browse Source

Allow for new or editing.

feature/python-error-tracking
Drew Larson 9 years ago
parent
commit
0c905da8af
  1. 1
      bikeshop_project/registration/templates/edit_member_form.html
  2. 4
      bikeshop_project/registration/views.py

1
bikeshop_project/registration/templates/edit_member_form.html

@ -192,6 +192,7 @@
{% if not form.instance.membership %}
<div class="mdl-cell mdl-cell--8-col">
<h3>No membership found.</h3>
<a class="mdl-button mdl-js-button mdl-button--flat mdl-js-ripple-effect mdl-button--colored" href="{% url 'new_membership' member_id=member.id %}">Add membership</a>
</div>
{% endif %}
{% endblock %}

4
bikeshop_project/registration/views.py

@ -22,6 +22,7 @@ class MemberFormView(View):
context = dict(form=form)
if member:
context['member'] = member
return TemplateResponse(request, 'edit_member_form.html', context=context)
return TemplateResponse(request, 'member_form.html', context=context)
@ -31,6 +32,7 @@ class MemberFormView(View):
member = Member.objects.get(id=member_id)
form = MemberForm(request.POST, instance=member)
except Member.DoesNotExist:
member = None
form = MemberForm(request.POST)
logger.debug(form)
if form.is_valid():
@ -41,4 +43,6 @@ class MemberFormView(View):
logger.debug(form)
context = {'form': form}
if member:
context['member'] = member
return TemplateResponse(request, 'member_form.html', context=context)

Loading…
Cancel
Save