Mercurial > kallithea
diff pylons_app/controllers/users.py @ 318:fdf9f6ee5217
Implemented permissions into hg app, secured admin controllers, templates and repository specific controllers
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Tue, 29 Jun 2010 20:45:03 +0200 |
parents | 61be6dcd49a0 |
children |
line wrap: on
line diff
--- a/pylons_app/controllers/users.py Tue Jun 29 20:43:01 2010 +0200 +++ b/pylons_app/controllers/users.py Tue Jun 29 20:45:03 2010 +0200 @@ -31,7 +31,7 @@ from pylons_app.lib.base import BaseController, render from pylons_app.model.db import User, UserLog from pylons_app.model.forms import UserForm -from pylons_app.model.user_model import UserModel +from pylons_app.model.user_model import UserModel, DefaultUserException import formencode import logging @@ -125,10 +125,11 @@ try: user_model.delete(id) h.flash(_('sucessfully deleted user'), category='success') + except DefaultUserException as e: + h.flash(str(e), category='warning') except Exception: h.flash(_('An error occured during deletion of user'), - category='error') - + category='error') return redirect(url('users')) def show(self, id, format='html'): @@ -140,6 +141,11 @@ """GET /users/id/edit: Form to edit an existing item""" # url('edit_user', id=ID) c.user = self.sa.query(User).get(id) + if c.user.username == 'default': + h.flash(_("You can't edit this user since it's" + " crucial for entire application"), category='warning') + return redirect(url('users')) + defaults = c.user.__dict__ return htmlfill.render( render('admin/users/user_edit.html'),