##// END OF EJS Templates
Updated admin to show last 5 actions + updated db model
Marcin Kuzminski -
r62:4df4c0ea default
parent child Browse files
Show More
@@ -12,7 +12,8 b' from pylons_app.lib import auth'
12 from pylons_app.model.forms import LoginForm
12 from pylons_app.model.forms import LoginForm
13 import formencode
13 import formencode
14 import formencode.htmlfill as htmlfill
14 import formencode.htmlfill as htmlfill
15 from pylons_app.lib.auth import authenticate
15 from pylons_app.model import meta
16 from pylons_app.model.db import Users, UserLogs
16 log = logging.getLogger(__name__)
17 log = logging.getLogger(__name__)
17
18
18 class AdminController(BaseController):
19 class AdminController(BaseController):
@@ -50,6 +51,9 b' class AdminController(BaseController):'
50 defaults=c.form_result,
51 defaults=c.form_result,
51 encoding="UTF-8"
52 encoding="UTF-8"
52 )
53 )
54 if c.admin_user:
55 sa = meta.Session
56 c.users_log = sa.query(UserLogs).limit(10).all()
53 return render('/admin.html')
57 return render('/admin.html')
54
58
55 def hgrc(self, dirname):
59 def hgrc(self, dirname):
@@ -21,6 +21,7 b' class UserLogs(Base):'
21 __table_args__ = {'useexisting':True}
21 __table_args__ = {'useexisting':True}
22 id = Column("id", SLInteger(), nullable=False, unique=True, default=None, primary_key=1)
22 id = Column("id", SLInteger(), nullable=False, unique=True, default=None, primary_key=1)
23 user_id = Column("user_id", SLInteger(), ForeignKey(u'users.user_id'), nullable=True, unique=None, default=None)
23 user_id = Column("user_id", SLInteger(), ForeignKey(u'users.user_id'), nullable=True, unique=None, default=None)
24 last_action = Column("last_action", SLText(length=None, convert_unicode=False, assert_unicode=None), nullable=True, unique=None, default=None)
24 repository = Column("repository", SLText(length=None, convert_unicode=False, assert_unicode=None), nullable=True, unique=None, default=None)
25 last_action_date = Column("last_action_date", SLDateTime(timezone=False), nullable=True, unique=None, default=None)
25 action = Column("action", SLText(length=None, convert_unicode=False, assert_unicode=None), nullable=True, unique=None, default=None)
26 action_date = Column("action_date", SLDateTime(timezone=False), nullable=True, unique=None, default=None)
26 user = relation('Users')
27 user = relation('Users')
@@ -33,8 +33,29 b''
33 </ul>
33 </ul>
34 <br/>
34 <br/>
35 <div>
35 <div>
36
36 <h2>Welcome ${c.admin_username}</h2>
37 <h2>Hi !</h2>
37 <div>Last 5 user actions</div>
38 %if c.users_log:
39 <table>
40 <tr>
41 <td>${_('Username')}</td>
42 <td>${_('Repository')}</td>
43 <td>${_('Action')}</td>
44 <td>${_('Date')}</td>
45 </tr>
46 %for cnt,l in enumerate(c.users_log):
47 <tr class="parity${cnt%2}">
48 <td>${l.user.username}</td>
49 <td>${l.repository}</td>
50 <td>${l.action}</td>
51 <td>${l.action_date}</td>
52 </tr>
53 %endfor
54 </table>
55 %else:
56 ${_('No actions yet')}
57 %endif
58
38 </div>
59 </div>
39 %else:
60 %else:
40 <div>
61 <div>
General Comments 0
You need to be logged in to leave comments. Login now