Пример #1
0
def navbar(context, request):
    def nav_item(name, url, icon=None):
        from phoenix.utils import root_path

        active = root_path(request.current_route_path()) == root_path(url)
        return dict(name=name, url=url, active=active, icon=icon)

    items = []
    if has_permission("edit", request.context, request):
        items.append(nav_item("Processes", request.route_path("processes")))
    if has_permission("submit", request.context, request):
        items.append(nav_item("Wizard", request.route_path("wizard")))
        items.append(nav_item("Monitor", request.route_path("monitor")))

    subitems = []
    if has_permission("edit", request.context, request):
        subitems.append(nav_item("Profile", request.route_path("profile", tab="account"), icon="fa fa-user"))
        subitems.append(nav_item("Dashboard", request.route_path("dashboard", tab="jobs"), icon="fa fa-dashboard"))
    if has_permission("admin", request.context, request):
        subitems.append(nav_item("Settings", request.route_path("settings"), icon="fa fa-wrench"))

    login = "******" in request.current_route_url()

    username = None
    try:
        user = get_user(request)
        if user:
            username = user.get("name")
    except:
        logger.exception("could not get username")

    return dict(title="Phoenix", items=items, subitems=subitems, username=username, login=login)
Пример #2
0
 def process_form(self, form):
     try:
         controls = self.request.POST.items()
         appstruct = form.validate(controls)
         user = get_user(self.request)
         for key in ['name', 'email', 'organisation', 'notes']:
             user[key] = appstruct.get(key)
         self.request.db.users.update({'identifier':authenticated_userid(self.request)}, user)
     except ValidationFailure, e:
         logger.exception('validation of form failed.')
         return dict(form=e.render())
Пример #3
0
 def appstruct(self):
     appstruct = get_user(self.request)
     if appstruct is None:
         appstruct = {}
     return appstruct
Пример #4
0
 def get_user(self):
     return models.get_user(self.request)