Skip to content

Commit

Permalink
Rename meta terms to tags. Also fix some translations.
Browse files Browse the repository at this point in the history
  • Loading branch information
frjo committed Jan 14, 2025
1 parent 014c337 commit c0ad63e
Show file tree
Hide file tree
Showing 11 changed files with 55 additions and 38 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Generated by Django 4.2.17 on 2025-01-14 09:50

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"},
),
]
4 changes: 2 additions & 2 deletions hypha/apply/categories/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
4 changes: 2 additions & 2 deletions hypha/apply/funds/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -399,10 +399,10 @@ class UpdateMetaTermsForm(ApplicationSubmissionModelForm):
meta_terms = GroupedModelMultipleChoiceField(
queryset=None, # updated in init method
widget=MetaTermSelect2Widget(attrs={"data-placeholder": "Select..."}),
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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@
{% if "meta_terms" 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 %}"
hx-get="{% url "apply:submissions:list" %}{% modify_query "only_query_string" "page" meta_terms=meta_term.id %}"
href="{% url "apply:submissions:list" %}{% modify_query "only_query_string" "page" tags=meta_term.id %}"
hx-get="{% url "apply:submissions:list" %}{% modify_query "only_query_string" "page" tags=meta_term.id %}"
hx-target="#main"
hx-push-url="true"
hx-swap="outerHTML"
data-tippy-content="Meta Term: {{meta_term.name}}"
data-tippy-content="Tag: {{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>
Expand Down
26 changes: 13 additions & 13 deletions hypha/apply/funds/templates/submissions/all.html
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@

{% if selected_statuses %}
<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">
status:{% for s in selected_statuses %}{{ s }}{% endfor %}
{% trans "Status" %}:{% for s in selected_statuses %}{{ s }}{% endfor %}
<a href="{% remove_from_query "status" %}" 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" aria-label="Remove">
{% heroicon_mini "x-mark" aria_hidden="true" fill="currentColor" %}
<span class="sr-only">{% trans "Remove status filter" %}</span>
Expand All @@ -214,7 +214,7 @@
{% endif %}
{% if selected_fund_objects %}
<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">
fund:{% for s in selected_fund_objects %}"{{ s }}"{% endfor %}
{% trans "Fund" %}:{% for s in selected_fund_objects %}"{{ s }}"{% endfor %}
<a href="{% remove_from_query "fund" %}" 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 fund filter" %}</span>
Expand All @@ -223,7 +223,7 @@
{% endif %}
{% if selected_round_objects %}
<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">
round:{% for s in selected_round_objects %}"{{ s }}"{% endfor %}
{% trans "Round" %}:{% for s in selected_round_objects %}"{{ s }}"{% endfor %}
<a href="{% remove_from_query "round" %}" 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 round filter" %}</span>
Expand All @@ -232,7 +232,7 @@
{% endif %}
{% if selected_leads %}
<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">
Lead:{% for s in selected_leads %}{{ s }}{% endfor %}
{% trans "Lead" %}:{% for s in selected_leads %}{{ s }}{% endfor %}
<a href="{% remove_from_query "lead" %}" 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 leads filter" %}</span>
Expand All @@ -241,7 +241,7 @@
{% endif %}
{% if selected_applicants %}
<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">
Applicant:{% for s in selected_applicants %}{{ s }}{% endfor %}
{% trans "Applicant" %}:{% for s in selected_applicants %}{{ s }}{% endfor %}
<a href="{% remove_from_query "applicants" %}" 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 applicant filter" %}</span>
Expand All @@ -250,7 +250,7 @@
{% endif %}
{% for s in selected_reviewers %}
<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">
Reviewer:{{ s }}
{% trans "Reviewer" %}:{{ s }}
<a href="{% remove_from_query reviewers=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 reviewer filter" %}</span>
Expand All @@ -259,16 +259,16 @@
{% 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">
Meta Term:{{ s }}
<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">
{% trans "Tag" %}:{{ s }}
<a href="{% remove_from_query tags=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 %}
{% for s in selected_category_options %}
<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">
Category:{{ s.value }}
{% trans "Category" %}:{{ s.value }}
<a href="{% remove_from_query category_options=s.id %}" 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 category filter" %}</span>
Expand All @@ -277,7 +277,7 @@
{% endfor %}
{% for s in selected_screening_statuses_objects %}
<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">
screening:"{{ s.title }}"
{% trans "Screening" %}:"{{ s.title }}"
<a href="{% remove_from_query screening_statuses=s.slug %}" 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 screening decisions filter" %}</span>
Expand All @@ -286,7 +286,7 @@
{% endfor %}
{% if selected_sort %}
<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">
sort:{{ selected_sort }}
{% trans "Sort" %}:{{ selected_sort }}
<a href="{% remove_from_query "sort" %}" 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 sort filter" %}</span>
Expand Down Expand Up @@ -452,7 +452,7 @@
{% endif %}

{% if "meta_terms" not in SUBMISSIONS_TABLE_EXCLUDED_FIELDS %}
{% dropdown_menu title="Terms" heading="Filter by Terms" enable_search=True position="right" %}
{% 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 %}
Expand Down
Original file line number Diff line number Diff line change
@@ -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 %}
Expand All @@ -33,7 +33,7 @@ <h2 class="inline-block mb-2 text-base font-semibold text-fg-muted">{{ group.gro
{% for meta_term in group.list %}
<a
class="py-1 px-2 text-sm font-semibold rounded-lg border transition-opacity hover:opacity-70 bg-slate-100"
href="{% url 'apply:submissions:list' %}?meta_terms={{ meta_term.id }}"
href="{% url 'apply:submissions:list' %}?tags={{ meta_term.id }}"
hx-boost="true"
hx-target="#main"
hx-select="#main"
Expand Down
18 changes: 9 additions & 9 deletions hypha/apply/funds/templates/submissions/submenu/meta-terms.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,24 @@
<ul class="overflow-scroll max-h-80 text-gray-700 divide-y" aria-labelledby="dropdown-meta-terms" data-filter-list>
{% if selected_meta_terms %}
<li data-filter-item-text>
<a href="{% url "apply:submissions:list" %}{% remove_from_query "only_query_string" "page" "meta_terms" %}"
hx-get="{% url "apply:submissions:list" %}{% remove_from_query "only_query_string" "page" "meta_terms" %}"
<a href="{% url "apply:submissions:list" %}{% remove_from_query "only_query_string" "page" "taga" %}"
hx-get="{% url "apply:submissions:list" %}{% remove_from_query "only_query_string" "page" "tags" %}"
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 %}
{% for meta_term in meta_terms %}
<li data-filter-item-text>
<a
{% if meta_term.selected %}
href="{% url "apply:submissions:list" %}{% remove_from_query "only_query_string" "page" meta_terms=meta_term.id %}"
hx-get="{% url "apply:submissions:list" %}{% remove_from_query "only_query_string" "page" meta_terms=meta_term.id %}"
href="{% url "apply:submissions:list" %}{% remove_from_query "only_query_string" "page" tags=meta_term.id %}"
hx-get="{% url "apply:submissions:list" %}{% remove_from_query "only_query_string" "page" tags=meta_term.id %}"
title="Remove {{ meta_term.title }} from current filters"
{% else %}
href="{% url "apply:submissions:list" %}{% add_to_query "only_query_string" "page" meta_terms=meta_term.id %}"
hx-get="{% url "apply:submissions:list" %}{% add_to_query "only_query_string" "page" meta_terms=meta_term.id %}"
href="{% url "apply:submissions:list" %}{% add_to_query "only_query_string" "page" tags=meta_term.id %}"
hx-get="{% url "apply:submissions:list" %}{% add_to_query "only_query_string" "page" tags=meta_term.id %}"
title="Add {{ meta_term.title }} to current filters"
{% endif %}
hx-push-url="true"
Expand All @@ -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>
2 changes: 1 addition & 1 deletion hypha/apply/funds/views/all.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def submissions_all(
selected_statuses = request.GET.getlist("status")
selected_screening_statuses = request.GET.getlist("screening_statuses")
selected_reviewers = request.GET.getlist("reviewers")
selected_meta_terms = request.GET.getlist("meta_terms")
selected_meta_terms = request.GET.getlist("tags")
selected_category_options = request.GET.getlist("category_options")
selected_sort = request.GET.get("sort")
page = request.GET.get("page", 1)
Expand Down
3 changes: 2 additions & 1 deletion hypha/apply/funds/views/submission_edit.py
Original file line number Diff line number Diff line change
Expand Up @@ -756,13 +756,14 @@ def post(self, *args, **kwargs):
if form.is_valid():
form.save()

message = _("Tags updated successfully.")
return HttpResponse(
status=204,
headers={
"HX-Trigger": json.dumps(
{
"metaTermsUpdated": None,
"showMessage": "Meta terms updated successfully.",
"showMessage": message,
}
),
},
Expand Down
2 changes: 1 addition & 1 deletion hypha/apply/funds/views/translate.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ def partial_translate_answers(request: HttpRequest, pk: int) -> HttpResponse:
message = _("Submission translation failed. Contact your Administrator.")
return HttpResponse(
status=400,
headers={"HX-Trigger": json.dumps({"showMessage": {message}})},
headers={"HX-Trigger": json.dumps({"showMessage": message})},
)

elif params == prev_params:
Expand Down

0 comments on commit c0ad63e

Please sign in to comment.