Newer
Older
from django.db import migrations
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 = [
('course', '0111_alter_git_source_in_course_to_a_required_field'),
migrations.RunPython(add_use_git_endpoint_permission)