Skip to content

Commit 9af2129

Browse files
committed
Merge branch 'hotfix/19.29.1'
2 parents 12539c1 + 7d66e22 commit 9af2129

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

api/registrations/serializers.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,8 @@ def anonymize_registered_meta(self, obj):
394394
for question in page['questions']:
395395
if question['title'] in ANONYMIZED_TITLES and meta_values.get(question.get('qid')):
396396
del meta_values[question['qid']]
397+
398+
strip_registered_meta_comments(meta_values)
397399
return meta_values
398400

399401
def check_admin_perms(self, registration, user, validated_data):
@@ -619,3 +621,33 @@ class RegistrationStorageProviderSerializer(NodeStorageProviderSerializer):
619621
kind='folder',
620622
never_embed=True,
621623
)
624+
625+
def strip_registered_meta_comments(messy_dict_or_list):
626+
"""Removes Prereg Challenge comments from a given `registered_meta` dict.
627+
628+
Nothing that uses APIv2 needs these comments:
629+
```
630+
{
631+
"registered_meta": {
632+
"q20": {
633+
"comments": [ ... ], <~~~ THIS
634+
"value": "foo",
635+
"extra": []
636+
},
637+
}
638+
}
639+
```
640+
"""
641+
if isinstance(messy_dict_or_list, list):
642+
for obj in messy_dict_or_list:
643+
strip_registered_meta_comments(obj)
644+
elif isinstance(messy_dict_or_list, dict):
645+
comments = messy_dict_or_list.get('comments', None)
646+
647+
# some schemas have a question named "comments" -- those will have a dict value
648+
if isinstance(comments, list):
649+
del messy_dict_or_list['comments']
650+
651+
# dig into the deeply nested structure
652+
for nested_obj in messy_dict_or_list.values():
653+
strip_registered_meta_comments(nested_obj)

0 commit comments

Comments
 (0)