From 6a5a6203258be862e3b47ed62f61ca0dfef24628 Mon Sep 17 00:00:00 2001 From: "Dave St.Germain" Date: Mon, 27 Jan 2020 14:15:41 -0500 Subject: [PATCH] Add a data researcher role for everyone who is currently staff or instructor. --- .../migrations/0029_add_data_researcher.py | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 common/djangoapps/student/migrations/0029_add_data_researcher.py diff --git a/common/djangoapps/student/migrations/0029_add_data_researcher.py b/common/djangoapps/student/migrations/0029_add_data_researcher.py new file mode 100644 index 0000000000..d7347c7428 --- /dev/null +++ b/common/djangoapps/student/migrations/0029_add_data_researcher.py @@ -0,0 +1,30 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.27 on 2020-01-27 19:02 +from __future__ import unicode_literals + +from django.db import migrations +from student.models import CourseAccessRole + + +def add_data_researcher(apps, schema_editor): + """ + Add a `data_researcher` role for everyone who is currently `staff` or `instructor`. + """ + for role in CourseAccessRole.objects.filter(role__in=('staff', 'instructor')): + new_role, created = CourseAccessRole.objects.get_or_create( + user=role.user, + org=role.org, + course_id=role.course_id, + role='data_researcher' + ) + + +class Migration(migrations.Migration): + + dependencies = [ + ('student', '0028_historicalmanualenrollmentaudit'), + ] + + operations = [ + migrations.RunPython(add_data_researcher, reverse_code=migrations.RunPython.noop), + ]