|
40 | 40 | urlencode, quote, unquote, urlparse, urlunparse |
41 | 41 | ) |
42 | 42 |
|
43 | | -import jinja2 |
44 | | - |
45 | 43 | import ckan.config |
46 | 44 | import ckan.exceptions |
47 | 45 | import ckan.model as model |
|
82 | 80 | 'about': 'home.about', |
83 | 81 | 'search': 'dataset.search', |
84 | 82 | 'dataset_read': 'dataset.read', |
85 | | - 'dataset_activity': 'dataset.activity', |
| 83 | + 'dataset_activity': 'activity.package_activity', |
86 | 84 | 'dataset_groups': 'dataset.groups', |
87 | 85 | 'group_index': 'group.index', |
88 | 86 | 'group_about': 'group.about', |
89 | 87 | 'group_read': 'group.read', |
90 | | - 'group_activity': 'group.activity', |
| 88 | + 'group_activity': 'activity.group_activity', |
91 | 89 | 'organizations_index': 'organization.index', |
92 | | - 'organization_activity': 'organization.activity', |
| 90 | + 'organization_activity': 'activity.organization_activity', |
93 | 91 | 'organization_read': 'organization.read', |
94 | 92 | 'organization_about': 'organization.about', |
| 93 | + # TODO: add activity routes |
| 94 | + "user.activity": "activity.user_activity", |
| 95 | + "dashboard.index": "activity.dashboard", |
| 96 | + |
| 97 | + "dataset.changes_multiple": "activity.package_changes_multiple", |
| 98 | + "dataset.changes": "activity.package_changes", |
| 99 | + "dataset.history": "activity.package_history", |
| 100 | + |
| 101 | + "group.changes_multiple": "activity.group_changes_multiple", |
| 102 | + "group.changes": "activity.group_changes", |
| 103 | + "group.history": "activity.group_history", |
| 104 | + "organization.changes_multiple": "activity.organization_changes_multiple", |
| 105 | + "organization.changes": "activity.organization_changes", |
| 106 | + "organization.history": "activity.organization_history", |
| 107 | + |
95 | 108 | } |
96 | 109 |
|
97 | 110 |
|
@@ -2000,57 +2013,6 @@ def user_in_org_or_group(group_id: str) -> bool: |
2000 | 2013 | return len(query.all()) != 0 |
2001 | 2014 |
|
2002 | 2015 |
|
2003 | | -@core_helper |
2004 | | -def dashboard_activity_stream(user_id: str, |
2005 | | - filter_type: Optional[str] = None, |
2006 | | - filter_id: Optional[str] = None, |
2007 | | - offset: int = 0) -> list[dict[str, Any]]: |
2008 | | - '''Return the dashboard activity stream of the current user. |
2009 | | -
|
2010 | | - :param user_id: the id of the user |
2011 | | - :type user_id: string |
2012 | | -
|
2013 | | - :param filter_type: the type of thing to filter by |
2014 | | - :type filter_type: string |
2015 | | -
|
2016 | | - :param filter_id: the id of item to filter by |
2017 | | - :type filter_id: string |
2018 | | -
|
2019 | | - :returns: an activity stream as an HTML snippet |
2020 | | - :rtype: string |
2021 | | -
|
2022 | | - ''' |
2023 | | - context = cast( |
2024 | | - Context, {'model': model, 'session': model.Session, 'user': g.user}) |
2025 | | - |
2026 | | - if filter_type: |
2027 | | - action_functions = { |
2028 | | - 'dataset': 'package_activity_list', |
2029 | | - 'user': 'user_activity_list', |
2030 | | - 'group': 'group_activity_list', |
2031 | | - 'organization': 'organization_activity_list', |
2032 | | - } |
2033 | | - action_function = logic.get_action(action_functions[filter_type]) |
2034 | | - return action_function(context, {'id': filter_id, 'offset': offset}) |
2035 | | - else: |
2036 | | - return logic.get_action('dashboard_activity_list')( |
2037 | | - context, {'offset': offset}) |
2038 | | - |
2039 | | - |
2040 | | -@core_helper |
2041 | | -def recently_changed_packages_activity_stream( |
2042 | | - limit: Optional[int] = None) -> list[dict[str, Any]]: |
2043 | | - if limit: |
2044 | | - data_dict = {'limit': limit} |
2045 | | - else: |
2046 | | - data_dict = {} |
2047 | | - context = cast( |
2048 | | - Context, {'model': model, 'session': model.Session, 'user': g.user} |
2049 | | - ) |
2050 | | - return logic.get_action('recently_changed_packages_activity_list')( |
2051 | | - context, data_dict) |
2052 | | - |
2053 | | - |
2054 | 2016 | @core_helper |
2055 | 2017 | def escape_js(str_to_escape: str) -> str: |
2056 | 2018 | '''Escapes special characters from a JS string. |
@@ -2415,20 +2377,6 @@ def SI_number_span(number: int) -> Markup: # noqa |
2415 | 2377 | localised_filesize = formatters.localised_filesize |
2416 | 2378 |
|
2417 | 2379 |
|
2418 | | -@core_helper |
2419 | | -def new_activities() -> Optional[int]: |
2420 | | - '''Return the number of activities for the current user. |
2421 | | -
|
2422 | | - See :func:`logic.action.get.dashboard_new_activities_count` for more |
2423 | | - details. |
2424 | | -
|
2425 | | - ''' |
2426 | | - if not g.userobj: |
2427 | | - return None |
2428 | | - action = logic.get_action('dashboard_new_activities_count') |
2429 | | - return action({}, {}) |
2430 | | - |
2431 | | - |
2432 | 2380 | @core_helper |
2433 | 2381 | def uploads_enabled() -> bool: |
2434 | 2382 | if uploader.get_storage_path(): |
@@ -2693,95 +2641,6 @@ def sanitize_id(id_: str) -> str: |
2693 | 2641 | return str(uuid.UUID(id_)) |
2694 | 2642 |
|
2695 | 2643 |
|
2696 | | -@core_helper |
2697 | | -def compare_pkg_dicts(old: dict[str, Any], new: dict[str, Any], |
2698 | | - old_activity_id: str) -> list[dict[str, Any]]: |
2699 | | - ''' |
2700 | | - Takes two package dictionaries that represent consecutive versions of |
2701 | | - the same dataset and returns a list of detailed & formatted summaries of |
2702 | | - the changes between the two versions. old and new are the two package |
2703 | | - dictionaries. The function assumes that both dictionaries will have |
2704 | | - all of the default package dictionary keys, and also checks for fields |
2705 | | - added by extensions and extra fields added by the user in the web |
2706 | | - interface. |
2707 | | -
|
2708 | | - Returns a list of dictionaries, each of which corresponds to a change |
2709 | | - to the dataset made in this revision. The dictionaries each contain a |
2710 | | - string indicating the type of change made as well as other data necessary |
2711 | | - to form a detailed summary of the change. |
2712 | | - ''' |
2713 | | - from ckan.lib.changes import check_metadata_changes, check_resource_changes |
2714 | | - change_list: list[dict[str, Any]] = [] |
2715 | | - |
2716 | | - check_metadata_changes(change_list, old, new) |
2717 | | - |
2718 | | - check_resource_changes(change_list, old, new, old_activity_id) |
2719 | | - |
2720 | | - # if the dataset was updated but none of the fields we check were changed, |
2721 | | - # display a message stating that |
2722 | | - if len(change_list) == 0: |
2723 | | - change_list.append({u'type': 'no_change'}) |
2724 | | - |
2725 | | - return change_list |
2726 | | - |
2727 | | - |
2728 | | -@core_helper |
2729 | | -def compare_group_dicts( |
2730 | | - old: dict[str, Any], new: dict[str, Any], old_activity_id: str): |
2731 | | - ''' |
2732 | | - Takes two package dictionaries that represent consecutive versions of |
2733 | | - the same organization and returns a list of detailed & formatted summaries |
2734 | | - of the changes between the two versions. old and new are the two package |
2735 | | - dictionaries. The function assumes that both dictionaries will have |
2736 | | - all of the default package dictionary keys, and also checks for fields |
2737 | | - added by extensions and extra fields added by the user in the web |
2738 | | - interface. |
2739 | | -
|
2740 | | - Returns a list of dictionaries, each of which corresponds to a change |
2741 | | - to the dataset made in this revision. The dictionaries each contain a |
2742 | | - string indicating the type of change made as well as other data necessary |
2743 | | - to form a detailed summary of the change. |
2744 | | - ''' |
2745 | | - from ckan.lib.changes import check_metadata_org_changes |
2746 | | - change_list: list[dict[str, Any]] = [] |
2747 | | - |
2748 | | - check_metadata_org_changes(change_list, old, new) |
2749 | | - |
2750 | | - # if the organization was updated but none of the fields we check |
2751 | | - # were changed, display a message stating that |
2752 | | - if len(change_list) == 0: |
2753 | | - change_list.append({u'type': 'no_change'}) |
2754 | | - |
2755 | | - return change_list |
2756 | | - |
2757 | | - |
2758 | | -@core_helper |
2759 | | -def activity_list_select(pkg_activity_list: list[dict[str, Any]], |
2760 | | - current_activity_id: str) -> list[Markup]: |
2761 | | - ''' |
2762 | | - Builds an HTML formatted list of options for the select lists |
2763 | | - on the "Changes" summary page. |
2764 | | - ''' |
2765 | | - select_list = [] |
2766 | | - template = jinja2.Template( |
2767 | | - u'<option value="{{activity_id}}" {{selected}}>' |
2768 | | - '{{timestamp}}</option>', |
2769 | | - autoescape=True) |
2770 | | - for activity in pkg_activity_list: |
2771 | | - entry = render_datetime(activity['timestamp'], |
2772 | | - with_hours=True, |
2773 | | - with_seconds=True) |
2774 | | - select_list.append(Markup( |
2775 | | - template |
2776 | | - .render(activity_id=activity['id'], timestamp=entry, |
2777 | | - selected='selected' |
2778 | | - if activity['id'] == current_activity_id |
2779 | | - else '') |
2780 | | - )) |
2781 | | - |
2782 | | - return select_list |
2783 | | - |
2784 | | - |
2785 | 2644 | @core_helper |
2786 | 2645 | def get_collaborators(package_id: str) -> list[tuple[str, str]]: |
2787 | 2646 | '''Return the collaborators list for a dataset |
|
0 commit comments