Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FEAT: update of Romania to 2.11 #38

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 17 additions & 6 deletions ckanext/who_romania/helpers.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
import ckan.logic as logic
import ckan.model as model
from ckan.common import request, g
import ckan.plugins.toolkit as toolkit
from datetime import datetime, timedelta

def get_site_statistics() -> dict[str, int]:
'''This function used be a core helper but it was removed in CKAN 2.11.0
We reproduce it here to templates can continue working as usual.
'''
stats = {}
stats['dataset_count'] = toolkit.get_action('package_search')(
{}, {"rows": 1})['count']
stats['group_count'] = len(toolkit.get_action('group_list')({}, {}))
stats['organization_count'] = len(
toolkit.get_action('organization_list')({}, {}))
return stats


def get_user_obj(field=""):
"""
Expand All @@ -19,7 +30,7 @@ def get_dataset_from_id(id, validate=False):
"validate": validate,
"use_cache": False,
}
package_show_action = logic.get_action("package_show")
package_show_action = toolkit.get_action("package_show")
return package_show_action(context, {"id": id})


Expand Down Expand Up @@ -75,24 +86,24 @@ def _facet_sort_function(facet_name, facet_items):


def get_all_groups():
return logic.get_action("group_list")(
return toolkit.get_action("group_list")(
data_dict={"sort": "title asc", "all_fields": True}
)


def get_featured_datasets():
featured_datasets = logic.get_action("package_search")(
featured_datasets = toolkit.get_action("package_search")(
data_dict={"fq": "tags:featured", "sort": "metadata_modified desc", "rows": 3}
)["results"]
recently_updated = logic.get_action("package_search")(
recently_updated = toolkit.get_action("package_search")(
data_dict={"q": "*:*", "sort": "metadata_modified desc", "rows": 3}
)["results"]
datasets = featured_datasets + recently_updated
return datasets[:3]


def get_user_from_id(userid):
user_show_action = logic.get_action("user_show")
user_show_action = toolkit.get_action("user_show")
user_info = user_show_action({}, {"id": userid})
return user_info["fullname"]

Expand Down
1 change: 1 addition & 0 deletions ckanext/who_romania/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ def get_helpers(self):
"get_dates_of_weekday_in_month": who_romania_helpers.get_dates_of_weekday_in_month,
"get_week_options": who_romania_helpers.get_week_options,
"get_login_view": who_romania_helpers.get_login_view,
"get_site_statistics": who_romania_helpers.get_site_statistics,
}

# IConfigurer
Expand Down
7 changes: 3 additions & 4 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
git+https://github.com/fjelltopp/ckanext-blob-storage@5b2f59217e8f88a3f2cdb9dc50bf4099d9abe0de#egg=ckanext-blob-storage
git+https://github.com/datopian/ckanext-authz-service@bd4c80f55a714c1117a0e130d07463e383c494c7#egg=ckanext-authz-service
git+https://github.com/ckan/ckanext-scheming@899a3bce5f5ac05bd4e612213ec9138b536f3076#egg=ckanext-scheming
git+https://github.com/fjelltopp/ckanext-blob-storage@eb8ea60cac30dee85bf65329e079f971ca8c90c4#egg=ckanext-blob-storage
git+https://github.com/datopian/ckanext-authz-service@3d52c13cce5152f1a75f89a21e88c319b6c2ea82#egg=ckanext-authz-service
git+https://github.com/ckan/ckanext-scheming@5ce30cf2856aee97fa7b49de46847f8119dad355#egg=ckanext-scheming
giftless-client==0.1.1
boto3==1.28.52
Loading