diff --git a/media/js/glosses_toggle_edit.js b/media/js/glosses_toggle_edit.js index 4eacd5614..460aff8ce 100644 --- a/media/js/glosses_toggle_edit.js +++ b/media/js/glosses_toggle_edit.js @@ -133,6 +133,23 @@ function toggle_handCh(data) { buttonCell.attr('value', button_contents); } +function toggle_relatArtic(data) { + if ($.isEmptyObject(data)) { + return; + }; + var glossid = data.glossid; + var relatArtic = data.relatArtic; + var hCell = $("#relatArtic_cell_"+glossid); + $(hCell).empty(); + var cell = ""+relatArtic+""; + hCell.html(cell); + + var button_lookup = '#button_' + glossid + '_relatArtic'; + var buttonCell = $(button_lookup); + var button_contents = similar_gloss_fields_labels['relatArtic'] + ': ' + relatArtic; + buttonCell.attr('value', button_contents); +} + function toggle_locprim(data) { if ($.isEmptyObject(data)) { return; @@ -434,6 +451,20 @@ $(document).ready(function() { }); }); + $('.quick_relatArtic').click(function(e) + { + e.preventDefault(); + var glossid = $(this).attr('value'); + var relatArtic = $(this).attr("data-relatArtic"); + $.ajax({ + url : url + "/dictionary/update/toggle_relatArtic/" + glossid + "/" + relatArtic, + type: 'POST', + data: { 'csrfmiddlewaretoken': csrf_token }, + datatype: "json", + success : toggle_relatArtic + }); + }); + $('.quick_locprim').click(function(e) { e.preventDefault(); diff --git a/signbank/dictionary/adminviews.py b/signbank/dictionary/adminviews.py index 3397ee52f..21e8d0121 100755 --- a/signbank/dictionary/adminviews.py +++ b/signbank/dictionary/adminviews.py @@ -6539,7 +6539,7 @@ def get_context_data(self, **kwargs): context['available_tags'] = [tag for tag in Tag.objects.all()] - similar_gloss_fields = ['handedness', 'domhndsh', 'subhndsh', 'handCh', 'locprim', + similar_gloss_fields = ['handedness', 'domhndsh', 'subhndsh', 'handCh', 'relatArtic', 'locprim', 'movSh', 'repeat', 'altern'] context['similar_gloss_fields'] = json.dumps(similar_gloss_fields) similar_gloss_fields_labels = {} @@ -6568,6 +6568,12 @@ def get_context_data(self, **kwargs): field='HandshapeChange', machine_value__gt=1).order_by('name')] context['available_handCh'] = available_handCh + available_relatArtic = [fc for fc in FieldChoice.objects.filter( + field='RelatArtic', machine_value__in=[0, 1]).order_by('machine_value')] + available_relatArtic += [fc for fc in FieldChoice.objects.filter( + field='RelatArtic', machine_value__gt=1).order_by('name')] + context['available_relatArtic'] = available_relatArtic + available_locprim = [fc for fc in FieldChoice.objects.filter( field='Location', machine_value__in=[0, 1]).order_by('machine_value')] available_locprim += [fc for fc in FieldChoice.objects.filter( diff --git a/signbank/dictionary/templates/dictionary/admin_batch_edit_view.html b/signbank/dictionary/templates/dictionary/admin_batch_edit_view.html index b6c9b8fde..fc8f3af45 100644 --- a/signbank/dictionary/templates/dictionary/admin_batch_edit_view.html +++ b/signbank/dictionary/templates/dictionary/admin_batch_edit_view.html @@ -500,6 +500,14 @@

{% trans "Batch Edit" %}

+ + {% trans "Relation between Articulators" %} + +
{% if gloss.relatArtic %}{{gloss.relatArtic.name}}{% endif %} +
+ + {% trans "Location" %} @@ -539,7 +547,7 @@

{% trans "Batch Edit" %}

{% trans "Text Fields" %} + data-target='#toggle_language_fields_panel_{{gloss.id}}'>{% trans "TEXT FIELDS" %}
@@ -569,7 +577,7 @@

{% trans "Batch Edit" %}

{% trans "Tags" %} + data-target='#toggle_tags_panel_{{gloss.id}}'>{% trans "TAGS" %}
@@ -587,7 +595,7 @@

{% trans "Batch Edit" %}

{% trans "Phonology" %} + data-target='#toggle_phonology_panel_{{gloss.id}}'>{% trans "PHONOLOGY" %}
@@ -666,6 +674,25 @@

{% trans "Batch Edit" %}

+
+
{% trans "Relation between Articulators" %} +
+
+
+

+ {% for wc in available_relatArtic %} + + {% endfor %} +

+
+
+
+
{% trans "Location" %} diff --git a/signbank/dictionary/update.py b/signbank/dictionary/update.py index c0330594d..bdcde1342 100755 --- a/signbank/dictionary/update.py +++ b/signbank/dictionary/update.py @@ -38,12 +38,7 @@ mapping_edit_senses_matrix, mapping_toggle_sense_tag from signbank.dictionary.consistency_senses import reorder_translations from signbank.dictionary.related_objects import gloss_related_objects, morpheme_related_objects -from signbank.dictionary.update_glosses import (mapping_toggle_tag, mapping_toggle_semanticfield, - mapping_toggle_wordclass, mapping_toggle_namedentity, - mapping_toggle_handedness, mapping_toggle_domhndsh, - mapping_toggle_subhndsh, mapping_toggle_handCh, mapping_toggle_locprim, - mapping_toggle_movSh, - batch_edit_create_sense, mapping_toggle_repeat, mapping_toggle_altern) +from signbank.dictionary.update_glosses import * from signbank.dictionary.batch_edit import batch_edit_update_gloss @@ -3582,6 +3577,19 @@ def toggle_handCh(request, glossid, handCh): return JsonResponse(result) +@permission_required('dictionary.change_gloss') +def toggle_relatArtic(request, glossid, relatArtic): + + gloss = Gloss.objects.filter(id=glossid).first() + + if not okay_to_update_gloss(request, gloss): + return JsonResponse({}) + + result = mapping_toggle_relatArtic(request, gloss, relatArtic) + + return JsonResponse(result) + + @permission_required('dictionary.change_gloss') def toggle_locprim(request, glossid, locprim): diff --git a/signbank/dictionary/update_glosses.py b/signbank/dictionary/update_glosses.py index da286bad3..b99a35c1b 100644 --- a/signbank/dictionary/update_glosses.py +++ b/signbank/dictionary/update_glosses.py @@ -308,6 +308,44 @@ def mapping_toggle_handCh(request, gloss, handCh): return result +@permission_required('dictionary.change_gloss') +def mapping_toggle_relatArtic(request, gloss, relatArtic): + + try: + relatArtic_machine_value = int(relatArtic) + except TypeError: + return {} + + empty_relatArtic = FieldChoice.objects.get(field='RelatArtic', machine_value=0) + new_relatArtic = FieldChoice.objects.filter(field='RelatArtic', machine_value=relatArtic_machine_value).first() + + if not new_relatArtic: + # if the word class does not exist, set it to empty + relatArtic_machine_value = 0 + new_relatArtic = empty_relatArtic + + original_relatArtic = gloss.relatArtic.name if gloss.relatArtic else '-' + + with atomic(): + if not gloss.relatArtic: + gloss.relatArtic = new_relatArtic + elif gloss.relatArtic.machine_value != relatArtic_machine_value: + gloss.relatArtic = new_relatArtic + else: + gloss.relatArtic = empty_relatArtic + new_relatArtic = empty_relatArtic + gloss.save() + + add_gloss_update_to_revision_history(request.user, gloss, 'relatArtic', original_relatArtic, new_relatArtic.name) + + result = dict() + result['glossid'] = str(gloss.id) + newvalue = gloss.relatArtic.name + result['relatArtic'] = newvalue + + return result + + @permission_required('dictionary.change_gloss') def mapping_toggle_locprim(request, gloss, locprim): diff --git a/signbank/dictionary/urls.py b/signbank/dictionary/urls.py index 18f52cae2..21d1365e0 100755 --- a/signbank/dictionary/urls.py +++ b/signbank/dictionary/urls.py @@ -102,6 +102,9 @@ re_path(r'^update/toggle_handCh/(?P\d+)/(?P.*)$', signbank.dictionary.update.toggle_handCh, name='toggle_handCh'), + re_path(r'^update/toggle_relatArtic/(?P\d+)/(?P.*)$', + signbank.dictionary.update.toggle_relatArtic, + name='toggle_relatArtic'), re_path(r'^update/toggle_locprim/(?P\d+)/(?P.*)$', signbank.dictionary.update.toggle_locprim, name='toggle_locprim'),