admin.py
31 lines
| 1.1 KiB
| text/x-python
|
PythonLexer
r43 | import logging | |||
from pylons import request, response, session, tmpl_context as c, url, app_globals as g | ||||
from pylons.controllers.util import abort, redirect | ||||
from pylons_app.lib.base import BaseController, render | ||||
Marcin Kuzminski
|
r62 | from pylons_app.model import meta | ||
r234 | from pylons_app.model.db import UserLog | |||
Marcin Kuzminski
|
r78 | from webhelpers.paginate import Page | ||
r191 | from pylons_app.lib.auth import LoginRequired | |||
r140 | ||||
r43 | log = logging.getLogger(__name__) | |||
class AdminController(BaseController): | ||||
r191 | ||||
@LoginRequired() | ||||
r43 | def __before__(self): | |||
r191 | user = session['hg_app_user'] | |||
c.admin_user = user.is_admin | ||||
c.admin_username = user.username | ||||
super(AdminController, self).__before__() | ||||
r43 | ||||
def index(self): | ||||
r191 | sa = meta.Session | |||
r234 | users_log = sa.query(UserLog).order_by(UserLog.action_date.desc()) | |||
r191 | p = int(request.params.get('page', 1)) | |||
c.users_log = Page(users_log, page=p, items_per_page=10) | ||||
c.log_data = render('admin/admin_log.html') | ||||
if request.params.get('partial'): | ||||
return c.log_data | ||||
r216 | return render('admin/admin.html') | |||
r133 | ||||