Skip to content
0112_add_use_git_endpoint_permission.py 853 B
Newer Older
from django.db import migrations

Andreas Klöckner's avatar
Andreas Klöckner committed

def add_use_git_endpoint_permission(apps, schema_editor):
    from course.constants import participation_permission as pperm

    ParticipationRolePermission = apps.get_model("course", "ParticipationRolePermission")

    roles_pks = (
        ParticipationRolePermission.objects.filter(
            permission=pperm.edit_course)
        .values_list("role", flat=True)
    )

    if roles_pks.count():
        for pk in roles_pks:
            ParticipationRolePermission.objects.get_or_create(
                role_id=pk,
                permission=pperm.use_git_endpoint
            )


class Migration(migrations.Migration):

    dependencies = [
Isuru Fernando's avatar
Isuru Fernando committed
        ('course', '0111_alter_git_source_in_course_to_a_required_field'),
        migrations.RunPython(add_use_git_endpoint_permission)