Holger Frey
7 years ago
5 changed files with 80 additions and 1 deletions
@ -0,0 +1,9 @@
@@ -0,0 +1,9 @@
|
||||
from pyramid.security import Allow, Authenticated, Deny, Everyone |
||||
|
||||
from .base import BaseResource |
||||
|
||||
|
||||
class Admin(BaseResource): |
||||
|
||||
def __acl__(self): |
||||
return [ (Allow, 'role:admin', 'view') ] |
@ -0,0 +1,36 @@
@@ -0,0 +1,36 @@
|
||||
{% extends "ordr2:templates/layout.jinja2" %} |
||||
{% import 'ordr2:templates/macros.jinja2' as macros with context %} |
||||
|
||||
{% block subtitle %} Admin {% endblock subtitle %} |
||||
|
||||
{% block content %} |
||||
<div class="content controls"> |
||||
|
||||
<div class="container-fluid"> |
||||
|
||||
<div class="row-fluid"> |
||||
<div class="page-controls"> |
||||
<h1>Register</h1> |
||||
</div> |
||||
</div> |
||||
|
||||
<div class="row-fluid">{{ macros.flash_messages() }}</div> |
||||
|
||||
<div class="row admin-options"> |
||||
<a href="<?php echo base_url(); ?>admin/users/view/"> |
||||
<div class="span4 rounded-box"> |
||||
<div class="option user"></div> |
||||
<h2>Mangage Users</h2> |
||||
</div> |
||||
</a> |
||||
<a href="<?php echo base_url(); ?>admin/consumables/view/"> |
||||
<div class="span4 rounded-box"> |
||||
<div class="option shop"></div> |
||||
<h2>Manage Consumables</h2> |
||||
</div> |
||||
</a> |
||||
</div> |
||||
</div> |
||||
|
||||
</div> |
||||
{% endblock content %} |
@ -0,0 +1,31 @@
@@ -0,0 +1,31 @@
|
||||
import deform |
||||
|
||||
from pyramid.httpexceptions import HTTPFound |
||||
from pyramid.renderers import render |
||||
from pyramid.security import remember, forget |
||||
from pyramid.view import view_config |
||||
|
||||
from ordr2.models import User, Role |
||||
from ordr2.schemas.account import UserSchema |
||||
|
||||
# user log in and log out |
||||
|
||||
@view_config( |
||||
context='ordr2:resources.Admin', |
||||
permission='view', |
||||
renderer='ordr2:templates/admin/admin_section.jinja2' |
||||
) |
||||
def admin_section(context, request): |
||||
''' display the admin section ''' |
||||
new_users = request.dbsession.query(User).filter_by(role=Role.NEW).count() |
||||
if new_users: |
||||
plural = 's' if new_users > 1 else '' |
||||
request.flash( |
||||
'info', |
||||
'{} new user{} have registered.'.format(new_users, plural), |
||||
'''Please <a href="{}">take a look at them</a> and confirm or |
||||
reject the registration by setting the role accordingly. This |
||||
message will disappear when all new registrations have been |
||||
processed.'''.format(request.resource_url(context, 'users')) |
||||
) |
||||
return {} |
Reference in new issue