Permalink
Browse files

Add an admin overview view showing pending / confirmed users.

  • Loading branch information...
1 parent 074dfe0 commit 2d182645f69cb4548ae996384650b2cda99c5b1e @tseaver tseaver committed Nov 8, 2011
Showing with 74 additions and 1 deletion.
  1. +2 −0 TODO.txt
  2. +17 −0 cartouche/admin.py
  3. +9 −0 cartouche/homepage.zcml
  4. +3 −1 cartouche/models.py
  5. +43 −0 cartouche/templates/admin.pt
View
@@ -156,3 +156,5 @@ User / Group Administration
* Key member UUID -> group names
- [X] Add a command-line script to make an existing user an admin.
+
+- [X] Add an admin overview view showing pending / confirmed users.
View
@@ -1,11 +1,28 @@
import os
import sys
+from pyramid.renderers import get_renderer
from pyramid.paster import bootstrap
import transaction
from cartouche.interfaces import IRegistrations
from cartouche.persistence import ConfirmedRegistrations
+from cartouche.persistence import PendingRegistrations
+
+def admin_view(context, request):
+ pending = request.registry.queryAdapter(context, IRegistrations,
+ name='pending')
+ if pending is None:
+ pending = PendingRegistrations(context)
+ confirmed = request.registry.queryAdapter(context, IRegistrations,
+ name='confirmed')
+ if confirmed is None:
+ confirmed = ConfirmedRegistrations(context)
+ main_template = get_renderer('templates/main.pt')
+ return {'main_template': main_template.implementation(),
+ 'pending': sorted(pending),
+ 'confirmed': sorted(confirmed),
+ }
def add_admin_user():
@@ -30,6 +30,15 @@
renderer="templates/testing_debug.pt"
/>
+ <!-- Admin pending / confirmed registration info. -->
+ <view
+ context=".models.Root"
+ name="admin.html"
+ view=".admin.admin_view"
+ renderer="templates/admin.pt"
+ permission="admin"
+ />
+
<!-- Use ZODB for storing pending registration info. -->
<adapter provides="cartouche.interfaces.IRegistrations"
name="pending"
View
@@ -28,7 +28,9 @@
class Root(PersistentMapping):
implements(IRoot)
__parent__ = __name__ = None
- __acl__ = [(Allow, Authenticated, ('view', 'edit_own_account'))]
+ __acl__ = [(Allow, Authenticated, ('view', 'edit_own_account')),
+ (Allow, 'g:admin', ('admin',)),
+ ]
def __repr__(self):
return '<Root object; keys: %s>' % ', '.join(self.keys())
@@ -0,0 +1,43 @@
+<metal:body metal:use-macro="main_template">
+ <metal:slot metal:fill-slot="main">
+
+ <h1>cartouche admin</h1>
+
+ <h3> pending registrations </h3>
+ <table>
+ <tr>
+ <th align="left" style="padding: .5em !important">E-mail</th>
+ <th align="left" style="padding: .5em !important">Token</th>
+ </tr>
+ <tr tal:repeat="(email, record) pending">
+ <td style="padding: .5em !important">${email}</td>
+ <td style="padding: .5em !important">${record.token}</td>
+ </tr>
+ </table>
+
+ <h3> confirmed registrations </h3>
+ <table>
+ <tr>
+ <th align="left" style="padding: .5em !important">UUID</th>
+ <th align="left" style="padding: .5em !important">E-mail</th>
+ <th align="left" style="padding: .5em !important">Login</th>
+ <th align="left" style="padding: .5em !important">Hashed password</th>
+ <th align="left" style="padding: .5em !important">Security question</th>
+ <th align="left" style="padding: .5em !important">Security answer</th>
+ <th align="left" style="padding: .5em !important">Token</th>
+ </tr>
+ <tr tal:repeat="(key, row) confirmed">
+ <tal:if tal:condition="not isinstance(row, basestring)">
+ <td style="padding: .5em !important">${row.uuid}</td>
+ <td style="padding: .5em !important">${row.email}</td>
+ <td style="padding: .5em !important">${row.login}</td>
+ <td style="padding: .5em !important">${row.password}</td>
+ <td style="padding: .5em !important">${row.security_question}</td>
+ <td style="padding: .5em !important">${row.security_answer}</td>
+ <td style="padding: .5em !important">${row.token}</td>
+ </tal:if>
+ </tr>
+ </table>
+
+ </metal:slot>
+</metal:body>

0 comments on commit 2d18264

Please sign in to comment.