##// END OF EJS Templates
rewrote graph plotting, added zooming and json dump insted of stupid string formating.
rewrote graph plotting, added zooming and json dump insted of stupid string formating.

File last commit:

r474:a3d9d24a celery
r486:5c376ac2 celery
Show More
login.py
144 lines | 5.5 KiB | text/x-python | PythonLexer
licensing updates, code cleanups
r252 #!/usr/bin/env python
# encoding: utf-8
# login controller for pylons
# Copyright (C) 2009-2010 Marcin Kuzminski <marcin@python-works.com>
new style error display for login
r360 #
licensing updates, code cleanups
r252 # This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; version 2
# of the License or (at your opinion) any later version of the license.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
# MA 02110-1301, USA.
permission refactoring,...
r417
"""
Created on April 22, 2010
login controller for pylons
@author: marcink
"""
Added user registration, changed login url schema, moved it into _admin/ for safety
r363 from formencode import htmlfill
from pylons import request, response, session, tmpl_context as c, url
from pylons.controllers.util import abort, redirect
permission refactoring,...
r417 from pylons_app.lib.auth import AuthUser, HasPermissionAnyDecorator
Added user registration, changed login url schema, moved it into _admin/ for safety
r363 from pylons_app.lib.base import BaseController, render
Implemented password reset(forms/models/ tasks) and mailing tasks....
r474 import pylons_app.lib.helpers as h
from pylons.i18n.translation import _
from pylons_app.model.forms import LoginForm, RegisterForm, PasswordResetForm
Added user registration, changed login url schema, moved it into _admin/ for safety
r363 from pylons_app.model.user_model import UserModel
import formencode
import logging
fixed menu in home page, and added login html with forms that validates username and password.
r186
log = logging.getLogger(__name__)
class LoginController(BaseController):
updated logging in logout. Added before, on login page.
r202 def __before__(self):
super(LoginController, self).__before__()
fixed menu in home page, and added login html with forms that validates username and password.
r186 def index(self):
cleared prints leftoovers, and changed current user fetching in login controller
r195 #redirect if already logged in
Implemented password reset(forms/models/ tasks) and mailing tasks....
r474 c.came_from = request.GET.get('came_from', None)
Added redirection to page that request came from, after login in
r437
cleared prints leftoovers, and changed current user fetching in login controller
r195 if c.hg_app_user.is_authenticated:
fixed menu in home page, and added login html with forms that validates username and password.
r186 return redirect(url('hg_home'))
if request.POST:
#import Login Form validator class
login_form = LoginForm()
try:
c.form_result = login_form.to_python(dict(request.POST))
moved loged in user propagation out of forms,...
r442 username = c.form_result['username']
user = UserModel().get_user_by_name(username)
auth_user = AuthUser()
auth_user.username = user.username
auth_user.is_authenticated = True
auth_user.is_admin = user.admin
auth_user.user_id = user.user_id
auth_user.name = user.name
auth_user.lastname = user.lastname
session['hg_app_user'] = auth_user
session.save()
log.info('user %s is now authenticated', username)
user.update_lastlogin()
Added redirection to page that request came from, after login in
r437 if c.came_from:
return redirect(c.came_from)
else:
return redirect(url('hg_home'))
fixed menu in home page, and added login html with forms that validates username and password.
r186
except formencode.Invalid as errors:
return htmlfill.render(
render('/login.html'),
defaults=errors.value,
new style error display for login
r360 errors=errors.error_dict or {},
prefix_error=False,
fixed menu in home page, and added login html with forms that validates username and password.
r186 encoding="UTF-8")
return render('/login.html')
Implemented password reset(forms/models/ tasks) and mailing tasks....
r474 @HasPermissionAnyDecorator('hg.admin', 'hg.register.auto_activate',
moved loged in user propagation out of forms,...
r442 'hg.register.manual_activate')
Added user registration, changed login url schema, moved it into _admin/ for safety
r363 def register(self):
permission refactoring,...
r417 user_model = UserModel()
c.auto_active = False
for perm in user_model.get_default().user_perms:
if perm.permission.permission_name == 'hg.register.auto_activate':
added logic for changin defualt permissions, and option to overwrite all defualt permissions on each repository...
r418 c.auto_active = True
permission refactoring,...
r417 break
Added user registration, changed login url schema, moved it into _admin/ for safety
r363 if request.POST:
permission refactoring,...
r417
Added user registration, changed login url schema, moved it into _admin/ for safety
r363 register_form = RegisterForm()()
try:
form_result = register_form.to_python(dict(request.POST))
permission refactoring,...
r417 form_result['active'] = c.auto_active
Added user registration, changed login url schema, moved it into _admin/ for safety
r363 user_model.create_registration(form_result)
Implemented password reset(forms/models/ tasks) and mailing tasks....
r474 h.flash(_('You have successfully registered into hg-app'),
category='success')
Added user registration, changed login url schema, moved it into _admin/ for safety
r363 return redirect(url('login_home'))
except formencode.Invalid as errors:
return htmlfill.render(
render('/register.html'),
defaults=errors.value,
errors=errors.error_dict or {},
prefix_error=False,
encoding="UTF-8")
return render('/register.html')
Implemented password reset(forms/models/ tasks) and mailing tasks....
r474
def password_reset(self):
user_model = UserModel()
if request.POST:
password_reset_form = PasswordResetForm()()
try:
form_result = password_reset_form.to_python(dict(request.POST))
user_model.reset_password(form_result)
h.flash(_('Your new password was sent'),
category='success')
return redirect(url('login_home'))
except formencode.Invalid as errors:
return htmlfill.render(
render('/password_reset.html'),
defaults=errors.value,
errors=errors.error_dict or {},
prefix_error=False,
encoding="UTF-8")
return render('/password_reset.html')
fixed menu in home page, and added login html with forms that validates username and password.
r186 def logout(self):
session['hg_app_user'] = AuthUser()
session.save()
updated logging in logout. Added before, on login page.
r202 log.info('Logging out and setting user as Empty')
fixed menu in home page, and added login html with forms that validates username and password.
r186 redirect(url('hg_home'))