-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
24 changed files
with
1,022 additions
and
8 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,141 @@ | ||
from __future__ import annotations | ||
|
||
from dominate import tags | ||
|
||
import ckan.plugins.toolkit as tk | ||
|
||
import ckanext.ap_main.collection.base as collection_base | ||
|
||
from ckanext.collection.utils import ApiData | ||
from ckanext.collection.types import InputFilter, ButtonFilter, SelectFilter | ||
from ckanext.collection.utils import Filters | ||
|
||
from ckanext.ap_doi.utils import DOIProblemPackageData | ||
|
||
|
||
def row_dictizer( | ||
serializer: collection_base.ApHtmxTableSerializer, row: DOIProblemPackageData | ||
): | ||
row["bulk-action"] = row["id"] # type: ignore | ||
|
||
return row | ||
|
||
|
||
class ApDOICollection(collection_base.ApCollection): | ||
SerializerFactory = collection_base.ApHtmxTableSerializer.with_attributes( | ||
row_dictizer=row_dictizer, | ||
# record_template="ap_doi/record.html", | ||
# pager_template="ap_doi/pager.html", | ||
) | ||
|
||
ColumnsFactory = collection_base.ApColumns.with_attributes( | ||
names=[ | ||
"bulk-action", | ||
"title", | ||
"doi_status", | ||
"identifier", | ||
"timestamp", | ||
"published", | ||
"row_actions", | ||
], | ||
sortable={}, | ||
labels={ | ||
"bulk-action": tk.literal( | ||
tags.input_( | ||
type="checkbox", | ||
name="bulk_check", | ||
id="bulk_check", | ||
data_module="ap-bulk-check", | ||
data_module_selector='input[name="entity_id"]', | ||
) | ||
), | ||
"title": "Title", | ||
"doi_status": "Status", | ||
"identifier": "DOI", | ||
"timestamp": "Timestamp", | ||
"published": "Publish Date", | ||
"row_actions": "Actions", | ||
}, | ||
width={"title": "15%", "doi_status": "10%", "row_actions": "20%"}, | ||
serializers={ | ||
"timestamp": [("date", {})], | ||
"published": [("date", {})], | ||
}, | ||
) | ||
|
||
DataFactory = ApiData.with_attributes( | ||
action="ap_doi_get_packages_doi", | ||
) | ||
|
||
FiltersFactory = Filters.with_attributes( | ||
static_actions=[ | ||
collection_base.BulkAction( | ||
name="bulk-action", | ||
type="bulk_action", | ||
options={ | ||
"label": "Action", | ||
"options": [ | ||
{"value": "1", "text": "Update DOI"}, | ||
], | ||
}, | ||
), | ||
collection_base.RowAction( | ||
name="view", | ||
type="row_action", | ||
options={ | ||
"endpoint": "doi_dashboard.create_or_update_doi", | ||
"label": "Update DOI", | ||
"params": { | ||
"package_id": "$id", | ||
}, | ||
}, | ||
), | ||
collection_base.RowAction( | ||
name="view", | ||
type="row_action", | ||
options={ | ||
"endpoint": "ap_content.entity_proxy", | ||
"label": "View", | ||
"params": { | ||
"entity_id": "$name", | ||
"entity_type": "$type", | ||
"view": "read", | ||
}, | ||
}, | ||
), | ||
], | ||
static_filters=[ | ||
InputFilter( | ||
name="q", | ||
type="input", | ||
options={ | ||
"label": "Search", | ||
"placeholder": "Search", | ||
}, | ||
), | ||
SelectFilter( | ||
name="doi_status", | ||
type="select", | ||
options={ | ||
"label": "Status", | ||
"options": [ | ||
{"value": "", "text": "Any"}, | ||
{"value": "Published", "text": "Published"}, | ||
{"value": "Missing", "text": "Missing"}, | ||
{"value": "Outdated", "text": "Outdated"}, | ||
], | ||
}, | ||
), | ||
ButtonFilter( | ||
name="type", | ||
type="button", | ||
options={ | ||
"label": "Clear", | ||
"type": "button", | ||
"attrs": { | ||
"onclick": "$(this).closest('form').find('input,select').val('').prevObject[0].requestSubmit()" | ||
}, | ||
}, | ||
), | ||
], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import ckan.plugins.toolkit as tk | ||
|
||
|
||
def is_mock_api_calls() -> bool: | ||
return tk.asbool(tk.config.get("ckanext.ap_doi.mock_api_calls")) | ||
|
||
|
||
def get_doi_prefix() -> str: | ||
return tk.config.get("ckanext.doi.prefix") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
version: 1 | ||
groups: | ||
- annotation: Admin panel example | ||
options: | ||
# The following keys are declared here, because ckanext-doi doesn't provide config declaration | ||
|
||
- key: ckanext.doi.account_name | ||
required: true | ||
description: Your DataCite Repository account | ||
editable: true | ||
|
||
- key: ckanext.doi.account_password | ||
required: true | ||
description: Your DataCite Repository account password | ||
editable: true | ||
|
||
- key: ckanext.doi.prefix | ||
required: true | ||
description: The prefix taken from your DataCite Repository account (from your test account if running in test mode) | ||
editable: true | ||
|
||
- key: ckanext.doi.publisher | ||
required: true | ||
description: The name of the institution publishing the DOI | ||
editable: true | ||
|
||
- key: ckanext.doi.test_mode | ||
description: Enable dev/test mode | ||
required: true | ||
description: If test mode is set to true, the DOIs will use the DataCite test site. The test site uses a separate account, so you must also change your credentials and prefix. | ||
editable: true | ||
|
||
- key: ckanext.doi.site_url | ||
description: Used to build the link back to the dataset | ||
editable: true | ||
|
||
- key: ckanext.doi.site_title | ||
description: Site title to use in the citation | ||
editable: true | ||
|
||
# AP_DOI config options | ||
- key: ckanext.ap_doi.mock_api_calls | ||
description: If enabled, the extension will not make any API calls to DataCite | ||
editable: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
scheming_version: 2 | ||
schema_id: ap_doi_config | ||
about: Configuration options for the DOI extension | ||
|
||
fields: | ||
- field_name: ckanext.ap_doi.mock_api_calls | ||
label: Mock API calls | ||
description: If enabled, the extension will not make any API calls to DataCite | ||
validators: default(true), one_of([true, false]) | ||
preset: select | ||
required: true | ||
choices: | ||
- value: true | ||
label: Enabled | ||
- value: false | ||
label: Disabled | ||
|
||
- field_name: ckanext.doi.account_name | ||
label: Account name | ||
required: true | ||
description: Your DataCite Repository account | ||
form_snippet: text.html | ||
display_snippet: text.html | ||
|
||
- field_name: ckanext.doi.account_password | ||
label: Account password | ||
required: true | ||
description: Your DataCite Repository account password | ||
input_type: password | ||
|
||
- field_name: ckanext.doi.prefix | ||
label: DOI prefix | ||
required: true | ||
description: The prefix taken from your DataCite Repository account (from your test account if running in test mode) | ||
|
||
- field_name: ckanext.doi.publisher | ||
label: Publisher | ||
required: true | ||
description: The name of the institution publishing the DOI | ||
|
||
- field_name: ckanext.doi.test_mode | ||
label: Test mode | ||
required: true | ||
description: If test mode is set to true, the DOIs will use the DataCite test site. The test site uses a separate account, so you must also change your credentials and prefix. | ||
validators: default(true), one_of([true, false]) | ||
preset: select | ||
required: true | ||
choices: | ||
- value: true | ||
label: Enabled | ||
- value: false | ||
label: Disabled | ||
|
||
- field_name: ckanext.doi.site_url | ||
label: Site URL | ||
description: Used to build the link back to the dataset | ||
|
||
- field_name: ckanext.doi.site_title | ||
label: Site title | ||
description: Site title to use in the citation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
DOI_FLAKE_NAME = "ckanext:ap_doi:doi:" |
Oops, something went wrong.