diff --git a/media/js/glosses_toggle_edit.js b/media/js/glosses_toggle_edit.js
index 397815586..ab546b22a 100644
--- a/media/js/glosses_toggle_edit.js
+++ b/media/js/glosses_toggle_edit.js
@@ -89,6 +89,29 @@ function toggle_domhndsh(data) {
hCell.html(cell);
}
+function toggle_subhndsh(data) {
+ if ($.isEmptyObject(data)) {
+ return;
+ };
+ var glossid = data.glossid;
+ var subhndsh = data.subhndsh;
+ var hCell = $("#subhndsh_cell_"+glossid);
+ $(hCell).empty();
+ var cell = ""+subhndsh+"";
+ hCell.html(cell);
+}
+
+function toggle_locprim(data) {
+ if ($.isEmptyObject(data)) {
+ return;
+ };
+ var glossid = data.glossid;
+ var locprim = data.locprim;
+ var hCell = $("#locprim_cell_"+glossid);
+ $(hCell).empty();
+ var cell = ""+locprim+"";
+ hCell.html(cell);
+}
$(document).ready(function() {
// setup required for Ajax POST
@@ -189,5 +212,32 @@ $(document).ready(function() {
success : toggle_domhndsh
});
});
-
+ $('.quick_subhndsh').click(function(e)
+ {
+ e.preventDefault();
+ console.log('subhndsh');
+ var glossid = $(this).attr('value');
+ var subhndsh = $(this).attr("data-subhndsh");
+ $.ajax({
+ url : url + "/dictionary/update/toggle_subhndsh/" + glossid + "/" + subhndsh,
+ type: 'POST',
+ data: { 'csrfmiddlewaretoken': csrf_token },
+ datatype: "json",
+ success : toggle_subhndsh
+ });
+ });
+ $('.quick_locprim').click(function(e)
+ {
+ e.preventDefault();
+ console.log('locprim');
+ var glossid = $(this).attr('value');
+ var locprim = $(this).attr("data-locprim");
+ $.ajax({
+ url : url + "/dictionary/update/toggle_locprim/" + glossid + "/" + locprim,
+ type: 'POST',
+ data: { 'csrfmiddlewaretoken': csrf_token },
+ datatype: "json",
+ success : toggle_locprim
+ });
+ });
});
diff --git a/signbank/dictionary/adminviews.py b/signbank/dictionary/adminviews.py
index 5d102bb88..74c91d336 100755
--- a/signbank/dictionary/adminviews.py
+++ b/signbank/dictionary/adminviews.py
@@ -6537,6 +6537,9 @@ def get_context_data(self, **kwargs):
context['available_handshape'] = [wc for wc in Handshape.objects.filter(
machine_value__gt=1).order_by('name')]
+ context['available_locprim'] = [h for h in FieldChoice.objects.filter(
+ field='Location', machine_value__gt=1).order_by('name')]
+
# data structures to store the query parameters in order to keep them in the form
context['query_parameters'] = json.dumps(self.query_parameters)
query_parameters_keys = list(self.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 1cdfeda17..11aaf658a 100644
--- a/signbank/dictionary/templates/dictionary/admin_batch_edit_view.html
+++ b/signbank/dictionary/templates/dictionary/admin_batch_edit_view.html
@@ -393,11 +393,7 @@
{% trans "On initial view, prior to searching, recently added glosses are sh
{% endfor %}
{% endwith %}
- {% trans "Handedness" %} |
-
-
-
-
+ {% trans "Handedness" %} |
{% if gloss.handedness %}{{gloss.handedness.name}}{% endif %}
@@ -406,17 +402,30 @@ {% trans "On initial view, prior to searching, recently added glosses are sh
|
- {% trans "Sterke Hand" %} |
-
-
-
-
+ {% trans "Strong Hand" %} |
{% if gloss.domhndsh %}{{gloss.domhndsh.name}}{% endif %}
|
+
+
+ {% trans "Weak Hand" %} |
+
+ {% if gloss.subhndsh %}{{gloss.subhndsh.name}}{% endif %}
+
+ |
+
+
+ {% trans "Location" %} |
+
+ {% if gloss.locprim %}{{gloss.locprim.name}}{% endif %}
+
+ |
+
@@ -459,7 +468,7 @@ {% trans "On initial view, prior to searching, recently added glosses are sh
{% trans "Sterke Hand" %}
+ data-target='#toggle_domhndsh_panel_{{gloss.id}}'>{% trans "Strong Hand" %}
@@ -475,6 +484,45 @@ {% trans "On initial view, prior to searching, recently added glosses are sh
+
+
+ {% trans "Weak Hand" %}
+
+
+
+
+ {% for wc in available_handshape %}
+
+ {% endfor %}
+
+
+
+
+
+
+ {% trans "Location" %}
+
+
+
+
+ {% for wc in available_locprim %}
+
+ {% endfor %}
+
+
+
+
+
|
{% tags_for_object gloss as tag_list %}
diff --git a/signbank/dictionary/update.py b/signbank/dictionary/update.py
index 0f09ac49e..bbd1fdd68 100755
--- a/signbank/dictionary/update.py
+++ b/signbank/dictionary/update.py
@@ -37,7 +37,9 @@
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_wordclass, mapping_toggle_namedentity,
+ mapping_toggle_handedness, mapping_toggle_domhndsh,
+ mapping_toggle_subhndsh, mapping_toggle_locprim)
def show_error(request, translated_message, form, dataset_languages):
@@ -3533,7 +3535,6 @@ def toggle_handedness(request, glossid, handedness):
@permission_required('dictionary.change_gloss')
def toggle_domhndsh(request, glossid, domhndsh):
- print('toggle domhndsh')
if not request.user.is_authenticated:
return JsonResponse({})
@@ -3545,6 +3546,32 @@ def toggle_domhndsh(request, glossid, domhndsh):
return JsonResponse(result)
+@permission_required('dictionary.change_gloss')
+def toggle_subhndsh(request, glossid, subhndsh):
+ if not request.user.is_authenticated:
+ return JsonResponse({})
+
+ if not request.user.has_perm('dictionary.change_gloss'):
+ return JsonResponse({})
+
+ result = mapping_toggle_subhndsh(request, glossid, subhndsh)
+
+ return JsonResponse(result)
+
+
+@permission_required('dictionary.change_gloss')
+def toggle_locprim(request, glossid, locprim):
+ if not request.user.is_authenticated:
+ return JsonResponse({})
+
+ if not request.user.has_perm('dictionary.change_gloss'):
+ return JsonResponse({})
+
+ result = mapping_toggle_locprim(request, glossid, locprim)
+
+ return JsonResponse(result)
+
+
@permission_required('dictionary.change_gloss')
def add_affiliation(request, glossid):
"""View to add an affiliation to a gloss"""
diff --git a/signbank/dictionary/update_glosses.py b/signbank/dictionary/update_glosses.py
index 6dd238caa..e057ca071 100644
--- a/signbank/dictionary/update_glosses.py
+++ b/signbank/dictionary/update_glosses.py
@@ -308,3 +308,98 @@ def mapping_toggle_domhndsh(request, glossid, domhndsh):
return result
+
+@permission_required('dictionary.change_gloss')
+def mapping_toggle_subhndsh(request, glossid, subhndsh):
+ if not request.user.is_authenticated:
+ return {}
+
+ if not request.user.has_perm('dictionary.change_gloss'):
+ return {}
+
+ try:
+ gloss_id = int(glossid)
+ except TypeError:
+ return {}
+
+ gloss = Gloss.objects.filter(id=gloss_id).first()
+
+ if not gloss:
+ return {}
+
+ try:
+ subhndsh_machine_value = int(subhndsh)
+ except TypeError:
+ return {}
+
+ empty_subhndsh = Handshape.objects.get(machine_value=0)
+ new_subhndsh = Handshape.objects.filter(machine_value=subhndsh_machine_value).first()
+
+ if not new_subhndsh:
+ # if the word class does not exist, set it to empty
+ subhndsh_machine_value = 0
+ new_subhndsh = empty_subhndsh
+
+ with atomic():
+ if not gloss.subhndsh:
+ gloss.subhndsh = new_subhndsh
+ elif gloss.subhndsh.machine_value != subhndsh_machine_value:
+ gloss.subhndsh = new_subhndsh
+ else:
+ gloss.subhndsh = empty_subhndsh
+ gloss.save()
+
+ result = dict()
+ result['glossid'] = str(gloss.id)
+ newvalue = gloss.subhndsh.name
+ result['subhndsh'] = newvalue
+
+ return result
+
+
+@permission_required('dictionary.change_gloss')
+def mapping_toggle_locprim(request, glossid, locprim):
+ if not request.user.is_authenticated:
+ return {}
+
+ if not request.user.has_perm('dictionary.change_gloss'):
+ return {}
+
+ try:
+ gloss_id = int(glossid)
+ except TypeError:
+ return {}
+
+ gloss = Gloss.objects.filter(id=gloss_id).first()
+
+ if not gloss:
+ return {}
+
+ try:
+ locprim_machine_value = int(locprim)
+ except TypeError:
+ return {}
+
+ empty_locprim = FieldChoice.objects.get(field='Location', machine_value=0)
+ new_locprim = FieldChoice.objects.filter(field='Location', machine_value=locprim_machine_value).first()
+
+ if not new_locprim:
+ # if the word class does not exist, set it to empty
+ locprim_machine_value = 0
+ new_locprim = empty_locprim
+
+ with atomic():
+ if not gloss.locprim:
+ gloss.locprim = new_locprim
+ elif gloss.locprim.machine_value != locprim_machine_value:
+ gloss.locprim = new_locprim
+ else:
+ gloss.locprim = empty_locprim
+ gloss.save()
+
+ result = dict()
+ result['glossid'] = str(gloss.id)
+ newvalue = gloss.locprim.name
+ result['locprim'] = newvalue
+
+ return result
diff --git a/signbank/dictionary/urls.py b/signbank/dictionary/urls.py
index 2b93e345b..6ab5a49f4 100755
--- a/signbank/dictionary/urls.py
+++ b/signbank/dictionary/urls.py
@@ -95,6 +95,12 @@
re_path(r'^update/toggle_domhndsh/(?P\d+)/(?P.*)$',
signbank.dictionary.update.toggle_domhndsh,
name='toggle_domhndsh'),
+ re_path(r'^update/toggle_subhndsh/(?P\d+)/(?P.*)$',
+ signbank.dictionary.update.toggle_subhndsh,
+ name='toggle_subhndsh'),
+ re_path(r'^update/toggle_locprim/(?P\d+)/(?P.*)$',
+ signbank.dictionary.update.toggle_locprim,
+ name='toggle_locprim'),
# The next one does not have a permission check because it should be accessible from a cronjob
re_path(r'^update_ecv/', GlossListView.as_view(only_export_ecv=True)),