learning-credentials 0.2.0rc1__py2.py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- learning_credentials/__init__.py +3 -0
- learning_credentials/admin.py +263 -0
- learning_credentials/apps.py +24 -0
- learning_credentials/compat.py +117 -0
- learning_credentials/exceptions.py +9 -0
- learning_credentials/generators.py +224 -0
- learning_credentials/migrations/0001_initial.py +205 -0
- learning_credentials/migrations/0002_migrate_to_learning_credentials.py +32 -0
- learning_credentials/migrations/0003_rename_certificates_to_credentials.py +128 -0
- learning_credentials/migrations/0004_replace_course_keys_with_learning_context_keys.py +59 -0
- learning_credentials/migrations/0005_rename_processors_and_generators.py +106 -0
- learning_credentials/migrations/__init__.py +0 -0
- learning_credentials/models.py +381 -0
- learning_credentials/processors.py +306 -0
- learning_credentials/settings/__init__.py +1 -0
- learning_credentials/settings/common.py +12 -0
- learning_credentials/settings/production.py +13 -0
- learning_credentials/tasks.py +53 -0
- learning_credentials/templates/learning_credentials/base.html +22 -0
- learning_credentials/templates/learning_credentials/edx_ace/certificate_generated/email/body.html +22 -0
- learning_credentials/templates/learning_credentials/edx_ace/certificate_generated/email/head.html +0 -0
- learning_credentials/urls.py +9 -0
- learning_credentials/views.py +1 -0
- learning_credentials-0.2.0rc1.dist-info/METADATA +204 -0
- learning_credentials-0.2.0rc1.dist-info/RECORD +34 -0
- learning_credentials-0.2.0rc1.dist-info/WHEEL +6 -0
- learning_credentials-0.2.0rc1.dist-info/entry_points.txt +3 -0
- learning_credentials-0.2.0rc1.dist-info/licenses/LICENSE.txt +664 -0
- learning_credentials-0.2.0rc1.dist-info/top_level.txt +2 -0
- openedx_certificates/__init__.py +1 -0
- openedx_certificates/apps.py +11 -0
- openedx_certificates/migrations/0001_initial.py +206 -0
- openedx_certificates/migrations/__init__.py +0 -0
- openedx_certificates/models.py +38 -0
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
from django.db import migrations, models
|
|
2
|
+
import django.utils.timezone
|
|
3
|
+
import jsonfield.fields
|
|
4
|
+
import model_utils.fields
|
|
5
|
+
import opaque_keys.edx.django.models
|
|
6
|
+
import uuid
|
|
7
|
+
|
|
8
|
+
import openedx_certificates.models
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class Migration(migrations.Migration):
|
|
12
|
+
|
|
13
|
+
initial = True
|
|
14
|
+
|
|
15
|
+
dependencies = [
|
|
16
|
+
('django_celery_beat', '0019_alter_periodictasks_options'),
|
|
17
|
+
]
|
|
18
|
+
|
|
19
|
+
operations = [
|
|
20
|
+
migrations.CreateModel(
|
|
21
|
+
name='ExternalCertificateAsset',
|
|
22
|
+
fields=[
|
|
23
|
+
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
|
24
|
+
(
|
|
25
|
+
'created',
|
|
26
|
+
model_utils.fields.AutoCreatedField(
|
|
27
|
+
default=django.utils.timezone.now, editable=False, verbose_name='created'
|
|
28
|
+
),
|
|
29
|
+
),
|
|
30
|
+
(
|
|
31
|
+
'modified',
|
|
32
|
+
model_utils.fields.AutoLastModifiedField(
|
|
33
|
+
default=django.utils.timezone.now, editable=False, verbose_name='modified'
|
|
34
|
+
),
|
|
35
|
+
),
|
|
36
|
+
('description', models.CharField(blank=True, help_text='Description of the asset.', max_length=255)),
|
|
37
|
+
(
|
|
38
|
+
'asset',
|
|
39
|
+
models.FileField(
|
|
40
|
+
help_text='Asset file. It could be a PDF template, image or font file.',
|
|
41
|
+
max_length=255,
|
|
42
|
+
upload_to=openedx_certificates.models.ExternalCertificateAsset.template_assets_path,
|
|
43
|
+
),
|
|
44
|
+
),
|
|
45
|
+
(
|
|
46
|
+
'asset_slug',
|
|
47
|
+
models.SlugField(
|
|
48
|
+
help_text="Asset's unique slug. We can reference the asset in templates using this value.",
|
|
49
|
+
max_length=255,
|
|
50
|
+
unique=True,
|
|
51
|
+
),
|
|
52
|
+
),
|
|
53
|
+
],
|
|
54
|
+
options={
|
|
55
|
+
'get_latest_by': 'created',
|
|
56
|
+
},
|
|
57
|
+
),
|
|
58
|
+
migrations.CreateModel(
|
|
59
|
+
name='ExternalCertificateType',
|
|
60
|
+
fields=[
|
|
61
|
+
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
|
62
|
+
(
|
|
63
|
+
'created',
|
|
64
|
+
model_utils.fields.AutoCreatedField(
|
|
65
|
+
default=django.utils.timezone.now, editable=False, verbose_name='created'
|
|
66
|
+
),
|
|
67
|
+
),
|
|
68
|
+
(
|
|
69
|
+
'modified',
|
|
70
|
+
model_utils.fields.AutoLastModifiedField(
|
|
71
|
+
default=django.utils.timezone.now, editable=False, verbose_name='modified'
|
|
72
|
+
),
|
|
73
|
+
),
|
|
74
|
+
('name', models.CharField(help_text='Name of the certificate type.', max_length=255, unique=True)),
|
|
75
|
+
(
|
|
76
|
+
'retrieval_func',
|
|
77
|
+
models.CharField(help_text='A name of the function to retrieve eligible users.', max_length=200),
|
|
78
|
+
),
|
|
79
|
+
(
|
|
80
|
+
'generation_func',
|
|
81
|
+
models.CharField(help_text='A name of the function to generate certificates.', max_length=200),
|
|
82
|
+
),
|
|
83
|
+
(
|
|
84
|
+
'custom_options',
|
|
85
|
+
jsonfield.fields.JSONField(blank=True, default=dict, help_text='Custom options for the functions.'),
|
|
86
|
+
),
|
|
87
|
+
],
|
|
88
|
+
options={
|
|
89
|
+
'abstract': False,
|
|
90
|
+
},
|
|
91
|
+
),
|
|
92
|
+
migrations.CreateModel(
|
|
93
|
+
name='ExternalCertificate',
|
|
94
|
+
fields=[
|
|
95
|
+
(
|
|
96
|
+
'created',
|
|
97
|
+
model_utils.fields.AutoCreatedField(
|
|
98
|
+
default=django.utils.timezone.now, editable=False, verbose_name='created'
|
|
99
|
+
),
|
|
100
|
+
),
|
|
101
|
+
(
|
|
102
|
+
'modified',
|
|
103
|
+
model_utils.fields.AutoLastModifiedField(
|
|
104
|
+
default=django.utils.timezone.now, editable=False, verbose_name='modified'
|
|
105
|
+
),
|
|
106
|
+
),
|
|
107
|
+
(
|
|
108
|
+
'uuid',
|
|
109
|
+
models.UUIDField(
|
|
110
|
+
default=uuid.uuid4,
|
|
111
|
+
editable=False,
|
|
112
|
+
help_text='Auto-generated UUID of the certificate',
|
|
113
|
+
primary_key=True,
|
|
114
|
+
serialize=False,
|
|
115
|
+
),
|
|
116
|
+
),
|
|
117
|
+
('user_id', models.IntegerField(help_text='ID of the user receiving the certificate')),
|
|
118
|
+
('user_full_name', models.CharField(help_text='User receiving the certificate', max_length=255)),
|
|
119
|
+
(
|
|
120
|
+
'course_id',
|
|
121
|
+
opaque_keys.edx.django.models.CourseKeyField(
|
|
122
|
+
help_text='ID of a course for which the certificate was issued', max_length=255
|
|
123
|
+
),
|
|
124
|
+
),
|
|
125
|
+
('certificate_type', models.CharField(help_text='Type of the certificate', max_length=255)),
|
|
126
|
+
(
|
|
127
|
+
'status',
|
|
128
|
+
models.CharField(
|
|
129
|
+
choices=[
|
|
130
|
+
('generating', 'Generating'),
|
|
131
|
+
('available', 'Available'),
|
|
132
|
+
('error', 'Error'),
|
|
133
|
+
('invalidated', 'Invalidated'),
|
|
134
|
+
],
|
|
135
|
+
default='generating',
|
|
136
|
+
help_text='Status of the certificate generation task',
|
|
137
|
+
max_length=32,
|
|
138
|
+
),
|
|
139
|
+
),
|
|
140
|
+
(
|
|
141
|
+
'download_url',
|
|
142
|
+
models.URLField(blank=True, help_text='URL of the generated certificate PDF (e.g., to S3)'),
|
|
143
|
+
),
|
|
144
|
+
(
|
|
145
|
+
'legacy_id',
|
|
146
|
+
models.IntegerField(
|
|
147
|
+
help_text='Legacy ID of the certificate imported from another system', null=True
|
|
148
|
+
),
|
|
149
|
+
),
|
|
150
|
+
('generation_task_id', models.CharField(help_text='Task ID from the Celery queue', max_length=255)),
|
|
151
|
+
],
|
|
152
|
+
options={
|
|
153
|
+
'unique_together': {('user_id', 'course_id', 'certificate_type')},
|
|
154
|
+
},
|
|
155
|
+
),
|
|
156
|
+
migrations.CreateModel(
|
|
157
|
+
name='ExternalCertificateCourseConfiguration',
|
|
158
|
+
fields=[
|
|
159
|
+
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
|
160
|
+
(
|
|
161
|
+
'created',
|
|
162
|
+
model_utils.fields.AutoCreatedField(
|
|
163
|
+
default=django.utils.timezone.now, editable=False, verbose_name='created'
|
|
164
|
+
),
|
|
165
|
+
),
|
|
166
|
+
(
|
|
167
|
+
'modified',
|
|
168
|
+
model_utils.fields.AutoLastModifiedField(
|
|
169
|
+
default=django.utils.timezone.now, editable=False, verbose_name='modified'
|
|
170
|
+
),
|
|
171
|
+
),
|
|
172
|
+
(
|
|
173
|
+
'course_id',
|
|
174
|
+
opaque_keys.edx.django.models.CourseKeyField(help_text='The ID of the course.', max_length=255),
|
|
175
|
+
),
|
|
176
|
+
(
|
|
177
|
+
'custom_options',
|
|
178
|
+
jsonfield.fields.JSONField(
|
|
179
|
+
blank=True,
|
|
180
|
+
default=dict,
|
|
181
|
+
help_text='Custom options for the functions. If specified, they are merged with the options defined in the certificate type.',
|
|
182
|
+
),
|
|
183
|
+
),
|
|
184
|
+
(
|
|
185
|
+
'certificate_type',
|
|
186
|
+
models.ForeignKey(
|
|
187
|
+
help_text='Associated certificate type.',
|
|
188
|
+
on_delete=django.db.models.deletion.CASCADE,
|
|
189
|
+
to='learning_credentials.externalcertificatetype',
|
|
190
|
+
),
|
|
191
|
+
),
|
|
192
|
+
(
|
|
193
|
+
'periodic_task',
|
|
194
|
+
models.OneToOneField(
|
|
195
|
+
help_text='Associated periodic task.',
|
|
196
|
+
on_delete=django.db.models.deletion.CASCADE,
|
|
197
|
+
to='django_celery_beat.periodictask',
|
|
198
|
+
),
|
|
199
|
+
),
|
|
200
|
+
],
|
|
201
|
+
options={
|
|
202
|
+
'unique_together': {('course_id', 'certificate_type')},
|
|
203
|
+
},
|
|
204
|
+
),
|
|
205
|
+
]
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
from django.db import migrations
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class Migration(migrations.Migration):
|
|
5
|
+
dependencies = [
|
|
6
|
+
('openedx_certificates', '0001_initial'),
|
|
7
|
+
('learning_credentials', '0001_initial'),
|
|
8
|
+
]
|
|
9
|
+
|
|
10
|
+
operations = [
|
|
11
|
+
migrations.RunSQL(
|
|
12
|
+
sql=[
|
|
13
|
+
"INSERT INTO learning_credentials_externalcertificatetype (id, created, modified, name, retrieval_func, generation_func, custom_options) "
|
|
14
|
+
"SELECT id, created, modified, name, retrieval_func, generation_func, custom_options FROM openedx_certificates_externalcertificatetype;",
|
|
15
|
+
|
|
16
|
+
"INSERT INTO learning_credentials_externalcertificatecourseconfiguration (id, created, modified, course_id, custom_options, certificate_type_id, periodic_task_id) "
|
|
17
|
+
"SELECT id, created, modified, course_id, custom_options, certificate_type_id, periodic_task_id FROM openedx_certificates_externalcertificatecourseconfiguration;",
|
|
18
|
+
|
|
19
|
+
"INSERT INTO learning_credentials_externalcertificateasset (id, created, modified, description, asset, asset_slug) "
|
|
20
|
+
"SELECT id, created, modified, description, asset, asset_slug FROM openedx_certificates_externalcertificateasset;",
|
|
21
|
+
|
|
22
|
+
"INSERT INTO learning_credentials_externalcertificate (uuid, created, modified, user_id, user_full_name, course_id, certificate_type, status, download_url, legacy_id, generation_task_id) "
|
|
23
|
+
"SELECT uuid, created, modified, user_id, user_full_name, course_id, certificate_type, status, download_url, legacy_id, generation_task_id FROM openedx_certificates_externalcertificate;",
|
|
24
|
+
],
|
|
25
|
+
reverse_sql=[
|
|
26
|
+
"DELETE FROM learning_credentials_externalcertificate;",
|
|
27
|
+
"DELETE FROM learning_credentials_externalcertificatecourseconfiguration;",
|
|
28
|
+
"DELETE FROM learning_credentials_externalcertificateasset;",
|
|
29
|
+
"DELETE FROM learning_credentials_externalcertificatetype;",
|
|
30
|
+
],
|
|
31
|
+
),
|
|
32
|
+
]
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
from django.db import migrations, models
|
|
2
|
+
import django.utils.timezone
|
|
3
|
+
import jsonfield.fields
|
|
4
|
+
import opaque_keys.edx.django.models
|
|
5
|
+
import uuid
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class Migration(migrations.Migration):
|
|
9
|
+
|
|
10
|
+
dependencies = [
|
|
11
|
+
('django_celery_beat', '0019_alter_periodictasks_options'),
|
|
12
|
+
('learning_credentials', '0002_migrate_to_learning_credentials'),
|
|
13
|
+
]
|
|
14
|
+
|
|
15
|
+
operations = [
|
|
16
|
+
migrations.RenameModel(
|
|
17
|
+
old_name='ExternalCertificateCourseConfiguration',
|
|
18
|
+
new_name='CredentialConfiguration',
|
|
19
|
+
),
|
|
20
|
+
migrations.RenameModel(
|
|
21
|
+
old_name='ExternalCertificateAsset',
|
|
22
|
+
new_name='CredentialAsset',
|
|
23
|
+
),
|
|
24
|
+
migrations.RenameModel(
|
|
25
|
+
old_name='ExternalCertificateType',
|
|
26
|
+
new_name='CredentialType',
|
|
27
|
+
),
|
|
28
|
+
migrations.RenameModel(
|
|
29
|
+
old_name='ExternalCertificate',
|
|
30
|
+
new_name='Credential',
|
|
31
|
+
),
|
|
32
|
+
migrations.RenameField(
|
|
33
|
+
model_name='Credential',
|
|
34
|
+
old_name='certificate_type',
|
|
35
|
+
new_name='credential_type',
|
|
36
|
+
),
|
|
37
|
+
migrations.RenameField(
|
|
38
|
+
model_name='CredentialConfiguration',
|
|
39
|
+
old_name='certificate_type',
|
|
40
|
+
new_name='credential_type',
|
|
41
|
+
),
|
|
42
|
+
migrations.AlterField(
|
|
43
|
+
model_name='credential',
|
|
44
|
+
name='course_id',
|
|
45
|
+
field=opaque_keys.edx.django.models.CourseKeyField(
|
|
46
|
+
help_text='ID of a course for which the credential was issued', max_length=255
|
|
47
|
+
),
|
|
48
|
+
),
|
|
49
|
+
migrations.AlterField(
|
|
50
|
+
model_name='credential',
|
|
51
|
+
name='credential_type',
|
|
52
|
+
field=models.CharField(help_text='Type of the credential', max_length=255),
|
|
53
|
+
),
|
|
54
|
+
migrations.AlterField(
|
|
55
|
+
model_name='credential',
|
|
56
|
+
name='download_url',
|
|
57
|
+
field=models.URLField(blank=True, help_text='URL of the generated credential PDF (e.g., to S3)'),
|
|
58
|
+
),
|
|
59
|
+
migrations.AlterField(
|
|
60
|
+
model_name='credential',
|
|
61
|
+
name='legacy_id',
|
|
62
|
+
field=models.IntegerField(help_text='Legacy ID of the credential imported from another system', null=True),
|
|
63
|
+
),
|
|
64
|
+
migrations.AlterField(
|
|
65
|
+
model_name='credential',
|
|
66
|
+
name='status',
|
|
67
|
+
field=models.CharField(
|
|
68
|
+
choices=[
|
|
69
|
+
('generating', 'Generating'),
|
|
70
|
+
('available', 'Available'),
|
|
71
|
+
('error', 'Error'),
|
|
72
|
+
('invalidated', 'Invalidated'),
|
|
73
|
+
],
|
|
74
|
+
default='generating',
|
|
75
|
+
help_text='Status of the credential generation task',
|
|
76
|
+
max_length=32,
|
|
77
|
+
),
|
|
78
|
+
),
|
|
79
|
+
migrations.AlterField(
|
|
80
|
+
model_name='credential',
|
|
81
|
+
name='user_full_name',
|
|
82
|
+
field=models.CharField(help_text='User receiving the credential', max_length=255),
|
|
83
|
+
),
|
|
84
|
+
migrations.AlterField(
|
|
85
|
+
model_name='credential',
|
|
86
|
+
name='user_id',
|
|
87
|
+
field=models.IntegerField(help_text='ID of the user receiving the credential'),
|
|
88
|
+
),
|
|
89
|
+
migrations.AlterField(
|
|
90
|
+
model_name='credential',
|
|
91
|
+
name='uuid',
|
|
92
|
+
field=models.UUIDField(
|
|
93
|
+
default=uuid.uuid4,
|
|
94
|
+
editable=False,
|
|
95
|
+
help_text='Auto-generated UUID of the credential',
|
|
96
|
+
primary_key=True,
|
|
97
|
+
serialize=False,
|
|
98
|
+
),
|
|
99
|
+
),
|
|
100
|
+
migrations.AlterField(
|
|
101
|
+
model_name='credentialconfiguration',
|
|
102
|
+
name='credential_type',
|
|
103
|
+
field=models.ForeignKey(
|
|
104
|
+
help_text='Associated credential type.',
|
|
105
|
+
on_delete=django.db.models.deletion.CASCADE,
|
|
106
|
+
to='learning_credentials.credentialtype',
|
|
107
|
+
),
|
|
108
|
+
),
|
|
109
|
+
migrations.AlterField(
|
|
110
|
+
model_name='credentialconfiguration',
|
|
111
|
+
name='custom_options',
|
|
112
|
+
field=jsonfield.fields.JSONField(
|
|
113
|
+
blank=True,
|
|
114
|
+
default=dict,
|
|
115
|
+
help_text='Custom options for the functions. If specified, they are merged with the options defined in the credential type.',
|
|
116
|
+
),
|
|
117
|
+
),
|
|
118
|
+
migrations.AlterField(
|
|
119
|
+
model_name='credentialtype',
|
|
120
|
+
name='generation_func',
|
|
121
|
+
field=models.CharField(help_text='A name of the function to generate credentials.', max_length=200),
|
|
122
|
+
),
|
|
123
|
+
migrations.AlterField(
|
|
124
|
+
model_name='credentialtype',
|
|
125
|
+
name='name',
|
|
126
|
+
field=models.CharField(help_text='Name of the credential type.', max_length=255, unique=True),
|
|
127
|
+
),
|
|
128
|
+
]
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# Generated by Django 4.2.20 on 2025-03-27 17:36
|
|
2
|
+
|
|
3
|
+
from django.db import migrations
|
|
4
|
+
import opaque_keys.edx.django.models
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class Migration(migrations.Migration):
|
|
8
|
+
|
|
9
|
+
dependencies = [
|
|
10
|
+
('learning_credentials', '0003_rename_certificates_to_credentials'),
|
|
11
|
+
]
|
|
12
|
+
|
|
13
|
+
operations = [
|
|
14
|
+
migrations.AlterUniqueTogether(
|
|
15
|
+
name='credential',
|
|
16
|
+
unique_together=set(),
|
|
17
|
+
),
|
|
18
|
+
migrations.AlterUniqueTogether(
|
|
19
|
+
name='credentialconfiguration',
|
|
20
|
+
unique_together=set(),
|
|
21
|
+
),
|
|
22
|
+
|
|
23
|
+
migrations.RenameField(
|
|
24
|
+
model_name='credential',
|
|
25
|
+
old_name='course_id',
|
|
26
|
+
new_name='learning_context_key',
|
|
27
|
+
),
|
|
28
|
+
migrations.RenameField(
|
|
29
|
+
model_name='credentialconfiguration',
|
|
30
|
+
old_name='course_id',
|
|
31
|
+
new_name='learning_context_key',
|
|
32
|
+
),
|
|
33
|
+
|
|
34
|
+
migrations.AlterField(
|
|
35
|
+
model_name='credential',
|
|
36
|
+
name='learning_context_key',
|
|
37
|
+
field=opaque_keys.edx.django.models.LearningContextKeyField(
|
|
38
|
+
help_text='ID of a learning context (e.g., a course or a Learning Path) for which the credential was issued',
|
|
39
|
+
max_length=255
|
|
40
|
+
),
|
|
41
|
+
),
|
|
42
|
+
migrations.AlterField(
|
|
43
|
+
model_name='credentialconfiguration',
|
|
44
|
+
name='learning_context_key',
|
|
45
|
+
field=opaque_keys.edx.django.models.LearningContextKeyField(
|
|
46
|
+
help_text='ID of a learning context (e.g., a course or a Learning Path).',
|
|
47
|
+
max_length=255
|
|
48
|
+
),
|
|
49
|
+
),
|
|
50
|
+
|
|
51
|
+
migrations.AlterUniqueTogether(
|
|
52
|
+
name='credential',
|
|
53
|
+
unique_together={('user_id', 'learning_context_key', 'credential_type')},
|
|
54
|
+
),
|
|
55
|
+
migrations.AlterUniqueTogether(
|
|
56
|
+
name='credentialconfiguration',
|
|
57
|
+
unique_together={('learning_context_key', 'credential_type')},
|
|
58
|
+
),
|
|
59
|
+
]
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
from django.db import migrations
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
def update_function_references_and_json_keys(apps, schema_editor):
|
|
5
|
+
"""
|
|
6
|
+
Update both function references and JSON field keys:
|
|
7
|
+
1. Replace 'openedx_certificates' prefix with 'learning_credentials'.
|
|
8
|
+
2. Replace 'retrieve_course_completions' with 'retrieve_completions'.
|
|
9
|
+
3. Replace JSON keys 'course_name*' with 'context_name*'.
|
|
10
|
+
4. Replace the task path in PeriodicTask records.
|
|
11
|
+
"""
|
|
12
|
+
CredentialType = apps.get_model('learning_credentials', 'CredentialType')
|
|
13
|
+
CredentialConfiguration = apps.get_model('learning_credentials', 'CredentialConfiguration')
|
|
14
|
+
|
|
15
|
+
for credential_type in CredentialType.objects.all():
|
|
16
|
+
credential_type.retrieval_func = credential_type.retrieval_func.replace(
|
|
17
|
+
'openedx_certificates', 'learning_credentials'
|
|
18
|
+
).replace(
|
|
19
|
+
'retrieve_course_completions', 'retrieve_completions'
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
credential_type.generation_func = credential_type.generation_func.replace(
|
|
23
|
+
'openedx_certificates', 'learning_credentials'
|
|
24
|
+
).replace(
|
|
25
|
+
'generate_pdf_certificate', 'generate_pdf_credential'
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
if credential_type.custom_options:
|
|
29
|
+
if 'course_name' in credential_type.custom_options:
|
|
30
|
+
credential_type.custom_options['context_name'] = credential_type.custom_options.pop('course_name')
|
|
31
|
+
if 'course_name_y' in credential_type.custom_options:
|
|
32
|
+
credential_type.custom_options['context_name_y'] = credential_type.custom_options.pop('course_name_y')
|
|
33
|
+
if 'course_name_color' in credential_type.custom_options:
|
|
34
|
+
credential_type.custom_options['context_name_color'] = credential_type.custom_options.pop('course_name_color')
|
|
35
|
+
|
|
36
|
+
credential_type.save()
|
|
37
|
+
|
|
38
|
+
for config in CredentialConfiguration.objects.all():
|
|
39
|
+
if config.custom_options:
|
|
40
|
+
if 'course_name' in config.custom_options:
|
|
41
|
+
config.custom_options['context_name'] = config.custom_options.pop('course_name')
|
|
42
|
+
if 'course_name_y' in config.custom_options:
|
|
43
|
+
config.custom_options['context_name_y'] = config.custom_options.pop('course_name_y')
|
|
44
|
+
if 'course_name_color' in config.custom_options:
|
|
45
|
+
config.custom_options['context_name_color'] = config.custom_options.pop('course_name_color')
|
|
46
|
+
|
|
47
|
+
if config.periodic_task.task == 'openedx_certificates.tasks.generate_certificates_for_course_task':
|
|
48
|
+
config.periodic_task.task = 'learning_credentials.tasks.generate_credentials_for_config_task'
|
|
49
|
+
config.periodic_task.save()
|
|
50
|
+
|
|
51
|
+
config.save()
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def reverse_function_references_and_json_keys(apps, schema_editor):
|
|
55
|
+
"""Reverse the changes made to function references and JSON keys."""
|
|
56
|
+
CredentialType = apps.get_model('learning_credentials', 'CredentialType')
|
|
57
|
+
CredentialConfiguration = apps.get_model('learning_credentials', 'CredentialConfiguration')
|
|
58
|
+
|
|
59
|
+
for credential_type in CredentialType.objects.all():
|
|
60
|
+
credential_type.retrieval_func = credential_type.retrieval_func.replace(
|
|
61
|
+
'learning_credentials', 'openedx_certificates'
|
|
62
|
+
).replace(
|
|
63
|
+
'retrieve_completions', 'retrieve_course_completions'
|
|
64
|
+
)
|
|
65
|
+
|
|
66
|
+
credential_type.generation_func = credential_type.generation_func.replace(
|
|
67
|
+
'learning_credentials', 'openedx_certificates'
|
|
68
|
+
).replace(
|
|
69
|
+
'generate_pdf_credential', 'generate_pdf_certificate'
|
|
70
|
+
)
|
|
71
|
+
|
|
72
|
+
if credential_type.custom_options:
|
|
73
|
+
if 'context_name' in credential_type.custom_options:
|
|
74
|
+
credential_type.custom_options['course_name'] = credential_type.custom_options.pop('context_name')
|
|
75
|
+
if 'context_name_y' in credential_type.custom_options:
|
|
76
|
+
credential_type.custom_options['course_name_y'] = credential_type.custom_options.pop('context_name_y')
|
|
77
|
+
if 'context_name_color' in credential_type.custom_options:
|
|
78
|
+
credential_type.custom_options['course_name_color'] = credential_type.custom_options.pop('context_name_color')
|
|
79
|
+
|
|
80
|
+
credential_type.save()
|
|
81
|
+
|
|
82
|
+
for config in CredentialConfiguration.objects.all():
|
|
83
|
+
if config.custom_options:
|
|
84
|
+
if 'context_name' in config.custom_options:
|
|
85
|
+
config.custom_options['course_name'] = config.custom_options.pop('context_name')
|
|
86
|
+
if 'context_name_y' in config.custom_options:
|
|
87
|
+
config.custom_options['course_name_y'] = config.custom_options.pop('context_name_y')
|
|
88
|
+
if 'context_name_color' in config.custom_options:
|
|
89
|
+
config.custom_options['course_name_color'] = config.custom_options.pop('context_name_color')
|
|
90
|
+
|
|
91
|
+
if config.periodic_task.task == 'learning_credentials.tasks.generate_credentials_for_config_task':
|
|
92
|
+
config.periodic_task.task = 'openedx_certificates.tasks.generate_certificates_for_course_task'
|
|
93
|
+
config.periodic_task.save()
|
|
94
|
+
|
|
95
|
+
config.save()
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
class Migration(migrations.Migration):
|
|
99
|
+
|
|
100
|
+
dependencies = [
|
|
101
|
+
('learning_credentials', '0004_replace_course_keys_with_learning_context_keys'),
|
|
102
|
+
]
|
|
103
|
+
|
|
104
|
+
operations = [
|
|
105
|
+
migrations.RunPython(update_function_references_and_json_keys, reverse_function_references_and_json_keys),
|
|
106
|
+
]
|
|
File without changes
|