Mercurial > kallithea
annotate pylons_app/controllers/admin.py @ 234:a0116e944da1
changed naming convention for db modules.
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Thu, 27 May 2010 21:31:30 +0200 |
parents | c8162373f214 |
children | fcab58c43ea1 |
rev | line source |
---|---|
43 | 1 import logging |
133
919b5bcd8630
Changed creation of repository to vcs implementation,
Marcin Kuzminski <marcin@python-works.com>
parents:
127
diff
changeset
|
2 import os |
43 | 3 |
4 from pylons import request, response, session, tmpl_context as c, url, app_globals as g | |
5 from pylons.controllers.util import abort, redirect | |
6 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
|
7 from pylons_app.model import meta |
234
a0116e944da1
changed naming convention for db modules.
Marcin Kuzminski <marcin@python-works.com>
parents:
216
diff
changeset
|
8 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
|
9 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
|
10 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
|
11 |
43 | 12 log = logging.getLogger(__name__) |
13 | |
14 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
|
15 |
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 @LoginRequired() |
43 | 17 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
|
18 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
|
19 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
|
20 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
|
21 super(AdminController, self).__before__() |
43 | 22 |
23 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
|
24 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
|
25 |
234
a0116e944da1
changed naming convention for db modules.
Marcin Kuzminski <marcin@python-works.com>
parents:
216
diff
changeset
|
26 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
|
27 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
|
28 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
|
29 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
|
30 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
|
31 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
|
32 return render('admin/admin.html') |
133
919b5bcd8630
Changed creation of repository to vcs implementation,
Marcin Kuzminski <marcin@python-works.com>
parents:
127
diff
changeset
|
33 |