Skip to content

Commit

Permalink
#1238: Revision history for morphology updates
Browse files Browse the repository at this point in the history
Repaired error reporting for morphology input, hopefully.
  • Loading branch information
susanodd committed May 30, 2024
1 parent 0b052ea commit f7037ee
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
19 changes: 19 additions & 0 deletions signbank/dictionary/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -2582,6 +2582,12 @@ def gloss_revision_history(request,gloss_pk):
for revision in GlossRevision.objects.filter(gloss=gloss):
if revision.field_name in Gloss.get_field_names():
revision_verbose_fieldname = _(Gloss.get_field(revision.field_name).verbose_name)
elif revision.field_name == 'sequential_morphology':
revision_verbose_fieldname = gettext("Sequential Morphology")
elif revision.field_name == 'simultaneous_morphology':
revision_verbose_fieldname = gettext("Simultaneous Morphology")
elif revision.field_name == 'blend_morphology':
revision_verbose_fieldname = gettext("Blend Morphology")
else:
revision_verbose_fieldname = _(revision.field_name)

Expand Down Expand Up @@ -2625,6 +2631,19 @@ def gloss_revision_history(request,gloss_pk):
# this translation exists in the interface of Gloss Edit View
add_command = str(_('Update'))
field_name_qualification = ' (' + add_command + ')'
elif revision.field_name in ['sequential_morphology', 'simultaneous_morphology', 'blend_morphology']:
if revision.old_value and not revision.new_value:
# this translation exists in the interface of Gloss Edit View
delete_command = str(_('Delete'))
field_name_qualification = ' (' + delete_command + ')'
elif revision.new_value and not revision.old_value:
# this translation exists in the interface of Gloss Edit View
add_command = str(_('Create'))
field_name_qualification = ' (' + add_command + ')'
else:
# this translation exists in the interface of Gloss Edit View
add_command = str(_('Update'))
field_name_qualification = ' (' + add_command + ')'
else:
field_name_qualification = ' (' + revision.field_name + ')'
revision_dict = {
Expand Down
10 changes: 5 additions & 5 deletions signbank/gloss_morphology_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,26 +95,26 @@ def gloss_update(gloss, update_fields_dict, language_code):

def detect_type_related_problems_for_gloss_update(gloss, changes, language_code):
internal_to_human_readable = internal_morphology_to_human_readable(language_code)
errors = dict()
errors_per_field = dict()
for field, (original_value, new_value) in changes.items():
if field == 'sequential_morphology':
(found, not_found, errors) = check_existence_sequential_morphology(gloss, new_value)
if len(errors):
morphology_field = internal_to_human_readable[field]
errors[morphology_field] = errors
errors_per_field[morphology_field] = errors
elif field == 'simultaneous_morphology':
new_human_value_list = [v.strip() for v in new_value.split(',')]
(checked_new_human_value, errors) = check_existence_simultaneous_morphology(gloss, new_human_value_list)
if len(errors):
morphology_field = internal_to_human_readable[field]
errors[morphology_field] = errors
errors_per_field[morphology_field] = errors
elif field == 'blend_morphology':
new_human_value_list = [v.strip() for v in new_value.split(',')]
(checked_new_human_value, errors) = check_existence_blend_morphology(gloss, new_human_value_list)
if len(errors):
morphology_field = internal_to_human_readable[field]
errors[morphology_field] = errors
return errors
errors_per_field[morphology_field] = errors
return errors_per_field


def gloss_update_do_changes(user, gloss, fields_to_update, language_code):
Expand Down

0 comments on commit f7037ee

Please sign in to comment.