def _get_admin_user_base_acl(self): """ Build acl for user account management for admins :returns: A list of user acls """ perms = ( 'view.user', 'edit.user', 'admin.user', 'delete.user', 'list.holiday', 'add.holiday', "list.company", "admin.company", "list.activity", 'add.userdatas', "add.login", "add.trainerdatas", ) for group in Group.query().options( load_only('name') ).filter(Group.name != 'admin'): perms += (u"addgroup.%s" % group.name,) admin_perms = perms + ('addgroup.admin',) return [ (Allow, 'group:admin', admin_perms), (Allow, 'group:manager', perms), ]
def get_groups(request): """ Collect non primary groups :returns: available groups as a list of 2-uples (name, label) """ groups = Group.query().options(load_only( Group.id, Group.label)).filter_by(primary=False).all() return [(group.name, group.label) for group in groups if request.has_permission(u"addgroup.{0}".format(group.name))]
def get_groups(request): """ Collect non primary groups :returns: available groups as a list of 2-uples (name, label) """ groups = Group.query().options( load_only(Group.id, Group.label) ).filter_by(primary=False).all() return [ (group.name, group.label) for group in groups if request.has_permission(u"addgroup.{0}".format(group.name)) ]
def deferred_user_groups_datas_validator(node, kw): ids = [entry[0] for entry in Group.query('id')] return colander.OneOf(ids)
def deferred_user_groups_datas_select(node, kw): values = Group.query('id', 'label').all() values.insert(0, ('', "- Sélectionner un rôle")) return deform.widget.SelectWidget(values=values)
def deferred_user_groups_datas_select(node, kw): values = Group.query('id', 'label').all() values.insert(0, ('', "- Sélectionner un rôle")) return deform.widget.SelectWidget( values=values )