本文整理汇总了Python中users.utils.handle_register函数的典型用法代码示例。如果您正苦于以下问题:Python handle_register函数的具体用法?Python handle_register怎么用?Python handle_register使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了handle_register函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: register
def register(request):
"""Register a new user."""
form = handle_register(request)
if form.is_valid():
return HttpResponseRedirect(reverse('mobile.home'))
return jingo.render(request, 'users/mobile/register.html',
{'form': form})
开发者ID:ryansnyder,项目名称:spark,代码行数:7,代码来源:views.py
示例2: register
def register(request):
"""Register a new user."""
form = handle_register(request)
if form.is_valid():
return jingo.render(request, 'users/register_done.html')
return jingo.render(request, 'users/register.html',
{'form': form})
开发者ID:Disabledpeople,项目名称:kitsune,代码行数:7,代码来源:views.py
示例3: register
def register(request):
"""Register a new user."""
try:
form = handle_register(request)
if form.is_valid():
return render(request, 'users/register_done.html')
return render(request, 'users/register.html',
{'form': form})
except MindTouchAPIError, e:
return render(request, '500.html',
{'error_message': "We couldn't "
"register a new account at this time. "
"Please try again later."})
开发者ID:Web5design,项目名称:kuma,代码行数:13,代码来源:views.py
示例4: register
def register(request, mobile=False):
"""Register a new user."""
form = handle_register(request)
valid = form.is_valid()
if valid:
# User is logged-in automatically after registration
new_user = auth.authenticate(username=form.cleaned_data['username'],
password=form.cleaned_data['password'])
auth.login(request, new_user)
# Register for newletters
data = form.cleaned_data
optins = []
if data['newsletter']:
optins.append(settings.MOZILLA_CAMPAIGN)
if data['spark_newsletter']:
optins.append(settings.SPARK_CAMPAIGN)
if len(optins) > 0:
# This will be async if Celery is enabled
status= responsys.subscribe(optins,
data['email'],
'html',
responsys.make_source_url(request),
request.locale)
# Set a flag for mobile menu notifications
profile = User.objects.get(username=form.cleaned_data['username']).profile
profile.new_challenges = True
# Set desktop or mobile login flag
if mobile:
profile.login_mobile = True
else:
profile.login_desktop = True
profile.save()
if mobile:
if valid:
return HttpResponseRedirect(reverse('mobile.boost'))
else:
return jingo.render(request, 'users/mobile/register.html',
{'form': form})
else: # ajax desktop registration
if valid:
return {'status': 'success',
'next': reverse('desktop.home')}
else:
return {'status': 'error',
'errors': dict(form.errors.iteritems())}
开发者ID:mozilla,项目名称:spark,代码行数:49,代码来源:views.py
示例5: register
def register(request, template, contributor=False):
"""Register a new user.
:param contributor: If True, this is for registering a new contributor.
"""
if request.method == 'GET' and not request.MOBILE:
url = reverse('users.auth') + '?' + request.GET.urlencode()
return HttpResponsePermanentRedirect(url)
form = handle_register(request)
if form.is_valid():
return jingo.render(request, template + 'register_done.html')
return user_auth(request, register_form=form)
开发者ID:victorneo,项目名称:kitsune,代码行数:15,代码来源:views.py
示例6: aaq
#.........这里部分代码省略.........
initial={'title': search})
# User is on the question details step
statsd.incr('questions.aaq.details-form')
else:
form = None
if search:
# User is on the article and questions suggestions step
statsd.incr('questions.aaq.suggestions')
return jingo.render(request, template,
{'form': form,
'results': results,
'tried_search': tried_search,
'products': products,
'current_product': product,
'current_category': category,
'current_html': html,
'current_articles': articles,
'current_step': step,
'deadend': deadend,
'host': Site.objects.get_current().domain})
# Handle the form post.
if not request.user.is_authenticated():
if request.POST.get('login'):
login_form = handle_login(request, only_active=False)
statsd.incr('questions.user.login')
register_form = RegisterForm()
elif request.POST.get('register'):
login_form = AuthenticationForm()
email_template = 'questions/email/confirm_question.ltxt'
email_subject = _('Please confirm your Firefox Help question')
email_data = request.GET.get('search')
register_form = handle_register(request, email_template,
email_subject, email_data)
if register_form.is_valid(): # Now try to log in.
user = auth.authenticate(username=request.POST.get('username'),
password=request.POST.get('password'))
auth.login(request, user)
statsd.incr('questions.user.register')
else:
# L10n: This shouldn't happen unless people tamper with POST data.
message = _lazy('Request type not recognized.')
return jingo.render(request, 'handlers/400.html',
{'message': message}, status=400)
if request.user.is_authenticated():
# Redirect to GET the current URL replacing the step parameter.
# This is also required for the csrf middleware to set the auth'd
# tokens appropriately.
url = urlparams(request.get_full_path(), step='aaq-question')
return HttpResponseRedirect(url)
else:
return jingo.render(request, login_t,
{'product': product, 'category': category,
'title': request.POST.get('title'),
'register_form': register_form,
'login_form': login_form})
form = NewQuestionForm(product=product, category=category,
data=request.POST)
if form.is_valid():
question = Question(creator=request.user,
title=form.cleaned_data['title'],
content=form.cleaned_data['content'])
question.save()
开发者ID:victorneo,项目名称:kitsune,代码行数:67,代码来源:views.py
示例7: new_question
def new_question(request, template=None):
"""Ask a new question."""
product_key = request.GET.get('product')
product = products.get(product_key)
if product_key and not product:
raise Http404
category_key = request.GET.get('category')
if product and category_key:
category = product['categories'].get(category_key)
if not category:
raise Http404
deadend = category.get('deadend', False)
html = category.get('html')
articles = category.get('articles')
else:
category = None
deadend = product.get('deadend', False) if product else False
html = product.get('html') if product else None
articles = None
login_t = ('questions/mobile/new_question_login.html' if request.MOBILE
else 'questions/new_question_login.html')
if request.method == 'GET':
search = request.GET.get('search', '')
if search:
try:
results = _search_suggestions(
search, locale_or_default(request.locale))
except SearchError:
# Just quietly advance the user to the next step.
results = []
tried_search = True
else:
results = []
tried_search = False
if request.GET.get('showform'):
# Before we show the form, make sure the user is auth'd:
if not request.user.is_authenticated():
login_form = AuthenticationForm()
register_form = RegisterForm()
return jingo.render(request, login_t,
{'product': product, 'category': category,
'title': search,
'register_form': register_form,
'login_form': login_form})
form = NewQuestionForm(product=product,
category=category,
initial={'title': search})
else:
form = None
return jingo.render(request, template,
{'form': form,
'results': results,
'tried_search': tried_search,
'products': products,
'current_product': product,
'current_category': category,
'current_html': html,
'current_articles': articles,
'deadend': deadend,
'host': Site.objects.get_current().domain})
# Handle the form post.
if not request.user.is_authenticated():
if request.POST.get('login'):
login_form = handle_login(request, only_active=False)
statsd.incr('questions.user.login')
register_form = RegisterForm()
elif request.POST.get('register'):
login_form = AuthenticationForm()
email_template = 'questions/email/confirm_question.ltxt'
email_subject = _('Please confirm your Firefox Help question')
email_data = request.GET.get('search')
register_form = handle_register(request, email_template,
email_subject, email_data)
if register_form.is_valid(): # Now try to log in.
user = auth.authenticate(username=request.POST.get('username'),
password=request.POST.get('password'))
auth.login(request, user)
statsd.incr('questions.user.register')
else:
# L10n: This shouldn't happen unless people tamper with POST data.
message = _lazy('Request type not recognized.')
return jingo.render(request, 'handlers/400.html',
{'message': message}, status=400)
if request.user.is_authenticated():
# Redirect to GET the current URL.
# This is required for the csrf middleware to set the auth'd tokens
# appropriately.
return HttpResponseRedirect(request.get_full_path())
else:
return jingo.render(request, login_t,
{'product': product, 'category': category,
'title': request.POST.get('title'),
'register_form': register_form,
'login_form': login_form})
#.........这里部分代码省略.........
开发者ID:bowmasters,项目名称:kitsune,代码行数:101,代码来源:views.py
示例8: new_question
def new_question(request):
"""Ask a new question."""
product_key = request.GET.get('product')
product = products.get(product_key)
if product_key and not product:
raise Http404
category_key = request.GET.get('category')
if product and category_key:
category = product['categories'].get(category_key)
if not category:
raise Http404
deadend = category.get('deadend', False)
html = category.get('html')
articles = category.get('articles')
else:
category = None
deadend = product.get('deadend', False) if product else False
html = product.get('html') if product else None
articles = None
if request.method == 'GET':
search = request.GET.get('search', '')
if search:
try:
search_results = _search_suggestions(
search, locale_or_default(request.locale))
except SearchError:
# Just quietly advance the user to the next step.
search_results = []
tried_search = True
else:
search_results = []
tried_search = False
if request.GET.get('showform'):
# Before we show the form, make sure the user is auth'd:
if not request.user.is_authenticated():
login_form = AuthenticationForm()
register_form = RegisterForm()
return jingo.render(request,
'questions/new_question_login.html',
{'product': product, 'category': category,
'title': search,
'register_form': register_form,
'login_form': login_form})
form = NewQuestionForm(product=product,
category=category,
initial={'title': search})
else:
form = None
return jingo.render(request, 'questions/new_question.html',
{'form': form, 'search_results': search_results,
'tried_search': tried_search,
'products': products,
'current_product': product,
'current_category': category,
'current_html': html,
'current_articles': articles,
'deadend': deadend,
'host': Site.objects.get_current().domain})
# Handle the form post.
just_logged_in = False # Used below for whether to pre-load Question form.
if not request.user.is_authenticated():
type = request.POST.get('type')
if type not in ('login', 'register'):
# L10n: This shouldn't happen unless people tamper with POST data
message = _lazy('Request type not recognized.')
return jingo.render(request, 'handlers/400.html',
{'message': message}, status=400)
if type == 'login':
login_form = handle_login(request, only_active=False)
register_form = RegisterForm()
else: # must be 'register'
login_form = AuthenticationForm()
register_form = handle_register(request)
if register_form.is_valid(): # now try to log in
user = auth.authenticate(username=request.POST.get('username'),
password=request.POST.get('password'))
auth.login(request, user)
if not request.user.is_authenticated():
return jingo.render(request,
'questions/new_question_login.html',
{'product': product, 'category': category,
'title': request.POST.get('title'),
'register_form': register_form,
'login_form': login_form})
else:
just_logged_in = True
if just_logged_in:
form = NewQuestionForm(product=product,
category=category,
initial={'title': request.GET.get('search')})
else:
form = NewQuestionForm(product=product, category=category,
data=request.POST)
#.........这里部分代码省略.........
开发者ID:GPHemsley,项目名称:kuma,代码行数:101,代码来源:views.py
示例9: new_question
def new_question(request, template=None):
"""Ask a new question."""
product_key = request.GET.get("product")
product = products.get(product_key)
if product_key and not product:
raise Http404
category_key = request.GET.get("category")
if product and category_key:
category = product["categories"].get(category_key)
if not category:
raise Http404
deadend = category.get("deadend", False)
html = category.get("html")
articles = category.get("articles")
else:
category = None
deadend = product.get("deadend", False) if product else False
html = product.get("html") if product else None
articles = None
if product:
# User is on the select category step
statsd.incr("questions.aaq.select-category")
else:
# User is on the select product step
statsd.incr("questions.aaq.select-product")
login_t = "questions/mobile/new_question_login.html" if request.MOBILE else "questions/new_question_login.html"
if request.method == "GET":
search = request.GET.get("search", "")
if search:
try:
results = _search_suggestions(search, locale_or_default(request.locale), product.get("tags"))
except SearchError:
# Just quietly advance the user to the next step.
results = []
tried_search = True
else:
results = []
tried_search = False
if category:
# User is on the "Ask This" step
statsd.incr("questions.aaq.search-form")
if request.GET.get("showform"):
# Before we show the form, make sure the user is auth'd:
if not request.user.is_authenticated():
# User is on the login or register Step
statsd.incr("questions.aaq.login-or-register")
login_form = AuthenticationForm()
register_form = RegisterForm()
return jingo.render(
request,
login_t,
{
"product": product,
"category": category,
"title": search,
"register_form": register_form,
"login_form": login_form,
},
)
form = NewQuestionForm(product=product, category=category, initial={"title": search})
# User is on the question details step
statsd.incr("questions.aaq.details-form")
else:
form = None
if search:
# User is on the article and questions suggestions step
statsd.incr("questions.aaq.suggestions")
return jingo.render(
request,
template,
{
"form": form,
"results": results,
"tried_search": tried_search,
"products": products,
"current_product": product,
"current_category": category,
"current_html": html,
"current_articles": articles,
"deadend": deadend,
"host": Site.objects.get_current().domain,
},
)
# Handle the form post.
if not request.user.is_authenticated():
if request.POST.get("login"):
login_form = handle_login(request, only_active=False)
statsd.incr("questions.user.login")
register_form = RegisterForm()
elif request.POST.get("register"):
login_form = AuthenticationForm()
email_template = "questions/email/confirm_question.ltxt"
email_subject = _("Please confirm your Firefox Help question")
email_data = request.GET.get("search")
register_form = handle_register(request, email_template, email_subject, email_data)
#.........这里部分代码省略.........
开发者ID:fox2mike,项目名称:kitsune,代码行数:101,代码来源:views.py
示例10: aaq
#.........这里部分代码省略.........
if search:
# User is on the article and questions suggestions step
statsd.incr("questions.aaq.suggestions")
return jingo.render(
request,
template,
{
"form": form,
"results": results,
"tried_search": tried_search,
"products": products,
"current_product": product,
"current_category": category,
"current_html": html,
"current_articles": articles,
"current_step": step,
"deadend": deadend,
"host": Site.objects.get_current().domain,
},
)
# Handle the form post.
if not request.user.is_authenticated():
if request.POST.get("login"):
login_form = handle_login(request, only_active=False)
statsd.incr("questions.user.login")
register_form = RegisterForm()
elif request.POST.get("register"):
login_form = AuthenticationForm()
email_template = "questions/email/confirm_question.ltxt"
email_subject = _("Please confirm your Firefox Help question")
email_data = request.GET.get("search")
register_form = handle_register(request, email_template, email_subject, email_data)
if register_form.is_valid(): # Now try to log in.
user = auth.authenticate(username=request.POST.get("username"), password=request.POST.get("password"))
auth.login(request, user)
statsd.incr("questions.user.register")
else:
# L10n: This shouldn't happen unless people tamper with POST data.
message = _lazy("Request type not recognized.")
return jingo.render(request, "handlers/400.html", {"message": message}, status=400)
if request.user.is_authenticated():
# Redirect to GET the current URL replacing the step parameter.
# This is also required for the csrf middleware to set the auth'd
# tokens appropriately.
url = urlparams(request.get_full_path(), step="aaq-question")
return HttpResponseRedirect(url)
else:
return jingo.render(
request,
login_t,
{
"product": product,
"category": category,
"title": request.POST.get("title"),
"register_form": register_form,
"login_form": login_form,
},
)
form = NewQuestionForm(product=product, category=category, data=request.POST)
if form.is_valid():
question = Question(
creator=request.user,
开发者ID:pablocubico,项目名称:kitsune,代码行数:67,代码来源:views.py
注:本文中的users.utils.handle_register函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论