def validate(self, role_dict, key, unused_schema_version, errors):
        """Validate the role data sent from the form."""
        role_names = {role.name for role in RoleDAO.get_all() if (
            not key or role.id != long(key))}

        if not role_dict['name'] or role_dict['name'] in role_names:
            errors.append('The role must have a unique non-empty name.')
Exemple #2
0
    def validate(self, role_dict, key, unused_schema_version, errors):
        """Validate the role data sent from the form."""
        role_names = {role.name for role in RoleDAO.get_all() if (
            not key or role.id != long(key))}

        if not role_dict['name'] or role_dict['name'] in role_names:
            errors.append('The role must have a unique non-empty name.')
    def _render_roles_list(self):
        """Render roles list to HTML."""
        all_roles = RoleDAO.get_all()
        if all_roles:
            output = safe_dom.Element('ul')
            for role in sorted(all_roles, key=lambda r: r.name):
                li = safe_dom.Element('li')
                output.add_child(li)
                li.add_text(role.name).add_child(
                    dashboard_utils.create_edit_button(
                        'dashboard?action=edit_role&key=%s' % (role.id)))
        else:
            output = safe_dom.Element('blockquote').add_text('< none >')

        return output
    def _render_roles_list(self):
        """Render roles list to HTML."""
        all_roles = RoleDAO.get_all()
        if all_roles:
            output = safe_dom.Element('ul')
            for role in sorted(all_roles, key=lambda r: r.name):
                li = safe_dom.Element('li')
                output.add_child(li)
                li.add_text(role.name).add_child(
                    dashboard_utils.create_edit_button(
                    'dashboard?action=edit_role&key=%s' % (role.id)
                ))
        else:
            output = safe_dom.Element('blockquote').add_text('< none >')

        return output
Exemple #5
0
 def _render_roles_list(self):
     """Render roles list to HTML."""
     all_roles = sorted(RoleDAO.get_all(), key=lambda role: role.name)
     return safe_dom.Template(
         self.get_template('role_list.html'), roles=all_roles)
 def _render_roles_list(self):
     """Render roles list to HTML."""
     all_roles = sorted(RoleDAO.get_all(), key=lambda role: role.name)
     return safe_dom.Template(
         self.get_template('role_list.html'), roles=all_roles)