示例#1
0
 def check_permission(self, permission, obj=None, message=None):
     """
     Throws a VLEPermissionError when the user does not have the specified permission, as defined by
     has_permission.
     """
     if not self.has_permission(permission, obj):
         raise VLEPermissionError(permission, message)
示例#2
0
def check_can_view_groups(user, course):
    if not (user.has_permission('can_view_course_users', course) or
            user.has_permission('can_edit_course_user_group', course) or
            user.has_permission('can_add_course_user_group', course) or
            user.has_permission('can_delete_course_user_group', course)):
        raise VLEPermissionError(message='You are not allowed to view the user groups of this course.')
示例#3
0
 def check_can_view(self, obj):
     if not self.can_view(obj):
         raise VLEPermissionError(message='You are not allowed to view {}'.format(str(obj)))
示例#4
0
 def check_can_edit(self, obj):
     if not permissions.can_edit(self, obj):
         raise VLEPermissionError(
             message='You are not allowed to edit {}'.format(str(obj)))