From c14289cb51a960ea158a6f69c8292232674e857a Mon Sep 17 00:00:00 2001 From: susanodd Date: Wed, 10 Jul 2024 12:49:28 +0200 Subject: [PATCH] #1268: Added handshape change to phonology. --- media/js/glosses_toggle_edit.js | 32 ++++++++++++++++ signbank/dictionary/adminviews.py | 9 ++++- .../dictionary/admin_batch_edit_view.html | 28 ++++++++++++++ signbank/dictionary/update.py | 16 +++++++- signbank/dictionary/update_glosses.py | 38 +++++++++++++++++++ signbank/dictionary/urls.py | 3 ++ 6 files changed, 124 insertions(+), 2 deletions(-) diff --git a/media/js/glosses_toggle_edit.js b/media/js/glosses_toggle_edit.js index a5a1644e..4eacd561 100644 --- a/media/js/glosses_toggle_edit.js +++ b/media/js/glosses_toggle_edit.js @@ -116,6 +116,23 @@ function toggle_subhndsh(data) { buttonCell.attr('value', button_contents); } +function toggle_handCh(data) { + if ($.isEmptyObject(data)) { + return; + }; + var glossid = data.glossid; + var handCh = data.handCh; + var hCell = $("#handCh_cell_"+glossid); + $(hCell).empty(); + var cell = ""+handCh+""; + hCell.html(cell); + + var button_lookup = '#button_' + glossid + '_handCh'; + var buttonCell = $(button_lookup); + var button_contents = similar_gloss_fields_labels['handCh'] + ': ' + handCh; + buttonCell.attr('value', button_contents); +} + function toggle_locprim(data) { if ($.isEmptyObject(data)) { return; @@ -402,6 +419,21 @@ $(document).ready(function() { success : toggle_subhndsh }); }); + + $('.quick_handCh').click(function(e) + { + e.preventDefault(); + var glossid = $(this).attr('value'); + var handCh = $(this).attr("data-handCh"); + $.ajax({ + url : url + "/dictionary/update/toggle_handCh/" + glossid + "/" + handCh, + type: 'POST', + data: { 'csrfmiddlewaretoken': csrf_token }, + datatype: "json", + success : toggle_handCh + }); + }); + $('.quick_locprim').click(function(e) { e.preventDefault(); diff --git a/signbank/dictionary/adminviews.py b/signbank/dictionary/adminviews.py index 4a506ad7..3397ee52 100755 --- a/signbank/dictionary/adminviews.py +++ b/signbank/dictionary/adminviews.py @@ -6539,7 +6539,8 @@ def get_context_data(self, **kwargs): context['available_tags'] = [tag for tag in Tag.objects.all()] - similar_gloss_fields = ['handedness', 'domhndsh', 'subhndsh', 'locprim', 'movSh', 'repeat', 'altern'] + similar_gloss_fields = ['handedness', 'domhndsh', 'subhndsh', 'handCh', 'locprim', + 'movSh', 'repeat', 'altern'] context['similar_gloss_fields'] = json.dumps(similar_gloss_fields) similar_gloss_fields_labels = {} for field in similar_gloss_fields: @@ -6561,6 +6562,12 @@ def get_context_data(self, **kwargs): machine_value__gt=1).order_by('name')] context['available_handshape'] = available_handshape + available_handCh = [fc for fc in FieldChoice.objects.filter( + field='HandshapeChange', machine_value__in=[0, 1]).order_by('machine_value')] + available_handCh += [fc for fc in FieldChoice.objects.filter( + field='HandshapeChange', machine_value__gt=1).order_by('name')] + context['available_handCh'] = available_handCh + 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 669ab66e..b6c9b8fd 100644 --- a/signbank/dictionary/templates/dictionary/admin_batch_edit_view.html +++ b/signbank/dictionary/templates/dictionary/admin_batch_edit_view.html @@ -492,6 +492,14 @@

{% trans "Batch Edit" %}

+ + {% trans "Handshape Change" %} + +
{% if gloss.handCh %}{{gloss.handCh.name}}{% endif %} +
+ + {% trans "Location" %} @@ -639,6 +647,25 @@

{% trans "Batch Edit" %}

+
+
{% trans "Handshape Change" %} +
+
+
+

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

+
+
+
+
{% trans "Location" %} @@ -656,6 +683,7 @@

{% trans "Batch Edit" %}

+
\d+)/(?P.*)$', signbank.dictionary.update.toggle_subhndsh, name='toggle_subhndsh'), + re_path(r'^update/toggle_handCh/(?P\d+)/(?P.*)$', + signbank.dictionary.update.toggle_handCh, + name='toggle_handCh'), re_path(r'^update/toggle_locprim/(?P\d+)/(?P.*)$', signbank.dictionary.update.toggle_locprim, name='toggle_locprim'),