本文整理汇总了Python中mezzanine.accounts.get_profile_form函数的典型用法代码示例。如果您正苦于以下问题:Python get_profile_form函数的具体用法?Python get_profile_form怎么用?Python get_profile_form使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_profile_form函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: profile_update
def profile_update(request, template="accounts/account_profile_update.html"):
"""
Profile update form.
"""
profile_form = get_profile_form()
form = profile_form(request.POST or None, request.FILES or None,
instance=request.user)
if request.method == "POST" and form.is_valid():
user = form.save()
info(request, _("Profile updated"))
try:
customer = request.user.get_profile()
customer_address = customer.address + ', ' + customer.zip_code
loc = location_utils.getLocation(customer_address)
correct_address = location_utils.getAddress(loc[0],loc[1])
customer.location = loc
customer.address = correct_address
customer.save()
request.session['location'] = (loc[0],loc[1])
request.session['age'] = True
request.session['address'] = correct_address
request.session['map'] = True
avail_store_ids, avail_store_names, avail_liquor_types, loc, store_locs = new_location_get_ids(request, loc)
return redirect("profile", username=user.username)
except NoReverseMatch:
return redirect("profile_update")
context = {"form": form, "title": _("Update Profile")}
return render(request, template, context)
示例2: signup
def signup(request, template="accounts/account_signup.html",
extra_context=None):
"""
Signup form.
"""
profile_form = get_profile_form()
form = profile_form(request.POST or None, request.FILES or None)
if request.method == "POST" and form.is_valid():
new_user = form.save()
if not new_user.is_active:
if settings.ACCOUNTS_APPROVAL_REQUIRED:
send_approve_mail(request, new_user)
info(request, _("Thanks for signing up! You'll receive "
"an email when your account is activated."))
else:
send_verification_mail(request, new_user, "signup_verify")
info(request, _("A verification email has been sent with "
"a link for activating your account."))
return redirect(next_url(request) or "/")
else:
info(request, _("Successfully signed up"))
auth_login(request, new_user)
return login_redirect(request)
context = {"form": form, "title": _("Sign up")}
context.update(extra_context or {})
return TemplateResponse(request, template, context)
示例3: signup
def signup(request, template="accounts/account_signup.html"):
"""
Signup form.
"""
profile_form = get_profile_form()
form = profile_form(request.POST or None, request.FILES or None)
if request.method == "POST" and form.is_valid():
new_user = form.save()
if not new_user.is_active:
if settings.ACCOUNTS_APPROVAL_REQUIRED:
send_approve_mail(request, new_user)
info(request, _("Thanks for signing up! You'll receive "
"an email when your account is activated."))
else:
send_verification_mail(request, new_user, "signup_verify")
info(request, _("A verification email has been sent with "
"a link for activating your account."))
return redirect(request.GET.get("next", "/"))
else:
info(request, _("Successfully signed up"))
auth_login(request, new_user)
return login_redirect(request)
else:
log.debug('Form is not valid. Errors: %s' % form.errors)
context = {"form": form, "title": _("Create an Account"), "submit_label": "Next Step"}
return render(request, template, context)
示例4: signup_form
def signup_form(*args):
"""
Returns the signup form:
{% signup_form as form %}
{{ form }}
"""
return get_profile_form()()
示例5: profile_form
def profile_form(user):
"""
Returns the profile form for a user:
{% if request.user.is_authenticated %}
{% profile_form request.user as form %}
{{ form }}
{% endif %}
"""
if isinstance(user, User):
return get_profile_form()(instance=user)
return ""
示例6: profile_update
def profile_update(request, template="accounts/account_profile_update.html"):
"""
Profile update form.
"""
profile_form = get_profile_form()
form = profile_form(request.POST or None, instance=request.user)
if request.method == "POST" and form.is_valid():
user = form.save()
info(request, _("Profile updated"))
try:
return redirect("profile", username=user.username)
except NoReverseMatch:
return redirect("profile_update")
context = {"form": form, "title": _("Update Profile")}
return render(request, template, context)
示例7: signup
def signup(request, template="accounts/account_signup.html"):
"""
Signup form.
"""
profile_form = get_profile_form()
form = profile_form(request.POST or None, request.FILES or None)
if request.method == "POST" and form.is_valid():
new_user = form.save()
if not new_user.is_active:
if settings.ACCOUNTS_APPROVAL_REQUIRED:
send_approve_mail(request, new_user)
info(request, _("Thanks for signing up! You'll receive "
"an email when your account is activated."))
else:
send_verification_mail(request, new_user, "signup_verify")
info(request, _("A verification email has been sent with "
"a link for activating your account."))
# return redirect(request.GET.get("next", "/"))
return redirect(next_url(request) or "/")
else:
info(request, _("Successfully signed up"))
auth_login(request, new_user)
customer = request.user.get_profile()
customer_address = customer.address + ', ' + customer.zip_code
loc = location_utils.getLocation(customer_address)
correct_address = location_utils.getAddress(loc[0],loc[1])
customer.location = loc
customer.address = correct_address
customer.save()
request.session['location'] = (loc[0],loc[1])
request.session['age'] = True
request.session['address'] = correct_address
request.session['map'] = True
avail_store_ids, avail_store_names, avail_liquor_types, loc, store_locs = new_location_get_ids(request, loc)
# return login_redirect(request)
if 'cart loaded' in request.session:
return redirect('/shop/cart/')
else:
return redirect('/shop/')
context = {"form": form, "title": _("Sign up")}
return render(request, template, context)
示例8: signup
def signup(request, template="accounts/account_signup.html"):
"""
Signup form.
"""
profile_form = get_profile_form()
form = profile_form(request.POST or None)
if request.method == "POST" and form.is_valid():
new_user = form.save()
if not new_user.is_active:
send_verification_mail(request, new_user, "signup_verify")
info(request, _("A verification email has been sent with " "a link for activating your account."))
return redirect(request.GET.get("next", "/"))
else:
info(request, _("Successfully signed up"))
auth_login(request, new_user)
return login_redirect(request)
context = {"form": form, "title": _("Signup")}
return render(request, template, context)
示例9: profile_update
def profile_update(request, template="accounts/account_profile_update.html"):
"""
Profile update form.
"""
profile_form = get_profile_form()
form = profile_form(request.POST or None, request.FILES or None,
instance=request.user)
#print 'GET: %s' % request.GET
#print 'POST: %s' % request.POST
#print 'form valid? %s %s' % (form.is_valid(), form.errors)
if request.method == "POST" and form.is_valid():
user = form.save()
info(request, _("Profile updated"))
#print 'GET: %s' % request.GET
#print 'POST: %s' % request.POST
try:
if 'next' in request.GET:
return redirect(request.GET.get("next", "/"))
return redirect("profile", username=user.username)
except NoReverseMatch:
return redirect("profile_update")
context = {"form": form, "title": _("Update Profile")}
return render(request, template, context)