예제 #1
0
    def get(self, uuid, **kwargs):
        try:
            role = roles.get_metadata(uuid)
            all_perms = permissions.list_metadata()
        except DataRequestException as e:
            return render_template(self.template, errors=e.errors)
        else:
            # get the permissions already granted to the role
            role_perms = list(role['permissions'].keys())

            # remove any permissions not in the user's organization. Users
            # cannot add permissions from outside their org to a role inside it
            # but may be able to read metadata of those permissions.
            all_perms = self.filter_by_org(all_perms, 'organization')

            # Remove any permissions that already exist on the role.
            all_perms = [
                perm for perm in all_perms
                if perm['permission_id'] not in role_perms
            ]
            self.set_template_args()
        return render_template(self.template,
                               role=role,
                               table_data=all_perms,
                               **self.template_args,
                               **kwargs)
예제 #2
0
 def get(self):
     permissions_list = permissions.list_metadata().json()
     if 'errors' in permissions_list:
         permissions_list = None
     return render_template('forms/admin/permissions.html',
                            table_data=permissions_list,
                            **self.template_args())
예제 #3
0
 def get(self):
     try:
         permissions_list = permissions.list_metadata()
     except DataRequestException as e:
         return render_template(self.template, errors=e.errors)
     self.set_template_args()
     return render_template(self.template,
                            table_data=permissions_list,
                            **self.template_args)
예제 #4
0
 def get(self, uuid, **kwargs):
     # This view displays either a table of permissions granted to the role
     # or users that were granted the role based on the `table` query param.
     role_table = request.args.get('table', 'permissions')
     try:
         role = roles.get_metadata(uuid)
         permission_list = permissions.list_metadata()
     except DataRequestException as e:
         return render_template(self.template, errors=e.errors)
     else:
         self.set_template_args(role, permission_list, role_table)
     return render_template(self.template, **kwargs, **self.template_args)
예제 #5
0
 def get(self, uuid):
     role = roles.get_metadata(uuid).json()
     if 'errors' in role:
         role = None
     else:
         permission_list = permissions.list_metadata().json()
         permission_map = {
             perm['permission_id']: perm
             for perm in permission_list
         }
         role['permissions'] = {
             k: {
                 'added_to_role': v,
                 **permission_map[k]
             }
             for k, v in role['permissions'].items() if k in permission_map
         }
     return render_template('forms/admin/role.html',
                            role=role,
                            **self.template_args())