Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# -*- coding: utf-8 -*-
# Generated by Django 1.10 on 2016-08-27 18:55
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion
def add_default_permissions(apps, schema_editor):
from course.models import add_default_roles_and_permissions
Course = apps.get_model("course", "Course") # noqa
ParticipationRole = apps.get_model("course", "ParticipationRole") # noqa
ParticipationRolePermission = apps.get_model("course", "ParticipationRolePermission") # noqa
Participation = apps.get_model("course", "Participation") # noqa
for course in Course.objects.all():
add_default_roles_and_permissions(
course,
ParticipationRole,
ParticipationRolePermission)
roles = dict(
(role.identifier, role)
for role in ParticipationRole.objects.all())
roles["ta"] = roles["teaching_assistant"]
for participation in Participation.objects.filter(course=course):
participation.roles.set([roles[participation.role]])
class Migration(migrations.Migration):
dependencies = [
('course', '0092_unicode_literals'),
]
operations = [
migrations.CreateModel(
name='ParticipationPermission',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('permission', models.CharField(choices=[('edit_course', 'Edit course'), ('impersonate_role', 'Impersonate role'), ('edit_exam', 'Edit exam'), ('issue_exam_ticket', 'Issue exam ticket'), ('batch_issue_exam_ticket', 'Batch issue exam ticket'), ('see_flow_sessions_from_role', 'See flow sessions from role '), ('see_grades_from_role', 'See grades from role '), ('see_gradebook', 'See gradebook'), ('assign_grade', 'Assign grade'), ('see_grader_stats', 'See grader stats'), ('batch_import_grade', 'Batch import grades'), ('batch_export_grade', 'Batch export grade'), ('impose_deadline', 'Impose deadline'), ('regrade_flow', 'Regrade flow'), ('add_exception', 'Add exception'), ('see_analytics', 'See analytics'), ('preview_content', 'Preview content'), ('update_content', 'Update content'), ('use_markup_sandbox', 'Use markup sandbox'), ('use_page_sandbox', 'Use page sandbox'), ('test_flow', 'Test flow'), ('edit_events', 'Edit events'), ('query_participation', 'Query participation'), ('preapprove_participation', 'Preapprove participation'), ('manage_instant_flow_requests', 'Manage instant flow requests')], max_length=200, verbose_name='Permission')),
('argument', models.CharField(blank=True, max_length=200, null=True, verbose_name='Argument')),
('participation', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='course.Participation', verbose_name='Participation')),
],
options={
'verbose_name': 'Participation permission',
'verbose_name_plural': 'Participation permissionss',
},
),
migrations.CreateModel(
name='ParticipationRole',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('identifier', models.CharField(help_text='A symbolic name for this role, used in course code. lower_case_with_underscores, no spaces.', max_length=100, verbose_name='Role identifier')),
('name', models.CharField(help_text='A human-readable description of this role.', max_length=200, verbose_name='Role name')),
],
options={
'verbose_name': 'Participation role',
'ordering': ('course', 'identifier'),
'verbose_name_plural': 'Participation roles',
},
),
migrations.CreateModel(
name='ParticipationRolePermission',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('permission', models.CharField(choices=[('edit_course', 'Edit course'), ('impersonate_role', 'Impersonate role'), ('edit_exam', 'Edit exam'), ('issue_exam_ticket', 'Issue exam ticket'), ('batch_issue_exam_ticket', 'Batch issue exam ticket'), ('see_flow_sessions_from_role', 'See flow sessions from role '), ('see_grades_from_role', 'See grades from role '), ('see_gradebook', 'See gradebook'), ('assign_grade', 'Assign grade'), ('see_grader_stats', 'See grader stats'), ('batch_import_grade', 'Batch import grades'), ('batch_export_grade', 'Batch export grade'), ('impose_deadline', 'Impose deadline'), ('regrade_flow', 'Regrade flow'), ('add_exception', 'Add exception'), ('see_analytics', 'See analytics'), ('preview_content', 'Preview content'), ('update_content', 'Update content'), ('use_markup_sandbox', 'Use markup sandbox'), ('use_page_sandbox', 'Use page sandbox'), ('test_flow', 'Test flow'), ('edit_events', 'Edit events'), ('query_participation', 'Query participation'), ('preapprove_participation', 'Preapprove participation'), ('manage_instant_flow_requests', 'Manage instant flow requests')], max_length=200, verbose_name='Permission')),
('argument', models.CharField(blank=True, max_length=200, null=True, verbose_name='Argument')),
('role', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='course.ParticipationRole', verbose_name='Role')),
],
options={
'verbose_name': 'Participation role permission',
'verbose_name_plural': 'Participation role permissions',
},
),
migrations.AlterField(
model_name='course',
name='preapproval_require_verified_inst_id',
field=models.BooleanField(default=True, help_text='If set, students cannot get participation preapproval using institutional ID if the institutional ID they provided is not verified.', verbose_name='Prevent preapproval by institutional ID if not verified?'),
),
migrations.AddField(
model_name='participationrole',
name='course',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='course.Course', verbose_name='Course'),
),
migrations.AddField(
model_name='participation',
name='roles',
field=models.ManyToManyField(blank=True, to='course.ParticipationRole', verbose_name='Roles'),
),
migrations.AlterUniqueTogether(
name='participationrolepermission',
unique_together=set([('role', 'permission', 'argument')]),
),
migrations.AlterUniqueTogether(
name='participationrole',
unique_together=set([('course', 'identifier')]),
),
migrations.AlterUniqueTogether(
name='participationpermission',
unique_together=set([('participation', 'permission', 'argument')]),
),
migrations.RunPython(add_default_permissions),
]