From 3785e2740e0a36767616aee03f92dc923f62f310 Mon Sep 17 00:00:00 2001 From: susanodd Date: Mon, 8 Jul 2024 16:00:29 +0200 Subject: [PATCH] #1268: Added repeat to phonology fields (part 1) --- signbank/dictionary/adminviews.py | 8 +++-- .../dictionary/admin_batch_edit_view.html | 31 ++++++++++++++++++- .../dictionary/templatetags/field_choice.py | 11 +++++-- 3 files changed, 45 insertions(+), 5 deletions(-) diff --git a/signbank/dictionary/adminviews.py b/signbank/dictionary/adminviews.py index f4bb9c74a..a5b4e1212 100755 --- a/signbank/dictionary/adminviews.py +++ b/signbank/dictionary/adminviews.py @@ -14,7 +14,7 @@ QueryDict, JsonResponse, StreamingHttpResponse from django.urls import reverse_lazy from django.core.exceptions import PermissionDenied, ObjectDoesNotExist -from django.utils.translation import override, gettext_lazy as _, activate +from django.utils.translation import override, gettext, gettext_lazy as _, activate from django.shortcuts import * from django.contrib import messages from django.contrib.sites.models import Site @@ -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'] + similar_gloss_fields = ['handedness', 'domhndsh', 'subhndsh', 'locprim', 'movSh', 'repeat'] context['similar_gloss_fields'] = json.dumps(similar_gloss_fields) similar_gloss_fields_labels = {} for field in similar_gloss_fields: @@ -6573,6 +6573,10 @@ def get_context_data(self, **kwargs): field='MovementShape', machine_value__gt=1).order_by('name')] context['available_movSh'] = available_movSh + available_boolean = [{'machine_value': 1, 'name': gettext("Yes")}, + {'machine_value': 0, 'name': gettext("No")}] + context['available_boolean'] = available_boolean + 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 09dc27947..57d6e384f 100644 --- a/signbank/dictionary/templates/dictionary/admin_batch_edit_view.html +++ b/signbank/dictionary/templates/dictionary/admin_batch_edit_view.html @@ -504,6 +504,15 @@

{% trans "Batch Edit" %}

+ + {% trans "Repeat" %} + +
{% if gloss.repeat %}{% trans "Yes" %}{% else %}{% trans "No" %}{% endif %} +
+ + + @@ -654,6 +663,26 @@

{% trans "Batch Edit" %}

+ +
+
{% trans "Repeat" %} +
+
+
+

+ {% for ab in available_boolean %} + + {% endfor %} +

+
+
+
+ @@ -675,7 +704,7 @@

{% trans "Batch Edit" %}

-
+ {% load field_choice %} {% for fieldname, label in similar_gloss_fields_labels.items %} {% with gloss|get_gloss_field:fieldname as fieldvalue %} diff --git a/signbank/dictionary/templatetags/field_choice.py b/signbank/dictionary/templatetags/field_choice.py index 2ad0fd56c..edde71adc 100644 --- a/signbank/dictionary/templatetags/field_choice.py +++ b/signbank/dictionary/templatetags/field_choice.py @@ -1,5 +1,7 @@ from django.template import Library from signbank.dictionary.models import FieldChoice, Dataset +from django.utils.translation import gettext + def get_field_choice(machine_value,field_category): @@ -17,9 +19,9 @@ def get_field_choice(machine_value,field_category): return '-' - register = Library() + @register.filter def normalise_empty(machine_value): if machine_value in [None,'None']: @@ -39,7 +41,12 @@ def translated_frequency_list(dataset): @register.filter def get_gloss_field(gloss, field): field_value = getattr(gloss, field) - if field_value: + if field in ['repeat', 'altern']: + if not field_value: + return gettext("No") + else: + return gettext("Yes") + elif field_value: return field_value.name else: return '-'