Skip to content

Commit

Permalink
Merge pull request #7943 from avdata99/allow_custom_org_types_for_act…
Browse files Browse the repository at this point in the history
…ivities

Allow custom org types for activities
  • Loading branch information
pdelboca committed Nov 30, 2023
2 parents bf71c4f + b3a7915 commit c990c6e
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 4 deletions.
2 changes: 2 additions & 0 deletions changes/7943.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
URLs in activities always points to `/organization/*` but custom org types
requeres `/custom-organization/*` URLs. This fixes those links.
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}
2 changes: 1 addition & 1 deletion ckanext/activity/templates/snippets/stream.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
{% endmacro %}

{% macro organization(activity) %}
<a href="{{ h.url_for('organization.read', id=activity.object_id) }}">
<a href="{{ h.url_for(group_type ~ '.read', id=activity.object_id) }}">
{{ activity.data.group.title if activity.data.group else _('unknown') }}
</a>
{% endmacro %}
Expand Down
14 changes: 13 additions & 1 deletion ckanext/activity/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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="grup")

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()
Expand Down
3 changes: 2 additions & 1 deletion ckanext/activity/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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(),
Expand Down

0 comments on commit c990c6e

Please sign in to comment.