Source

BlastOff / BlastOff / blastoff / template / +package+ / controllers / admin.py_tmpl

Full commit
{{if rum_admin}}
import logging

from paste.deploy.converters import asbool
from pylons import g, config

from {{package}}.lib import helpers as h


log = logging.getLogger(__name__)


def AdminController(environ, start_response):
    if not asbool(config.get('admin.enable', False)):
        # abort(404)
        start_response("404 Not Found", [])
        return ['404 Not Found']
    
    # Authenticated user must be in "admin.users" config setting
    auth_user = h.user()
    if auth_user is None or not auth_user.user_name in admin_users():
        # abort(404)
        start_response("404 Not Found", [])
        return ['404 Not Found']
    
    return g.admin_app(environ, start_response)


def admin_users():
    return [u.strip() for u in config.get('admin.users', '').split(',')]

{{else}}
{{py:raise SkipTemplate('skip file')}}
{{endif}}