From be65b5db773e5d928ab919a3472b410d233c8924 Mon Sep 17 00:00:00 2001 From: avdata99 Date: Mon, 27 Nov 2023 12:13:56 -0300 Subject: [PATCH 1/4] Allow custom org types for activities --- ckanext/activity/templates/organization/activity_stream.html | 2 +- ckanext/activity/templates/snippets/stream.html | 2 +- ckanext/activity/views.py | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/ckanext/activity/templates/organization/activity_stream.html b/ckanext/activity/templates/organization/activity_stream.html index a512dbfd507..c69b210c020 100644 --- a/ckanext/activity/templates/organization/activity_stream.html +++ b/ckanext/activity/templates/organization/activity_stream.html @@ -8,7 +8,7 @@ {% snippet 'snippets/activity_type_selector.html', id=id, activity_type=activity_type, activity_types=activity_types, blueprint='activity.organization_activity' %} {% endif %} - {% snippet 'snippets/stream.html', activity_stream=activity_stream, id=id, object_type='organization' %} + {% snippet 'snippets/stream.html', activity_stream=activity_stream, id=id, object_type='organization', group_type=group_type %} {% snippet 'snippets/pagination.html', newer_activities_url=newer_activities_url, older_activities_url=older_activities_url %} {% endblock %} diff --git a/ckanext/activity/templates/snippets/stream.html b/ckanext/activity/templates/snippets/stream.html index e2b0cffca91..52c0d4b4902 100644 --- a/ckanext/activity/templates/snippets/stream.html +++ b/ckanext/activity/templates/snippets/stream.html @@ -14,7 +14,7 @@ {% endmacro %} {% macro organization(activity) %} - + {{ activity.data.group.title if activity.data.group else _('unknown') }} {% endmacro %} diff --git a/ckanext/activity/views.py b/ckanext/activity/views.py index fb32504e028..c298ae6c2cd 100644 --- a/ckanext/activity/views.py +++ b/ckanext/activity/views.py @@ -510,6 +510,7 @@ def group_activity(id: str, group_type: str) -> str: except (tk.ObjectNotFound, tk.NotAuthorized): tk.abort(404, tk._("Group not found")) + real_group_type = group_dict["type"] action_name = "organization_activity_list" if not group_dict.get("is_organization"): action_name = "group_activity_list" @@ -563,7 +564,7 @@ def group_activity(id: str, group_type: str) -> str: extra_vars = { "id": id, "activity_stream": activity_stream, - "group_type": group_type, + "group_type": real_group_type, "group_dict": group_dict, "activity_type": activity_type, "activity_types": filter_types.keys(), From 3998876be29b7c40c41d5301e91ed64e7c2b60d7 Mon Sep 17 00:00:00 2001 From: avdata99 Date: Mon, 27 Nov 2023 12:16:12 -0300 Subject: [PATCH 2/4] Changelog --- changes/7943.bugfix | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 changes/7943.bugfix diff --git a/changes/7943.bugfix b/changes/7943.bugfix new file mode 100644 index 00000000000..6a9eead8879 --- /dev/null +++ b/changes/7943.bugfix @@ -0,0 +1,2 @@ +URLs in activities always points to `/organization/*` but custom org types +requeres `/custom-organization/*` URLs. This fixes those links. From b1493b9fc6715bcec2812ce65eb0ab7585ae7160 Mon Sep 17 00:00:00 2001 From: avdata99 Date: Mon, 27 Nov 2023 14:02:29 -0300 Subject: [PATCH 3/4] Test custom org URLs --- ckanext/activity/tests/test_views.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/ckanext/activity/tests/test_views.py b/ckanext/activity/tests/test_views.py index 3600c1466d4..935ef920468 100644 --- a/ckanext/activity/tests/test_views.py +++ b/ckanext/activity/tests/test_views.py @@ -46,6 +46,18 @@ def test_simple(self, app): response = app.get(url) assert user["fullname"] in response assert "created the organization" in response + assert_group_link_in_response(org, response) + + def test_simple_for_custom_org_type(self, app): + """Checking the template shows the activity stream.""" + user = factories.User() + org = factories.Organization(user=user, type="custom_org_type") + + url = url_for("activity.organization_activity", id=org["id"]) + response = app.get(url) + assert user["fullname"] in response + assert "created the organization" in response + assert_group_link_in_response(org, response) def test_create_organization(self, app): user = factories.User() From b3a79152eda498dc6165afab50828631f334e932 Mon Sep 17 00:00:00 2001 From: avdata99 Date: Wed, 29 Nov 2023 12:39:54 -0300 Subject: [PATCH 4/4] Test custom group_type for activities --- ckanext/activity/tests/test_views.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ckanext/activity/tests/test_views.py b/ckanext/activity/tests/test_views.py index 935ef920468..fabbbb27002 100644 --- a/ckanext/activity/tests/test_views.py +++ b/ckanext/activity/tests/test_views.py @@ -34,7 +34,7 @@ def assert_group_link_in_response(group, response): ) -@pytest.mark.ckan_config("ckan.plugins", "activity") +@pytest.mark.ckan_config("ckan.plugins", "activity example_igroupform") @pytest.mark.usefixtures("with_plugins", "clean_db") class TestOrganization(object): def test_simple(self, app): @@ -51,7 +51,7 @@ def test_simple(self, app): def test_simple_for_custom_org_type(self, app): """Checking the template shows the activity stream.""" user = factories.User() - org = factories.Organization(user=user, type="custom_org_type") + org = factories.Organization(user=user, type="grup") url = url_for("activity.organization_activity", id=org["id"]) response = app.get(url)