Mercurial > kallithea
annotate pylons_app/controllers/admin.py @ 235:fcab58c43ea1
Fixed access to repos and users.
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Sun, 30 May 2010 00:44:45 +0200 |
parents | a0116e944da1 |
children | 3782a6d698af |
rev | line source |
---|---|
43 | 1 import logging |
2 from pylons import request, response, session, tmpl_context as c, url, app_globals as g | |
3 from pylons.controllers.util import abort, redirect | |
4 from pylons_app.lib.base import BaseController, render | |
62
4df4c0eac619
Updated admin to show last 5 actions + updated db model
Marcin Kuzminski <marcin@python-blog.com>
parents:
52
diff
changeset
|
5 from pylons_app.model import meta |
234
a0116e944da1
changed naming convention for db modules.
Marcin Kuzminski <marcin@python-works.com>
parents:
216
diff
changeset
|
6 from pylons_app.model.db import UserLog |
78
6f524697f79d
Implemented paging to admin user acion log
Marcin Kuzminski <marcin@python-blog.com>
parents:
75
diff
changeset
|
7 from webhelpers.paginate import Page |
191
b68b2246e5a6
Authenticated controller with LoginRequired decorator, and cleaned __before__ (used in baseController now). fixed User for clone url with logged in session user.
Marcin Kuzminski <marcin@python-works.com>
parents:
171
diff
changeset
|
8 from pylons_app.lib.auth import LoginRequired |
140
b5e59e2b5cfe
moved cache invalidating to utils, as seperate function. Implemented invalidating in
Marcin Kuzminski <marcin@python-works.com>
parents:
133
diff
changeset
|
9 |
43 | 10 log = logging.getLogger(__name__) |
11 | |
12 class AdminController(BaseController): | |
191
b68b2246e5a6
Authenticated controller with LoginRequired decorator, and cleaned __before__ (used in baseController now). fixed User for clone url with logged in session user.
Marcin Kuzminski <marcin@python-works.com>
parents:
171
diff
changeset
|
13 |
b68b2246e5a6
Authenticated controller with LoginRequired decorator, and cleaned __before__ (used in baseController now). fixed User for clone url with logged in session user.
Marcin Kuzminski <marcin@python-works.com>
parents:
171
diff
changeset
|
14 @LoginRequired() |
43 | 15 def __before__(self): |
191
b68b2246e5a6
Authenticated controller with LoginRequired decorator, and cleaned __before__ (used in baseController now). fixed User for clone url with logged in session user.
Marcin Kuzminski <marcin@python-works.com>
parents:
171
diff
changeset
|
16 user = session['hg_app_user'] |
b68b2246e5a6
Authenticated controller with LoginRequired decorator, and cleaned __before__ (used in baseController now). fixed User for clone url with logged in session user.
Marcin Kuzminski <marcin@python-works.com>
parents:
171
diff
changeset
|
17 c.admin_user = user.is_admin |
b68b2246e5a6
Authenticated controller with LoginRequired decorator, and cleaned __before__ (used in baseController now). fixed User for clone url with logged in session user.
Marcin Kuzminski <marcin@python-works.com>
parents:
171
diff
changeset
|
18 c.admin_username = user.username |
b68b2246e5a6
Authenticated controller with LoginRequired decorator, and cleaned __before__ (used in baseController now). fixed User for clone url with logged in session user.
Marcin Kuzminski <marcin@python-works.com>
parents:
171
diff
changeset
|
19 super(AdminController, self).__before__() |
43 | 20 |
21 def index(self): | |
191
b68b2246e5a6
Authenticated controller with LoginRequired decorator, and cleaned __before__ (used in baseController now). fixed User for clone url with logged in session user.
Marcin Kuzminski <marcin@python-works.com>
parents:
171
diff
changeset
|
22 sa = meta.Session |
b68b2246e5a6
Authenticated controller with LoginRequired decorator, and cleaned __before__ (used in baseController now). fixed User for clone url with logged in session user.
Marcin Kuzminski <marcin@python-works.com>
parents:
171
diff
changeset
|
23 |
234
a0116e944da1
changed naming convention for db modules.
Marcin Kuzminski <marcin@python-works.com>
parents:
216
diff
changeset
|
24 users_log = sa.query(UserLog).order_by(UserLog.action_date.desc()) |
191
b68b2246e5a6
Authenticated controller with LoginRequired decorator, and cleaned __before__ (used in baseController now). fixed User for clone url with logged in session user.
Marcin Kuzminski <marcin@python-works.com>
parents:
171
diff
changeset
|
25 p = int(request.params.get('page', 1)) |
b68b2246e5a6
Authenticated controller with LoginRequired decorator, and cleaned __before__ (used in baseController now). fixed User for clone url with logged in session user.
Marcin Kuzminski <marcin@python-works.com>
parents:
171
diff
changeset
|
26 c.users_log = Page(users_log, page=p, items_per_page=10) |
b68b2246e5a6
Authenticated controller with LoginRequired decorator, and cleaned __before__ (used in baseController now). fixed User for clone url with logged in session user.
Marcin Kuzminski <marcin@python-works.com>
parents:
171
diff
changeset
|
27 c.log_data = render('admin/admin_log.html') |
b68b2246e5a6
Authenticated controller with LoginRequired decorator, and cleaned __before__ (used in baseController now). fixed User for clone url with logged in session user.
Marcin Kuzminski <marcin@python-works.com>
parents:
171
diff
changeset
|
28 if request.params.get('partial'): |
b68b2246e5a6
Authenticated controller with LoginRequired decorator, and cleaned __before__ (used in baseController now). fixed User for clone url with logged in session user.
Marcin Kuzminski <marcin@python-works.com>
parents:
171
diff
changeset
|
29 return c.log_data |
216
c8162373f214
Cleaned the way based was used to generate submenu for admin, now it's much more clear to use submenu. Cleaned admin and added comment to middleware
Marcin Kuzminski <marcin@python-works.com>
parents:
191
diff
changeset
|
30 return render('admin/admin.html') |
133
919b5bcd8630
Changed creation of repository to vcs implementation,
Marcin Kuzminski <marcin@python-works.com>
parents:
127
diff
changeset
|
31 |