def member_profile(request): if request.method == 'POST': pform = MemberProfileForm(request.POST) if pform.is_valid(): pform.save() return "saved" else: pform = MemberProfileForm() return render_to_response("member/profile.html", {'pform': pform}, context_instance=RequestContext(request))
def member_settings(request, redirect_from="profile"): user = request.user memberprofile = MemberProfile.objects.get(member=user) ''' If profile is not created yet go to startup page''' try: if user.memberprofile: pass except: return HttpResponseRedirect("/member/startup/") if request.method == 'POST': pform = MemberProfileForm(request.POST, instance=memberprofile) uform = UserForm(request.POST, instance=user) if uform.is_valid() and pform.is_valid(): user = uform.save(commit=False) user.save() profile = pform.save() messages.success(request, "Member profile saved successfully") else: uform = UserForm(instance=user) pform = MemberProfileForm(instance=memberprofile) tw_numbers = MemberTwilioNumber.objects.filter(member=user) twform = FilterTwilioNumberSearchForm() twnumberedit_form = MemberTwilioNumberEditForm() member_contact_numers = MemberContactNumber.objects.all() return render_to_response("member/settings.html", {'uform': uform, 'pform': pform, "tw_numbers": tw_numbers, 'twform': twform, 'twnumberedit_form': twnumberedit_form, 'path': redirect_from, 'contact_numbers': member_contact_numers}, context_instance=RequestContext(request))