From 17b6856fd5959f1345f19ab0b959cf2b6e6cf7a8 Mon Sep 17 00:00:00 2001
From: Fredrik Jonsson <frjo@xdeb.org>
Date: Fri, 31 Jan 2025 08:38:35 +0100
Subject: [PATCH] Rename meta terms to tags in the UI.

---
 docs/references/wagtail-admin.md                 |  2 +-
 docs/setup/administrators/configuration.md       |  2 +-
 .../migrations/0007_rename_meta_terms_to_tags.py | 16 ++++++++++++++++
 hypha/apply/categories/models.py                 |  4 ++--
 hypha/apply/funds/forms.py                       |  4 ++--
 hypha/apply/funds/tables.py                      |  2 +-
 .../funds/includes/admin_primary_actions.html    |  2 +-
 .../funds/includes/submission-list-row.html      |  4 ++--
 hypha/apply/funds/templates/submissions/all.html |  8 ++++----
 .../submissions/partials/meta-terms-card.html    |  8 ++++----
 .../submissions/submenu/meta-terms.html          |  6 +++---
 11 files changed, 37 insertions(+), 21 deletions(-)
 create mode 100644 hypha/apply/categories/migrations/0007_rename_meta_terms_to_tags.py

diff --git a/docs/references/wagtail-admin.md b/docs/references/wagtail-admin.md
index 60931d1f7d..953d424676 100644
--- a/docs/references/wagtail-admin.md
+++ b/docs/references/wagtail-admin.md
@@ -22,7 +22,7 @@ The WagTail Admin is your "back office" for setting up form applications and pub
 - Category Questions: Application questions with multiple options for users to select.
 - Screening Statuses: For metadata related to the initial screening stage. 
 - Reviewer Roles: Adding reviewer roles.
-- Meta Terms: For metadata, such as tags, thumbnail image and ... “and” - The results must match all terms (default for database search).
+- Tags: For metadata, such as tags, thumbnail image and ... “and” - The results must match all terms (default for database search).
 - Manage
 
 ### Wagtail default settings
diff --git a/docs/setup/administrators/configuration.md b/docs/setup/administrators/configuration.md
index 59aa689c68..b9b891f66f 100644
--- a/docs/setup/administrators/configuration.md
+++ b/docs/setup/administrators/configuration.md
@@ -213,7 +213,7 @@ Should staff admins be able to export submissions.
 
 Columns to exclude from the submission tables.
 
-Possible values are: fund, round, status, lead, reviewers, screening_statuses, category_options, meta_terms, organization_name
+Possible values are: fund, round, status, lead, reviewers, screening_statuses, category_options, tags, organization_name
 
     SUBMISSIONS_TABLE_EXCLUDED_FIELDS = env.list('SUBMISSIONS_TABLE_EXCLUDED_FIELDS', [])
 
diff --git a/hypha/apply/categories/migrations/0007_rename_meta_terms_to_tags.py b/hypha/apply/categories/migrations/0007_rename_meta_terms_to_tags.py
new file mode 100644
index 0000000000..79f96a2721
--- /dev/null
+++ b/hypha/apply/categories/migrations/0007_rename_meta_terms_to_tags.py
@@ -0,0 +1,16 @@
+# Generated by Django 4.2.18 on 2025-01-31 07:38
+
+from django.db import migrations
+
+
+class Migration(migrations.Migration):
+    dependencies = [
+        ("categories", "0006_use_category_options_as_submission_filter"),
+    ]
+
+    operations = [
+        migrations.AlterModelOptions(
+            name="metaterm",
+            options={"verbose_name": "Tag", "verbose_name_plural": "Tags"},
+        ),
+    ]
diff --git a/hypha/apply/categories/models.py b/hypha/apply/categories/models.py
index d747656d7d..53d0bda898 100644
--- a/hypha/apply/categories/models.py
+++ b/hypha/apply/categories/models.py
@@ -136,8 +136,8 @@ def __str__(self):
         return self.name
 
     class Meta:
-        verbose_name = _("Meta Term")
-        verbose_name_plural = _("Meta Terms")
+        verbose_name = _("Tag")
+        verbose_name_plural = _("Tags")
 
 
 class MetaTermChoiceField(forms.ModelChoiceField):
diff --git a/hypha/apply/funds/forms.py b/hypha/apply/funds/forms.py
index 3e3bf483cd..d504870d7f 100644
--- a/hypha/apply/funds/forms.py
+++ b/hypha/apply/funds/forms.py
@@ -401,10 +401,10 @@ class UpdateMetaTermsForm(ApplicationSubmissionModelForm):
         widget=MetaTermWidget(
             attrs={"data-placeholder": "Select...", "data-js-choices": ""}
         ),
-        label=_("Meta terms"),
+        label=_("Tags"),
         choices_groupby="get_parent",
         required=False,
-        help_text=_("Meta terms are hierarchical in nature."),
+        help_text=_("Tags are hierarchical in nature."),
     )
 
     class Meta:
diff --git a/hypha/apply/funds/tables.py b/hypha/apply/funds/tables.py
index 21da0286ba..c5fc2cdb49 100644
--- a/hypha/apply/funds/tables.py
+++ b/hypha/apply/funds/tables.py
@@ -349,7 +349,7 @@ class SubmissionFilter(filters.FilterSet):
     category_options = MultipleChoiceFilter(
         choices=[], label=_("Category"), method="filter_category_options"
     )
-    meta_terms = ModelMultipleChoiceFilter(queryset=get_meta_terms, label=_("Terms"))
+    meta_terms = ModelMultipleChoiceFilter(queryset=get_meta_terms, label=_("Tags"))
 
     class Meta:
         model = ApplicationSubmission
diff --git a/hypha/apply/funds/templates/funds/includes/admin_primary_actions.html b/hypha/apply/funds/templates/funds/includes/admin_primary_actions.html
index 7bcbf79797..d5efa6efed 100644
--- a/hypha/apply/funds/templates/funds/includes/admin_primary_actions.html
+++ b/hypha/apply/funds/templates/funds/includes/admin_primary_actions.html
@@ -95,7 +95,7 @@ <h5>{% trans "Actions to take" %}</h5>
             class="button button--white button--full-width button--bottom-space"
             hx-get="{% url 'funds:submissions:metaterms_update' pk=object.pk %}"
             hx-target="#htmx-modal"
-        >{% trans "Meta Terms" %}</button>
+        >{% trans "Tags" %}</button>
 
         <button
             class="button button--white button--full-width button--bottom-space"
diff --git a/hypha/apply/funds/templates/funds/includes/submission-list-row.html b/hypha/apply/funds/templates/funds/includes/submission-list-row.html
index 527114254c..71bd8ecca2 100644
--- a/hypha/apply/funds/templates/funds/includes/submission-list-row.html
+++ b/hypha/apply/funds/templates/funds/includes/submission-list-row.html
@@ -52,7 +52,7 @@
                 class="{{ s.phase.bg_color }} hover:opacity-70 transition-opacity rounded-full whitespace-nowrap inline-block ms-1 px-2 pt-0.5 pb-1 text-xs font-medium text-gray-800"
             >{{ s.phase.display_name }}</a>
 
-            {% if "meta_terms" not in SUBMISSIONS_TABLE_EXCLUDED_FIELDS %}
+            {% if "tags" not in SUBMISSIONS_TABLE_EXCLUDED_FIELDS %}
                 {% for meta_term in s.get_assigned_meta_terms %}
                     <a
                         href="{% url "apply:submissions:list" %}{% modify_query "only_query_string" "page" meta_terms=meta_term.id %}"
@@ -60,7 +60,7 @@
                         hx-target="#main"
                         hx-push-url="true"
                         hx-swap="outerHTML"
-                        data-tippy-content="Meta Term: {{meta_term.name}}"
+                        data-tippy-content="Tags: {{meta_term.name}}"
                         data-tippy-placement="top"
                         class="inline-block px-2 pt-0.5 pb-1 text-xs font-medium whitespace-nowrap rounded-full transition-opacity hover:opacity-70 ms-1 text-slate-900 bg-slate-200"
                     >{{meta_term.name}}</a>
diff --git a/hypha/apply/funds/templates/submissions/all.html b/hypha/apply/funds/templates/submissions/all.html
index 891768d352..62343ef4f1 100644
--- a/hypha/apply/funds/templates/submissions/all.html
+++ b/hypha/apply/funds/templates/submissions/all.html
@@ -259,10 +259,10 @@
             {% endfor %}
             {% for s in selected_meta_terms %}
                 <span class="inline-flex items-center py-1 px-2 text-xs font-medium text-blue-800 bg-blue-100 rounded select-none me-2">
-                    {% trans "Meta Term:" %} {{ s|get_meta_term_from_id }}
+                    {% trans "Tag:" %} {{ s|get_meta_term_from_id }}
                     <a href="{% remove_from_query meta_terms=s %}" role="button" class="inline-flex items-center p-0.5 text-xs text-blue-400 bg-transparent rounded-sm hover:text-blue-900 hover:bg-blue-200 ms-1 dark:hover:bg-blue-800 dark:hover:text-blue-300" aria-label="Remove">
                         {% heroicon_mini "x-mark" aria_hidden="true" fill="currentColor" %}
-                        <span class="sr-only">{% trans "Remove meta term filter" %}</span>
+                        <span class="sr-only">{% trans "Remove tag filter" %}</span>
                     </a>
                 </span>
             {% endfor %}
@@ -451,8 +451,8 @@
                     {% enddropdown_menu %}
                 {% endif %}
 
-                {% if "meta_terms" not in SUBMISSIONS_TABLE_EXCLUDED_FIELDS %}
-                    {% dropdown_menu title="Terms" heading="Filter by Terms" enable_search=True position="right" %}
+                {% if "tags" not in SUBMISSIONS_TABLE_EXCLUDED_FIELDS %}
+                    {% dropdown_menu title="Tags" heading="Filter by tags" enable_search=True position="right" %}
                         {% slot "url" %}{% url "apply:submissions:submenu-meta-terms" %}{% remove_from_query "only_query_string" "page" %}{% endslot %}
                     {% enddropdown_menu %}
                 {% endif %}
diff --git a/hypha/apply/funds/templates/submissions/partials/meta-terms-card.html b/hypha/apply/funds/templates/submissions/partials/meta-terms-card.html
index 67199a1f66..89c5b91ff5 100644
--- a/hypha/apply/funds/templates/submissions/partials/meta-terms-card.html
+++ b/hypha/apply/funds/templates/submissions/partials/meta-terms-card.html
@@ -1,17 +1,17 @@
 {% load i18n heroicons %}
 
 <div class="flex gap-4 justify-between pb-4">
-    <h5 class="m-0">{% trans "Meta Terms" %}</h5>
+    <h5 class="m-0">{% trans "Tags" %}</h5>
     <button
         class="flex items-center py-1 px-2 font-bold rounded transition-colors hover:bg-gray-100 text-dark-blue -me-2"
         hx-get="{% url 'funds:submissions:metaterms_update' pk=submission.pk %}"
         hx-target="#htmx-modal"
         role="button"
         {% if meta_terms %}
-            aria-label="{% trans "Update Meta Terms" %}"
-            title="{% trans "Update Meta Terms" %}"
+            aria-label="{% trans "Update tags" %}"
+            title="{% trans "Update tags" %}"
         {% else %}
-            aria-label="{% trans "Add Meta Terms" %}"
+            aria-label="{% trans "Add tags" %}"
         {% endif %}
     >
         {% if meta_terms %}
diff --git a/hypha/apply/funds/templates/submissions/submenu/meta-terms.html b/hypha/apply/funds/templates/submissions/submenu/meta-terms.html
index 65fe08dd7d..43feeea874 100644
--- a/hypha/apply/funds/templates/submissions/submenu/meta-terms.html
+++ b/hypha/apply/funds/templates/submissions/submenu/meta-terms.html
@@ -7,7 +7,7 @@
                hx-get="{% url "apply:submissions:list" %}{% remove_from_query "only_query_string" "page" "meta_terms" %}"
                hx-push-url="true"
                class="flex px-3 py-2 text-gray-600 items-center hover:bg-gray-100 focus:bg-gray-100{% if s.selected %}bg-gray-100{% endif %}">
-                {% trans "All Meta Terms" %}
+                {% trans "All tags" %}
             </a>
         </li>
     {% endif %}
@@ -39,8 +39,8 @@
         </li>
     {% empty %}
         <li class="py-2 max-w-xs text-gray-600 ps-4 pe-3">
-            {% trans "No meta terms found." %}
+            {% trans "No tags found." %}
         </li>
     {% endfor %}
 </ul>
-<p class="py-2 px-3 m-0 text-fg-muted" data-filter-empty-state hidden>{% trans "No meta terms found. Sorry about that." %}</p>
+<p class="py-2 px-3 m-0 text-fg-muted" data-filter-empty-state hidden>{% trans "No tags found. Sorry about that." %}</p>