diff --git a/pylons_app/controllers/admin.py b/pylons_app/controllers/admin.py --- a/pylons_app/controllers/admin.py +++ b/pylons_app/controllers/admin.py @@ -12,7 +12,8 @@ from pylons_app.lib import auth from pylons_app.model.forms import LoginForm import formencode import formencode.htmlfill as htmlfill -from pylons_app.lib.auth import authenticate +from pylons_app.model import meta +from pylons_app.model.db import Users, UserLogs log = logging.getLogger(__name__) class AdminController(BaseController): @@ -50,6 +51,9 @@ class AdminController(BaseController): defaults=c.form_result, encoding="UTF-8" ) + if c.admin_user: + sa = meta.Session + c.users_log = sa.query(UserLogs).limit(10).all() return render('/admin.html') def hgrc(self, dirname): diff --git a/pylons_app/model/db.py b/pylons_app/model/db.py --- a/pylons_app/model/db.py +++ b/pylons_app/model/db.py @@ -21,6 +21,7 @@ class UserLogs(Base): __table_args__ = {'useexisting':True} id = Column("id", SLInteger(), nullable=False, unique=True, default=None, primary_key=1) user_id = Column("user_id", SLInteger(), ForeignKey(u'users.user_id'), nullable=True, unique=None, default=None) - last_action = Column("last_action", SLText(length=None, convert_unicode=False, assert_unicode=None), nullable=True, unique=None, default=None) - last_action_date = Column("last_action_date", SLDateTime(timezone=False), nullable=True, unique=None, default=None) + repository = Column("repository", SLText(length=None, convert_unicode=False, assert_unicode=None), nullable=True, unique=None, default=None) + action = Column("action", SLText(length=None, convert_unicode=False, assert_unicode=None), nullable=True, unique=None, default=None) + action_date = Column("action_date", SLDateTime(timezone=False), nullable=True, unique=None, default=None) user = relation('Users') diff --git a/pylons_app/templates/admin.html b/pylons_app/templates/admin.html --- a/pylons_app/templates/admin.html +++ b/pylons_app/templates/admin.html @@ -33,8 +33,29 @@
- -

Hi !

+

Welcome ${c.admin_username}

+
Last 5 user actions
+ %if c.users_log: + + + + + + + + %for cnt,l in enumerate(c.users_log): + + + + + + + %endfor +
${_('Username')}${_('Repository')}${_('Action')}${_('Date')}
${l.user.username}${l.repository}${l.action}${l.action_date}
+ %else: + ${_('No actions yet')} + %endif +
%else: