# -*- 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),
    ]

Add a data researcher role for everyone who is currently staff or instructor.
Add a data researcher role for everyone who is currently staff or instructor.
