|
@ -27,7 +27,6 @@ logger = logging.getLogger('bikeshop') |
|
|
class MemberFormView(View): |
|
|
class MemberFormView(View): |
|
|
def get(self, request, member_id=None): |
|
|
def get(self, request, member_id=None): |
|
|
try: |
|
|
try: |
|
|
logger.debug(member_id) |
|
|
|
|
|
member = Member.objects.get(id=member_id) |
|
|
member = Member.objects.get(id=member_id) |
|
|
form = MemberForm(instance=member) |
|
|
form = MemberForm(instance=member) |
|
|
except Member.DoesNotExist: |
|
|
except Member.DoesNotExist: |
|
@ -38,24 +37,21 @@ class MemberFormView(View): |
|
|
if member: |
|
|
if member: |
|
|
context['member'] = member |
|
|
context['member'] = member |
|
|
return TemplateResponse(request, 'edit_member_form.html', context=context) |
|
|
return TemplateResponse(request, 'edit_member_form.html', context=context) |
|
|
|
|
|
|
|
|
return TemplateResponse(request, 'member_form.html', context=context) |
|
|
return TemplateResponse(request, 'member_form.html', context=context) |
|
|
|
|
|
|
|
|
def post(self, request, member_id=None): |
|
|
def post(self, request, member_id=None): |
|
|
try: |
|
|
try: |
|
|
logger.debug(member_id) |
|
|
|
|
|
member = Member.objects.get(id=member_id) |
|
|
member = Member.objects.get(id=member_id) |
|
|
form = MemberForm(request.POST, instance=member) |
|
|
form = MemberForm(request.POST, instance=member) |
|
|
except Member.DoesNotExist: |
|
|
except Member.DoesNotExist: |
|
|
member = None |
|
|
member = None |
|
|
form = MemberForm(request.POST) |
|
|
form = MemberForm(request.POST) |
|
|
logger.debug(form) |
|
|
|
|
|
if form.is_valid(): |
|
|
if form.is_valid(): |
|
|
member_instance = form.save() |
|
|
member_instance = form.save() |
|
|
logger.debug(member_instance) |
|
|
|
|
|
return HttpResponseRedirect(reverse('member_edit', kwargs=dict(member_id=member_instance.id))) |
|
|
return HttpResponseRedirect(reverse('member_edit', kwargs=dict(member_id=member_instance.id))) |
|
|
|
|
|
|
|
|
logger.debug(form) |
|
|
|
|
|
|
|
|
|
|
|
context = {'form': form} |
|
|
context = {'form': form} |
|
|
if member: |
|
|
if member: |
|
|
context['member'] = member |
|
|
context['member'] = member |
|
|