''' Resources for account registraion and settings ''' from pyramid.security import Allow, Authenticated, Everyone, Deny, DENY_ALL from ordr2.resources.base import BaseResource class AccountResource(BaseResource): ''' Resouce class for account registration and settings ''' #: name of the main navigation section for template highlighting nav_section = 'account' def __init__(self, name, parent, model=None): ''' Create a base resource ''' super().__init__(name, parent) # the current model depends is the current logged in user or None self.model = self.request.user def __acl__(self): ''' access controll list for the resource - everyone can log in our log out - authenticated users can change their settings - unauthenticated users can register ''' return [ (Allow, Everyone, 'login'), (Allow, Everyone, 'logout'), (Deny, Authenticated, 'register'), (Allow, Everyone, 'register'), (Allow, Authenticated, 'settings'), ]