Permalink
Browse files

Add groups list to admin dashboard

  • Loading branch information...
finitud committed Dec 3, 2015
1 parent 49f770e commit 33a71ca87264da6d358362e1c0feda572f608b53
Showing with 51 additions and 0 deletions.
  1. +7 −0 h/admin.py
  2. +4 −0 h/groups/models.py
  3. +2 −0 h/resources.py
  4. +37 −0 h/templates/admin/groups.html.jinja2
  5. +1 −0 h/templates/layouts/admin.html.jinja2
View
@@ -207,6 +207,12 @@ def badge_remove(request):
request.db.delete(models.Blocklist.get_by_uri(uri))
return badge_index(request)
@view.view_config(route_name='admin_groups',
request_method='GET',
renderer='h:templates/admin/groups.html.jinja2',
permission='admin_groups')
def groups_index(request):
return {"groups": models.Group.all(), "request": request}
def includeme(config):
config.add_route('admin_index', '/admin')
@@ -215,5 +221,6 @@ def includeme(config):
config.add_route('admin_admins', '/admin/admins')
config.add_route('admin_staff', '/admin/staff')
config.add_route('admin_users', '/admin/users')
config.add_route('admin_groups', '/admin/groups')
config.add_route('admin_badge', '/admin/badge')
config.scan(__name__)
View
@@ -63,6 +63,10 @@ def slug(self):
def __repr__(self):
return '<Group: %s>' % self.slug
@classmethod
def all(cls):
return cls.query.all()
@classmethod
def get_by_pubid(cls, pubid):
"""Return the group with the given pubid, or None."""
View
@@ -42,6 +42,8 @@ class Root(Resource):
(Allow, 'group:__admin__', 'admin_users'),
(Allow, 'group:__staff__', 'admin_users'),
(Allow, 'group:__admin__', 'admin_badge'),
(Allow, 'group:__admin__', 'admin_groups'),
(Allow, 'group:__staff__', 'admin_groups'),
]
@@ -0,0 +1,37 @@
{% extends "h:templates/layouts/admin.html.jinja2" %}
{% set page_id = 'groups' %}
{% set page_title = 'Groups' %}
{% block content %}
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th>Name</th>
<th>URL</th>
<th>Created by</th>
<th>Email</th>
<th>Members</th>
</tr>
</thead>
<tbody>
{% for group in groups %}
<tr>
<td>{{ group.name }}</td>
<td>
<a href="{{ request.route_url('group_read', pubid=group.pubid, slug=group.slug) }}">
{{ request.route_url('group_read', pubid=group.pubid, slug=group.slug) }}
</a>
</td>
<td>{{ group.creator.username }}</td>
<td>{{ group.creator.email }}</td>
<td>{{ group.members|length }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% endblock %}
@@ -5,6 +5,7 @@
('admins', 'admin_admins', 'Administrators'),
('staff', 'admin_staff', 'Staff'),
('users', 'admin_users', 'Users'),
('groups', 'admin_groups', 'Groups'),
('badge', 'admin_badge', 'Badge'),
] -%}

0 comments on commit 33a71ca

Please sign in to comment.