Logic¶
Action¶
populate_dataset_name ¶
Adding uuid to the named url , the name field was a bit confusing to the client.
Source code in ckanext/saeoss/logic/action/add_named_url.py
Override of CKAN actions
package_create ¶
Intercepts the core package_create
action to check if package
is being published after being created.
Source code in ckanext/saeoss/logic/action/ckan.py
package_patch ¶
Intercepts the core package_patch
action to check if package is being published.
Source code in ckanext/saeoss/logic/action/ckan.py
package_show ¶
Intercepts the core package_show
action to add reference_date to package dict
Source code in ckanext/saeoss/logic/action/ckan.py
package_update ¶
Intercepts the core package_update
action to check if package is being published.
Source code in ckanext/saeoss/logic/action/ckan.py
user_create ¶
Intercepts the core user_create
action to also create the extra_fields.
Source code in ckanext/saeoss/logic/action/ckan.py
user_patch ¶
Implements user_patch action, which is not available on CKAN
The data_dict
parameter is expected to contain at least the id
key, which
should hold the user's id or name
Source code in ckanext/saeoss/logic/action/ckan.py
user_show ¶
Intercepts the core user_show
action to add any extra_fields that may exist for
the user
Source code in ckanext/saeoss/logic/action/ckan.py
user_update ¶
Intercepts the core user_update
action to update any extra_fields that may exist
for the user.
Source code in ckanext/saeoss/logic/action/ckan.py
resource_update ¶
Update a resource.
To update a resource you must be authorized to update the dataset that the resource belongs to.
.. note:: Update methods may delete parameters not explicitly provided in the
data_dict. If you want to edit only a specific attribute use resource_patch
instead.
For further parameters see
func:~ckan.logic.action.create.resource_create
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
id |
string
|
the id of the resource to update |
required |
Returns:
Type | Description |
---|---|
string
|
the updated resource |
Source code in ckanext/saeoss/logic/action/ckan_custom_actions.py
140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 |
|
handle_versioning ¶
According to whether the dataset status is completed or not, the update action should either create a new version or overwrite the existing dataset.
Source code in ckanext/saeoss/logic/action/dataset_versioning_control.py
numbering_version ¶
Handle the numbering logic of the new version, incrementing the last one by one
Source code in ckanext/saeoss/logic/action/dataset_versioning_control.py
search_and_update ¶
Uses regex to find version (num) at the end of string and substitute it, either in the title and/or url, the title has a dot in it's struct and the name (url) has a dash
Source code in ckanext/saeoss/logic/action/dataset_versioning_control.py
update_dataset_title_and_url ¶
Set the name and the url for the new version.
Source code in ckanext/saeoss/logic/action/dataset_versioning_control.py
ckan scheming gives repeating subfields the naming of fieldname-0*-subfieldname the number * can change accoring to the number of repeating subfields, this schema may affect how the field is going to be referenced from other services related to EMC, we are changing this naming here.
handle_repeating_subfields_naming ¶
change the naming of repeating subfields from fieldname-0-subfieldname to fieldname_subfieldname
Source code in ckanext/saeoss/logic/action/handle_repeating_subfields.py
Auth¶
authorize_package_publish ¶
Check if the current user is authorized to publish a dataset
Only org admins or site-wide sysadmins are authorized to publish a dataset (i.e. make it public).
Source code in ckanext/saeoss/logic/auth/ckan.py
package_patch ¶
Custom auth for the package_patch action.
Source code in ckanext/saeoss/logic/auth/ckan.py
package_update ¶
Custom auth for the package_update action.
Packages that are public shall not be editable by users that are not org admins or site-wide sysadmins.
Source code in ckanext/saeoss/logic/auth/ckan.py
Custom auth functions for ckanext-pages
These are used to control which users are allowed to edit new pages on the portal
authorize_delete_page ¶
Check whether user should be allowed to delete pages
This auth function customizes the default behavior of ckanext-pages. Where the default is to only allow sysadmins to delete a page, we instead check if they are members of the special portal staff group.
As a result of this override behavior we do not call next_auth
here - otherwise
the default ckanext-pages auth function would be called last and it would
end up enforcing the default behavior.
Source code in ckanext/saeoss/logic/auth/pages.py
authorize_edit_page ¶
Check whether user should be allowed to edit pages
This auth function customizes the default behavior of ckanext-pages. Where the default is to only allow sysadmins to edit a page, we instead check if they are members of the special portal staff group.
As a result of this override behavior we do not call next_auth
here - otherwise
the default ckanext-pages auth function would be called last and it would
end up enforcing the default behavior (i.e. only allow sysadmins to edit a page).
Source code in ckanext/saeoss/logic/auth/pages.py
authorize_show_page ¶
Check whether user should be allowed to view a page
This auth function customized the default behavior of ckanext-pages. Where the default is to check if a page is public and if not only allow access to sysadmins, we want members of the special portal staff group to also be able to access private pages.
As a result of this override behavior we may not call next_auth
here - otherwise
the default ckanext-pages auth function would be called last and it would
end up enforcing the default behavior.
Source code in ckanext/saeoss/logic/auth/pages.py
STAC Validators¶
Converters¶
check_if_int ¶
check if the given value can be converted to an integer
Source code in ckanext/saeoss/logic/converters.py
check_if_number ¶
check if the given value can be converted to a number
Source code in ckanext/saeoss/logic/converters.py
convert_choices_select_to_int ¶
while submitting the select choices numerical values, they are returned as strings, they should be submitted as ints, otherwises a value error would be raised.
Source code in ckanext/saeoss/logic/converters.py
convert_select_custom_choice_to_extra ¶
adding custom field to select options, currently appears as "__extras" in the database,
default_metadata_standard_name ¶
default_metadata_standard_version ¶
spatial_resolution_converter ¶
the natural numbers validator used with spatial resolution field causes internal server error when the type is None, handled here
Source code in ckanext/saeoss/logic/converters.py
Schema¶
Validators¶
doi_validator ¶
check if the doi follows certain pattern.
Source code in ckanext/saeoss/logic/validators.py
lineage_source_srs_validator ¶
" the difference from above method that the lineage source srs can be empty
srs_validator ¶
Validator for a dataset's spatial_reference_system field
Source code in ckanext/saeoss/logic/validators.py
to_date_after_from_date_validator ¶
Validator that checks that start and end dates are consistent
Source code in ckanext/saeoss/logic/validators.py
value_or_true_validator ¶
Validator that provides a default value of True
when the input is None.
This was designed with a package's private
field in mind. We want it to be
assigned a value of True when it is not explicitly provided on package creation.
This shall enforce creating private packages by default.
Source code in ckanext/saeoss/logic/validators.py
version_validator ¶
check if the version is number or not