Commits

Doug Latornell  committed 8e146e6

Add admin item list view stubs & view for admins (aka wranglers).

  • Participants
  • Parent commits b2d0a8b

Comments (0)

Files changed (5)

File randopony/__init__.py

     config.add_route('home', '/')
     # admin routes
     config.add_route('admin.home', '/admin')
+    config.add_route('admin.brevets', '/admin/brevets/')
+    config.add_route('admin.club_events', '/admin/club-events/')
+    config.add_route('admin.populaires', '/admin/populaires/')
+    config.add_route('admin.wranglers', '/admin/wranglers/')
+    config.add_route('admin.wrangler.edit', '/admin/wranglers/{item}/edit')

File randopony/models.py

 
     def __init__(self, persona_email):
         self.persona_email = persona_email
+
+    def __str__(self):
+        return self.persona_email

File randopony/templates/admin/home.mako

 <%inherit file="page.mako"/>
 
 <ul class="unstyled admin-list">
-  <li><a href="#">Brevets</a></li>
-  <li><a href="#">Club Events</a></li>
-  <li><a href="#">Populaires</a></li>
-  <li><a href="#">Pony Wranglers</a></li>
+  <li><a href="${request.route_url('admin.brevets')}">Brevets</a></li>
+  <li><a href="${request.route_url('admin.club_events')}">Club Events</a></li>
+  <li><a href="${request.route_url('admin.populaires')}">Populaires</a></li>
+  <li><a href="${request.route_url('admin.wranglers')}">Pony Wranglers</a></li>
 </ul>

File randopony/templates/admin/wranglers.mako

+<%inherit file="page.mako"/>
+
+<ul class="unstyled admin-list">
+  %for wrangler in wranglers:
+  <li>
+    <a href="${request.route_url('admin.wrangler.edit', item=str(wrangler))}">
+      ${wrangler.persona_email}
+    </a>
+  </li>
+  %endfor
+</ul>

File randopony/views/admin.py

 """
 from pyramid.renderers import render
 from pyramid.response import Response
-from pyramid.security import authenticated_userid
 from pyramid.view import (
     forbidden_view_config,
     view_config,
     )
+from ..models import (
+    DBSession,
+    Administrator,
+    )
 
 
 @forbidden_view_config()
 @view_config(route_name='admin.home', renderer='admin/home.mako',
              permission='admin')
 def admin_home(request):
-    userid = authenticated_userid(request)
-    return {'logout_btn': True, 'user': userid}
+    return {'logout_btn': True}
+
+
+@view_config(route_name='admin.brevets', renderer='string',
+             permission='admin')
+def admin_brevets(request):
+    return 'brevets stub'
+
+
+@view_config(route_name='admin.club_events', renderer='string',
+             permission='admin')
+def admin_club_events(request):
+    return 'club events stub'
+
+
+@view_config(route_name='admin.populaires', renderer='string',
+             permission='admin')
+def admin_populaires(request):
+    return 'populaires stub'
+
+
+@view_config(route_name='admin.wranglers',
+    renderer='admin/wranglers.mako',
+    permission='admin')
+def admin_wranglers(request):
+    tmpl_vars = {'logout_btn': True}
+    wranglers = DBSession.query(Administrator).\
+        order_by(Administrator.persona_email)
+    tmpl_vars.update({'wranglers': wranglers})
+    return tmpl_vars
+
+
+@view_config(route_name='admin.wrangler.edit',
+    renderer='string',
+    permission='admin')
+def admin_wrangler_edit(request):
+    admin = request.matchdict['item']
+    return 'wrangler edit stub for {}'.format(admin)