From b8bc243c20b799cd364271797d21fe10cd36d2eb Mon Sep 17 00:00:00 2001 From: Anton Suharev <161566457+asuworks@users.noreply.github.com> Date: Tue, 15 Oct 2024 17:49:02 -0700 Subject: [PATCH 1/2] fix: adjust order by in codebase search component if search query is empty, the ordering parameter should default to most recently published. otherwise, should be order by relevance - deps: pin MarkupSafe for regression in 3.0.x (refs https://github.com/comses/planning/issues/277) - minor text refinement, change to "clear search" and include for queries as well should not offer a sort by relevance when there is no search query but that's for a later date Co-authored-by: Allen Lee --- django/core/jinja2/base.jinja | 2 +- django/core/jinja2/common.jinja | 67 ++++++++++--------- django/core/pagination.py | 6 +- django/requirements.txt | 1 + .../src/components/CodebaseListSidebar.vue | 3 +- 5 files changed, 43 insertions(+), 36 deletions(-) diff --git a/django/core/jinja2/base.jinja b/django/core/jinja2/base.jinja index 054aa9fa1..299f80e9d 100644 --- a/django/core/jinja2/base.jinja +++ b/django/core/jinja2/base.jinja @@ -354,7 +354,7 @@ {% if not is_production() %} -
+
You are currently accessing a test version of the comses.net website. Information that you view or store here will not be preserved and may not be consistent. diff --git a/django/core/jinja2/common.jinja b/django/core/jinja2/common.jinja index d7b2cff91..b0fc5347e 100644 --- a/django/core/jinja2/common.jinja +++ b/django/core/jinja2/common.jinja @@ -109,8 +109,9 @@
{% endmacro %} -{% macro build_paginator_url_params(page_number, query_params) %}{%- if query_params %}{{ query_params }}&{%endif --%}page={{page_number}}{% endmacro %} +{% macro build_paginator_url_params(page_number, query_params) %} +{%- if query_params %}{{ query_params }}&{%endif-%}page={{page_number}} +{% endmacro %} {% macro page_nav(url_name, list_state) %} {% endmacro %} {% macro paginator(url_name, list_state) %} -

Displaying {{ list_state.num_results }} of {{ list_state.count }} results - {% if list_state.query %} - for '{{ list_state.query }}' - {% endif %} - {% if list_state.filter_display_terms %} - {% for term in list_state.filter_display_terms %} - {{ term }} - {% endfor %} - - clear filters - +

Displaying {{ list_state.num_results }} of {{ list_state.count }} results + {% if list_state.query or list_state.filter_display_terms %} + {% if list_state.query %} + for "{{ list_state.query }}" + {% endif %} + {% if list_state.filter_display_terms %} + {% for term in list_state.filter_display_terms %} + {{ term }} + {% endfor %} + {% endif %} + + clear search + {% endif %} +

{% if list_state.count %}
diff --git a/django/core/pagination.py b/django/core/pagination.py index db6fdcd14..344676764 100644 --- a/django/core/pagination.py +++ b/django/core/pagination.py @@ -12,9 +12,9 @@ SORT_BY_FILTERS = defaultdict( lambda: "Sort by: Relevance", # default sort by relevance { - "-first_published_at": "Sort by: Publish date: newest", - "first_published_at": "Sort by: Publish date: oldest", - "-last_modified": "Sort by: Recently Modified", + "-first_published_at": "Sort by: Recently published", + "first_published_at": "Sort by: Earliest published", + "-last_modified": "Sort by: Recently modified", }, ) diff --git a/django/requirements.txt b/django/requirements.txt index a26f31403..3ec7ca983 100644 --- a/django/requirements.txt +++ b/django/requirements.txt @@ -30,6 +30,7 @@ html2text>=2016.9.19 jinja2==3.1.4 jsonschema==4.19.0 markdown==3.6 +MarkupSafe<3.0.0 # FIXME: remove after regression in 3.0.x is patched https://github.com/comses/planning/issues/277 nltk>=3.8.1,<4.0.0 numpy==1.26.4 pandas==2.2.2 diff --git a/frontend/src/components/CodebaseListSidebar.vue b/frontend/src/components/CodebaseListSidebar.vue index 8a0063db6..4e8a82e9f 100644 --- a/frontend/src/components/CodebaseListSidebar.vue +++ b/frontend/src/components/CodebaseListSidebar.vue @@ -141,7 +141,8 @@ const initializeFilterValues = () => { values.endDate = urlParams.get("publishedBefore") ? new Date(urlParams.get("publishedBefore")!) : null; - values.ordering = urlParams.get("ordering") || "-first_published_at"; + values.ordering = + urlParams.get("ordering") || (urlParams.get("query") ? "relevance" : "-first_published_at"); initialFilterValues.value = { ...values }; }; From 09178b4862477244eb5a8ddcef714269e90e0d3e Mon Sep 17 00:00:00 2001 From: sgfost <46429375+sgfost@users.noreply.github.com> Date: Fri, 18 Oct 2024 15:22:12 -0700 Subject: [PATCH 2/2] deps: remove markupsafe pin (#768) * deps: remove markupsafe v2 pin resolves comses/planning#277 * test(e2e): give release editor some time to initialize rarely, the test would hang up on a (inconsequential) TypeError on the client if it tried to do stuff before the release editor store was initialized --- django/requirements.txt | 1 - e2e/cypress/tests/codebase.spec.ts | 3 ++- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/django/requirements.txt b/django/requirements.txt index 3ec7ca983..a26f31403 100644 --- a/django/requirements.txt +++ b/django/requirements.txt @@ -30,7 +30,6 @@ html2text>=2016.9.19 jinja2==3.1.4 jsonschema==4.19.0 markdown==3.6 -MarkupSafe<3.0.0 # FIXME: remove after regression in 3.0.x is patched https://github.com/comses/planning/issues/277 nltk>=3.8.1,<4.0.0 numpy==1.26.4 pandas==2.2.2 diff --git a/e2e/cypress/tests/codebase.spec.ts b/e2e/cypress/tests/codebase.spec.ts index fa418d0b1..154ca2f3b 100644 --- a/e2e/cypress/tests/codebase.spec.ts +++ b/e2e/cypress/tests/codebase.spec.ts @@ -48,7 +48,8 @@ describe("Visit codebases page", () => { getDataCy("codebase-associated-publications").type(codebase["associated-publications"]); getDataCy("codebase-references").type(codebase.references); getDataCy("next").click(); - + // make sure the release editor is initialized + cy.wait(2000); //add images getDataCy("add-image").click(); getDataCy("upload-image")