learning-credentials 0.4.1rc4__py3-none-any.whl → 0.4.1rc6__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/generators.py +3 -2
- learning_credentials/models.py +21 -2
- {learning_credentials-0.4.1rc4.dist-info → learning_credentials-0.4.1rc6.dist-info}/METADATA +1 -1
- {learning_credentials-0.4.1rc4.dist-info → learning_credentials-0.4.1rc6.dist-info}/RECORD +8 -8
- {learning_credentials-0.4.1rc4.dist-info → learning_credentials-0.4.1rc6.dist-info}/WHEEL +0 -0
- {learning_credentials-0.4.1rc4.dist-info → learning_credentials-0.4.1rc6.dist-info}/entry_points.txt +0 -0
- {learning_credentials-0.4.1rc4.dist-info → learning_credentials-0.4.1rc6.dist-info}/licenses/LICENSE.txt +0 -0
- {learning_credentials-0.4.1rc4.dist-info → learning_credentials-0.4.1rc6.dist-info}/top_level.txt +0 -0
|
@@ -378,12 +378,13 @@ def generate_pdf_credential(
|
|
|
378
378
|
|
|
379
379
|
# Handle multiline context name.
|
|
380
380
|
context_name = get_learning_context_name(learning_context_key)
|
|
381
|
+
custom_context_name = ''
|
|
381
382
|
custom_context_text_element = options.get('text_elements', {}).get('context', {})
|
|
382
383
|
if isinstance(custom_context_text_element, dict):
|
|
383
|
-
|
|
384
|
+
custom_context_name = custom_context_text_element.get('text', '')
|
|
384
385
|
|
|
385
386
|
template_path = options.get('template')
|
|
386
|
-
if '\n' in context_name:
|
|
387
|
+
if '\n' in context_name or '\n' in custom_context_name:
|
|
387
388
|
template_path = options.get('template_multiline', template_path)
|
|
388
389
|
|
|
389
390
|
if not template_path:
|
learning_credentials/models.py
CHANGED
|
@@ -33,6 +33,25 @@ if TYPE_CHECKING: # pragma: no cover
|
|
|
33
33
|
log = logging.getLogger(__name__)
|
|
34
34
|
|
|
35
35
|
|
|
36
|
+
def _deep_merge(base: dict, override: dict) -> dict:
|
|
37
|
+
"""
|
|
38
|
+
Deep merge two dictionaries.
|
|
39
|
+
|
|
40
|
+
Values from `override` take precedence. Nested dictionaries are merged recursively.
|
|
41
|
+
|
|
42
|
+
:param base: The base dictionary.
|
|
43
|
+
:param override: The dictionary with overriding values.
|
|
44
|
+
:return: A new dictionary with merged values.
|
|
45
|
+
"""
|
|
46
|
+
result = base.copy()
|
|
47
|
+
for key, value in override.items():
|
|
48
|
+
if key in result and isinstance(result[key], dict) and isinstance(value, dict):
|
|
49
|
+
result[key] = _deep_merge(result[key], value)
|
|
50
|
+
else:
|
|
51
|
+
result[key] = value
|
|
52
|
+
return result
|
|
53
|
+
|
|
54
|
+
|
|
36
55
|
class CredentialType(TimeStampedModel):
|
|
37
56
|
"""
|
|
38
57
|
Model to store global credential configurations for each type.
|
|
@@ -176,7 +195,7 @@ class CredentialConfiguration(TimeStampedModel):
|
|
|
176
195
|
module = import_module(module_path)
|
|
177
196
|
func = getattr(module, func_name)
|
|
178
197
|
|
|
179
|
-
custom_options =
|
|
198
|
+
custom_options = _deep_merge(self.credential_type.custom_options, self.custom_options)
|
|
180
199
|
return func(self.learning_context_key, custom_options)
|
|
181
200
|
|
|
182
201
|
def generate_credential_for_user(self, user_id: int, celery_task_id: int = 0):
|
|
@@ -195,7 +214,7 @@ class CredentialConfiguration(TimeStampedModel):
|
|
|
195
214
|
# Use the name from the profile if it is not empty. Otherwise, use the first and last name.
|
|
196
215
|
# We check if the profile exists because it may not exist in some cases (e.g., when a User is created manually).
|
|
197
216
|
user_full_name = getattr(getattr(user, 'profile', None), 'name', f"{user.first_name} {user.last_name}")
|
|
198
|
-
custom_options =
|
|
217
|
+
custom_options = _deep_merge(self.credential_type.custom_options, self.custom_options)
|
|
199
218
|
|
|
200
219
|
credential, _ = Credential.objects.update_or_create(
|
|
201
220
|
user_id=user_id,
|
|
@@ -3,8 +3,8 @@ learning_credentials/admin.py,sha256=ynK3tVJwLsIeV7Jk66t1FAVyVsU1G-KRIAdRkycVTmA
|
|
|
3
3
|
learning_credentials/apps.py,sha256=trdQxe-JRhUdUaOQoQWiGL1sn6I1sfDiTvdCwy8yGuw,1037
|
|
4
4
|
learning_credentials/compat.py,sha256=bTAB6bTh99ZyhUqOsDtM_BuIPzFxCjySFtfvc-_fCd4,4731
|
|
5
5
|
learning_credentials/exceptions.py,sha256=UaqBVXFMWR2Iob7_LMb3j4NNVmWQFAgLi_MNMRUvGsI,290
|
|
6
|
-
learning_credentials/generators.py,sha256=
|
|
7
|
-
learning_credentials/models.py,sha256=
|
|
6
|
+
learning_credentials/generators.py,sha256=gaw3zoEzVhSjo96QM6Q6K70e_iK44LxCuQIQ05p7lP0,14895
|
|
7
|
+
learning_credentials/models.py,sha256=t_FahXhxa6IsIQl2nqzgcE4XVGdyb5jVGXMLWjJd5cI,16679
|
|
8
8
|
learning_credentials/processors.py,sha256=LkdjmkLBnXc9qeMcksB1T8AQ5ZhYaECyQO__KfHB_aU,15212
|
|
9
9
|
learning_credentials/tasks.py,sha256=byoFEUvN_ayVaU5K5SlEiA7vu9BRPaSSmKnB9g5toec,1927
|
|
10
10
|
learning_credentials/urls.py,sha256=gO_c930rzMylP-riQ9SGHXH9JIMF7ajySDT2Tc-E8x4,188
|
|
@@ -32,9 +32,9 @@ learning_credentials/templates/learning_credentials/edx_ace/certificate_generate
|
|
|
32
32
|
learning_credentials/templates/learning_credentials/edx_ace/certificate_generated/email/from_name.txt,sha256=-n8tjPSwfwAfeOSZ1WhcCTrpOah4VswzMZ5mh63Pxow,20
|
|
33
33
|
learning_credentials/templates/learning_credentials/edx_ace/certificate_generated/email/head.html,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
34
34
|
learning_credentials/templates/learning_credentials/edx_ace/certificate_generated/email/subject.txt,sha256=S7Hc5T_sZSsSBXm5_H5HBNNv16Ohl0oZn0nVqqeWL0g,132
|
|
35
|
-
learning_credentials-0.4.
|
|
36
|
-
learning_credentials-0.4.
|
|
37
|
-
learning_credentials-0.4.
|
|
38
|
-
learning_credentials-0.4.
|
|
39
|
-
learning_credentials-0.4.
|
|
40
|
-
learning_credentials-0.4.
|
|
35
|
+
learning_credentials-0.4.1rc6.dist-info/licenses/LICENSE.txt,sha256=GDpsPnW_1NKhPvZpZL9imz25P2nIpbwJPEhrlq4vPAU,34523
|
|
36
|
+
learning_credentials-0.4.1rc6.dist-info/METADATA,sha256=_3vW2RqkLIUwho5al3zefc877eWnW9qLPOB-ZjsOvDg,8258
|
|
37
|
+
learning_credentials-0.4.1rc6.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
38
|
+
learning_credentials-0.4.1rc6.dist-info/entry_points.txt,sha256=hHqqLUEdzAN24v5OGBX9Fr-wh3ATDPjQjByKz03eC2Y,91
|
|
39
|
+
learning_credentials-0.4.1rc6.dist-info/top_level.txt,sha256=Ce-4_leZe_nny7CpmkeRiemcDV6jIHpIvLjlcQBuf18,21
|
|
40
|
+
learning_credentials-0.4.1rc6.dist-info/RECORD,,
|
|
File without changes
|
{learning_credentials-0.4.1rc4.dist-info → learning_credentials-0.4.1rc6.dist-info}/entry_points.txt
RENAMED
|
File without changes
|
|
File without changes
|
{learning_credentials-0.4.1rc4.dist-info → learning_credentials-0.4.1rc6.dist-info}/top_level.txt
RENAMED
|
File without changes
|