Merge pull request #21087 from edx/waheed/PROD-433-add-student-support-role

Add system wide student support role.
This commit is contained in:
Waheed Ahmed
2019-07-12 12:30:08 +05:00
committed by GitHub
5 changed files with 71 additions and 1 deletions

View File

@@ -82,6 +82,8 @@ COURSE_CATALOG_API_URL = 'http://edx.devstack.discovery:18381/api/v1/'
# LOGGING['handlers']['console']['level'] = 'DEBUG'
# LOGGING['loggers']['django.db.backends'] = {'handlers': ['console'], 'level': 'DEBUG', 'propagate': False}
SYSTEM_WIDE_ROLE_CLASSES = os.environ.get("SYSTEM_WIDE_ROLE_CLASSES", SYSTEM_WIDE_ROLE_CLASSES)
SYSTEM_WIDE_ROLE_CLASSES.extend(['system_wide_roles.SystemWideRoleAssignment'])
if FEATURES['ENABLE_ENTERPRISE_INTEGRATION']:
SYSTEM_WIDE_ROLE_CLASSES = os.environ.get("SYSTEM_WIDE_ROLE_CLASSES", [])
SYSTEM_WIDE_ROLE_CLASSES.extend(['enterprise.SystemWideEnterpriseUserRoleAssignment'])

View File

@@ -0,0 +1,22 @@
# -*- coding: utf-8 -*-
"""
Django admin integration for system wide roles application.
"""
from django.contrib import admin
from edx_rbac.admin import UserRoleAssignmentAdmin
from openedx.core.djangoapps.system_wide_roles.admin.forms import SystemWideRoleAssignmentForm
from openedx.core.djangoapps.system_wide_roles.models import SystemWideRoleAssignment
@admin.register(SystemWideRoleAssignment)
class SystemWideRoleAssignmentAdmin(UserRoleAssignmentAdmin):
"""
Django admin model for SystemWideRoleAssignment.
"""
search_fields = ('user__email', 'role__name')
form = SystemWideRoleAssignmentForm
class Meta(object):
model = SystemWideRoleAssignment

View File

@@ -0,0 +1,9 @@
"""
Forms used for system wide roles admin.
"""
from edx_rbac.admin import UserRoleAssignmentAdminForm
class SystemWideRoleAssignmentForm(UserRoleAssignmentAdminForm):
pass

View File

@@ -0,0 +1,5 @@
"""
System wide roles application constants.
"""
STUDENT_SUPPORT_ADMIN_ROLE = 'student_support_admin'

View File

@@ -0,0 +1,32 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.22 on 2019-07-11 11:26
from __future__ import unicode_literals
from django.db import migrations
from openedx.core.djangoapps.system_wide_roles.constants import STUDENT_SUPPORT_ADMIN_ROLE
def create_roles(apps, schema_editor):
"""Create the system wide student support roles if they do not already exist."""
SystemWideRole = apps.get_model('system_wide_roles', 'SystemWideRole')
SystemWideRole.objects.update_or_create(name=STUDENT_SUPPORT_ADMIN_ROLE)
def delete_roles(apps, schema_editor):
"""Delete the system wide student support roles."""
SystemWideRole = apps.get_model('system_wide_roles', 'SystemWideRole')
SystemWideRole.objects.filter(
name=STUDENT_SUPPORT_ADMIN_ROLE
).delete()
class Migration(migrations.Migration):
dependencies = [
('system_wide_roles', '0001_SystemWideRole_SystemWideRoleAssignment'),
]
operations = [
migrations.RunPython(create_roles, delete_roles)
]