diff --git a/media/js/glosses_toggle_edit.js b/media/js/glosses_toggle_edit.js
index 4686216f4..a5a1644eb 100644
--- a/media/js/glosses_toggle_edit.js
+++ b/media/js/glosses_toggle_edit.js
@@ -167,6 +167,23 @@ function toggle_repeat(data) {
buttonCell.attr('value', button_contents);
}
+function toggle_altern(data) {
+ if ($.isEmptyObject(data)) {
+ return;
+ };
+ var glossid = data.glossid;
+ var altern = data.altern;
+ var hCell = $("#altern_cell_"+glossid);
+ $(hCell).empty();
+ var cell = ""+altern+"";
+ hCell.html(cell);
+
+ var button_lookup = '#button_' + glossid + '_altern';
+ var buttonCell = $(button_lookup);
+ var button_contents = similar_gloss_fields_labels['altern'] + ': ' + altern;
+ buttonCell.attr('value', button_contents);
+}
+
function toggle_create_sense(data) {
if ($.isEmptyObject(data)) {
return;
@@ -427,6 +444,20 @@ $(document).ready(function() {
});
});
+ $('.quick_altern').click(function(e)
+ {
+ e.preventDefault();
+ var glossid = $(this).attr('value');
+ var altern = $(this).attr("data-altern");
+ $.ajax({
+ url : url + "/dictionary/update/toggle_altern/" + glossid + "/" + altern,
+ type: 'POST',
+ data: { 'csrfmiddlewaretoken': csrf_token },
+ datatype: "json",
+ success : toggle_altern
+ });
+ });
+
$('.quick_create_sense').click(function(e)
{
e.preventDefault();
diff --git a/signbank/dictionary/adminviews.py b/signbank/dictionary/adminviews.py
index a5b4e1212..4a506ad73 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', 'locprim', 'movSh', 'repeat']
+ similar_gloss_fields = ['handedness', 'domhndsh', 'subhndsh', 'locprim', 'movSh', 'repeat', 'altern']
context['similar_gloss_fields'] = json.dumps(similar_gloss_fields)
similar_gloss_fields_labels = {}
for field in similar_gloss_fields:
diff --git a/signbank/dictionary/templates/dictionary/admin_batch_edit_view.html b/signbank/dictionary/templates/dictionary/admin_batch_edit_view.html
index 66f52c1d2..669ab66e9 100644
--- a/signbank/dictionary/templates/dictionary/admin_batch_edit_view.html
+++ b/signbank/dictionary/templates/dictionary/admin_batch_edit_view.html
@@ -509,13 +509,21 @@
{% trans "Batch Edit" %}
- {% trans "Repeat" %} |
+ {% trans "Repeated Movement" %} |
{% if gloss.repeat %}{% trans "Yes" %}{% else %}{% trans "No" %}{% endif %}
|
+
+ {% trans "Alternating Movement" %} |
+
+ {% if gloss.altern %}{% trans "Yes" %}{% else %}{% trans "No" %}{% endif %}
+
+ |
+
@@ -670,7 +678,7 @@ {% trans "Batch Edit" %}
{% trans "Repeat" %}
+ data-target='#toggle_repeat_panel_{{gloss.id}}'>{% trans "Repeated Movement" %}
@@ -687,6 +695,25 @@
{% trans "Batch Edit" %}
+
+
{% trans "Alternating Movement" %}
+
+
+
+
+ {% for ab in available_boolean %}
+
+ {% endfor %}
+
+
+
+
+
diff --git a/signbank/dictionary/update.py b/signbank/dictionary/update.py
index 963e63bdc..8a6284bfc 100755
--- a/signbank/dictionary/update.py
+++ b/signbank/dictionary/update.py
@@ -42,7 +42,7 @@
mapping_toggle_wordclass, mapping_toggle_namedentity,
mapping_toggle_handedness, mapping_toggle_domhndsh,
mapping_toggle_subhndsh, mapping_toggle_locprim, mapping_toggle_movSh,
- batch_edit_create_sense, mapping_toggle_repeat)
+ batch_edit_create_sense, mapping_toggle_repeat, mapping_toggle_altern)
from signbank.dictionary.batch_edit import batch_edit_update_gloss
@@ -3607,6 +3607,19 @@ def toggle_repeat(request, glossid, repeat):
return JsonResponse(result)
+@permission_required('dictionary.change_gloss')
+def toggle_altern(request, glossid, altern):
+
+ gloss = Gloss.objects.filter(id=glossid).first()
+
+ if not okay_to_update_gloss(request, gloss):
+ return JsonResponse({})
+
+ result = mapping_toggle_altern(request, gloss, altern)
+
+ 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 6611a0fd8..f3edde27d 100644
--- a/signbank/dictionary/update_glosses.py
+++ b/signbank/dictionary/update_glosses.py
@@ -372,6 +372,32 @@ def mapping_toggle_repeat(request, gloss, repeat):
return result
+@permission_required('dictionary.change_gloss')
+def mapping_toggle_altern(request, gloss, altern):
+ # altern is 0 or 1
+
+ if altern not in ['0', '1']:
+ return {}
+
+ new_altern_boolean = altern == '1'
+
+ original_altern = 'True' if gloss.altern else 'False'
+ new_altern = 'True' if altern == '1' else 'False'
+
+ with atomic():
+ gloss.altern = new_altern_boolean
+ gloss.save()
+
+ add_gloss_update_to_revision_history(request.user, gloss, 'altern', new_altern, original_altern)
+
+ result = dict()
+ result['glossid'] = str(gloss.id)
+ newvalue = gettext("Yes") if gloss.altern else gettext("No")
+ result['altern'] = 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 447781353..66ea0ba95 100755
--- a/signbank/dictionary/urls.py
+++ b/signbank/dictionary/urls.py
@@ -108,6 +108,9 @@
re_path(r'^update/toggle_repeat/(?P\d+)/(?P.*)$',
signbank.dictionary.update.toggle_repeat,
name='toggle_repeat'),
+ re_path(r'^update/toggle_altern/(?P\d+)/(?P.*)$',
+ signbank.dictionary.update.toggle_altern,
+ name='toggle_altern'),
re_path(r'^update/quick_create_sense/(?P\d+)$',
signbank.dictionary.update.quick_create_sense,