Esempio n. 1
0
def logout(request):
  if request.user:
    auth_logout(request)
    util.set_flash(request, "success_users_logout")
  else:
    util.set_flash(request, "error_users_alreadyloggedout", type='error')
    
  return redirect(reverse('front'))
Esempio n. 2
0
def forgot(request):
  form = ForgotPasswordForm()
  if request.method == 'POST':
    form = ForgotPasswordForm(request.POST)
    if form.is_valid():
      form.send_instructions()
      util.set_flash(request, "success_users_forgot")
      return redirect(reverse("success"))

  c = template.RequestContext(request, locals())
  return render_to_response('users_forgot.html', c)
Esempio n. 3
0
def settings(request):
  logging.info("** users.views.settings ")
  user = request.user
  form = SettingsForm(instance=request.user)
  if request.method == 'POST':
    form = SettingsForm(request.POST, instance=request.user)
    if form.is_valid():
      user_ref = form.save()
      avatar = request.FILES.get('avatarfield')
      if avatar is not None:
        user_ref.create_avatar(avatar)
      util.set_flash(request, "success_users_settings")
      return redirect(reverse('users_settings'))
      
  c = template.RequestContext(request, locals())
  return render_to_response('users_settings.html', c)
Esempio n. 4
0
def login(request):

  redirect_to = request.REQUEST.get('redirect_to', django_settings.LOGIN_REDIRECT_URL)
  redirect_to = clean.redirect_to(redirect_to)

  form = LoginForm()
  if request.method == 'POST':
    form = LoginForm(data=request.POST)
    if form.is_valid():
      user = form.get_user()
      auth_login(request, user)
      util.set_flash(request, "success_users_login")
      return redirect(redirect_to)
  
  c = template.RequestContext(request, locals())
  return render_to_response('users_login.html', c)