diff --git a/media/js/glosses_toggle_edit.js b/media/js/glosses_toggle_edit.js index fc2a76bd..0f5f9e3c 100644 --- a/media/js/glosses_toggle_edit.js +++ b/media/js/glosses_toggle_edit.js @@ -269,6 +269,23 @@ function toggle_relOriMov(data) { buttonCell.attr('value', button_contents); } +function toggle_relOriLoc(data) { + if ($.isEmptyObject(data)) { + return; + }; + var glossid = data.glossid; + var relOriLoc = data.relOriLoc; + var hCell = $("#relOriLoc_cell_"+glossid); + $(hCell).empty(); + var cell = ""+relOriLoc+""; + hCell.html(cell); + + var button_lookup = '#button_' + glossid + '_relOriLoc'; + var buttonCell = $(button_lookup); + var button_contents = similar_gloss_fields_labels['relOriLoc'] + ': ' + relOriLoc; + buttonCell.attr('value', button_contents); +} + function toggle_create_sense(data) { if ($.isEmptyObject(data)) { return; @@ -614,6 +631,20 @@ $(document).ready(function() { }); }); + $('.quick_relOriLoc').click(function(e) + { + e.preventDefault(); + var glossid = $(this).attr('value'); + var relOriLoc = $(this).attr("data-relOriLoc"); + $.ajax({ + url : url + "/dictionary/update/toggle_relOriLoc/" + glossid + "/" + relOriLoc, + type: 'POST', + data: { 'csrfmiddlewaretoken': csrf_token }, + datatype: "json", + success : toggle_relOriLoc + }); + }); + $('.quick_create_sense').click(function(e) { e.preventDefault(); diff --git a/signbank/dictionary/adminviews.py b/signbank/dictionary/adminviews.py index c72b7fe1..0fb724d3 100755 --- a/signbank/dictionary/adminviews.py +++ b/signbank/dictionary/adminviews.py @@ -6540,7 +6540,7 @@ def get_context_data(self, **kwargs): context['available_tags'] = [tag for tag in Tag.objects.all()] similar_gloss_fields = ['handedness', 'domhndsh', 'subhndsh', 'handCh', 'relatArtic', 'locprim', - 'contType', 'movSh', 'movDir', 'repeat', 'altern', 'relOriMov'] + 'contType', 'movSh', 'movDir', 'repeat', 'altern', 'relOriMov', 'relOriLoc'] context['similar_gloss_fields'] = json.dumps(similar_gloss_fields) similar_gloss_fields_labels = {} for field in similar_gloss_fields: @@ -6607,7 +6607,13 @@ def get_context_data(self, **kwargs): available_relOriMov += [fc for fc in FieldChoice.objects.filter( field='RelOriMov', machine_value__gt=1).order_by('name')] context['available_relOriMov'] = available_relOriMov - + + available_relOriLoc = [fc for fc in FieldChoice.objects.filter( + field='RelOriLoc', machine_value__in=[0, 1]).order_by('machine_value')] + available_relOriLoc += [fc for fc in FieldChoice.objects.filter( + field='RelOriLoc', machine_value__gt=1).order_by('name')] + context['available_relOriLoc'] = available_relOriLoc + context['query_parameters'] = json.dumps(self.query_parameters) query_parameters_keys = list(self.query_parameters.keys()) context['query_parameters_keys'] = json.dumps(query_parameters_keys) diff --git a/signbank/dictionary/templates/dictionary/admin_batch_edit_view.html b/signbank/dictionary/templates/dictionary/admin_batch_edit_view.html index dad3ad6b..3c0fe40a 100644 --- a/signbank/dictionary/templates/dictionary/admin_batch_edit_view.html +++ b/signbank/dictionary/templates/dictionary/admin_batch_edit_view.html @@ -570,15 +570,23 @@

{% trans "Batch Edit" %}

+ + {% trans "Relative Orientation: Location" %} + +
{% if gloss.relOriLoc %}{{gloss.relOriLoc.name}}{% endif %} +
+ + -
+
-
{% trans "TEXT FIELDS" %}
@@ -608,7 +616,7 @@

{% trans "Batch Edit" %}

-
{% trans "TAGS" %}
@@ -626,13 +634,13 @@

{% trans "Batch Edit" %}

-
{% trans "PHONOLOGY" %}
-
+
-
{% trans "Handedness" %}
@@ -650,7 +658,7 @@

{% trans "Batch Edit" %}

-
{% trans "Strong Hand" %}
@@ -669,7 +677,7 @@

{% trans "Batch Edit" %}

-
{% trans "Weak Hand" %}
@@ -688,7 +696,7 @@

{% trans "Batch Edit" %}

-
{% trans "Handshape Change" %}
@@ -707,7 +715,7 @@

{% trans "Batch Edit" %}

-
{% trans "Relation between Articulators" %}
@@ -726,7 +734,7 @@

{% trans "Batch Edit" %}

-
{% trans "Location" %}
@@ -745,7 +753,7 @@

{% trans "Batch Edit" %}

-
{% trans "Contact Type" %}
@@ -764,7 +772,7 @@

{% trans "Batch Edit" %}

-
{% trans "Movement Shape" %}
@@ -783,7 +791,7 @@

{% trans "Batch Edit" %}

-
{% trans "Movement Direction" %}
@@ -802,7 +810,7 @@

{% trans "Batch Edit" %}

-
{% trans "Repeated Movement" %}
@@ -821,7 +829,7 @@

{% trans "Batch Edit" %}

-
{% trans "Alternating Movement" %}
@@ -840,7 +848,7 @@

{% trans "Batch Edit" %}

-
{% trans "Relative Orientation: Movement" %}
@@ -858,6 +866,25 @@

{% trans "Batch Edit" %}

+
+
{% trans "Relative Orientation: Location" %} +
+
+
+

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

+
+
+
+
@@ -898,7 +925,7 @@

{% trans "Batch Edit" %}

class="quick_similarglosses btn actionButton" name='quick_similarglosses_{{gloss.id}}' data-glossid='{{gloss.id}}' style="height:26px;margin-top:10px;" - type="submit" >{% trans "QUERY" %} + type="submit" >{% trans "QUERY EXACT" %} diff --git a/signbank/dictionary/update.py b/signbank/dictionary/update.py index d0f9bfe9..59a40940 100755 --- a/signbank/dictionary/update.py +++ b/signbank/dictionary/update.py @@ -3681,6 +3681,19 @@ def toggle_relOriMov(request, glossid, relOriMov): return JsonResponse(result) +@permission_required('dictionary.change_gloss') +def toggle_relOriLoc(request, glossid, relOriLoc): + + gloss = Gloss.objects.filter(id=glossid).first() + + if not okay_to_update_gloss(request, gloss): + return JsonResponse({}) + + result = mapping_toggle_relOriLoc(request, gloss, relOriLoc) + + return JsonResponse(result) + + @permission_required('dictionary.change_gloss') def toggle_language_fields(request, glossid): diff --git a/signbank/dictionary/update_glosses.py b/signbank/dictionary/update_glosses.py index ad6053cf..fe3715e3 100644 --- a/signbank/dictionary/update_glosses.py +++ b/signbank/dictionary/update_glosses.py @@ -588,6 +588,44 @@ def mapping_toggle_relOriMov(request, gloss, relOriMov): return result +@permission_required('dictionary.change_gloss') +def mapping_toggle_relOriLoc(request, gloss, relOriLoc): + + try: + relOriLoc_machine_value = int(relOriLoc) + except TypeError: + return {} + + empty_relOriLoc = FieldChoice.objects.get(field='RelOriLoc', machine_value=0) + new_relOriLoc = FieldChoice.objects.filter(field='RelOriLoc', machine_value=relOriLoc_machine_value).first() + + if not new_relOriLoc: + # if the word class does not exist, set it to empty + relOriLoc_machine_value = 0 + new_relOriLoc = empty_relOriLoc + + original_relOriLoc = gloss.relOriLoc.name if gloss.relOriLoc else '-' + + with atomic(): + if not gloss.relOriLoc: + gloss.relOriLoc = new_relOriLoc + elif gloss.relOriLoc.machine_value != relOriLoc_machine_value: + gloss.relOriLoc = new_relOriLoc + else: + gloss.relOriLoc = empty_relOriLoc + new_relOriLoc = empty_relOriLoc + gloss.save() + + add_gloss_update_to_revision_history(request.user, gloss, 'relOriLoc', original_relOriLoc, new_relOriLoc.name) + + result = dict() + result['glossid'] = str(gloss.id) + newvalue = gloss.relOriLoc.name + result['relOriLoc'] = newvalue + + return result + + @permission_required('dictionary.change_gloss') def batch_edit_create_sense(request, gloss): diff --git a/signbank/dictionary/urls.py b/signbank/dictionary/urls.py index ac72c2c3..541e90e2 100755 --- a/signbank/dictionary/urls.py +++ b/signbank/dictionary/urls.py @@ -126,6 +126,9 @@ re_path(r'^update/toggle_relOriMov/(?P\d+)/(?P.*)$', signbank.dictionary.update.toggle_relOriMov, name='toggle_relOriMov'), + re_path(r'^update/toggle_relOriLoc/(?P\d+)/(?P.*)$', + signbank.dictionary.update.toggle_relOriLoc, + name='toggle_relOriLoc'), re_path(r'^update/quick_create_sense/(?P\d+)$', signbank.dictionary.update.quick_create_sense,