Blueprints¶
Flask uses a concept of blueprints for making application components and supporting common patterns within an application or across applications. Blueprints can greatly simplify how large applications work and provide a central means for Flask extensions to register operations on applications. A Blueprint object works similarly to a Flask application object, but it is not actually an application. Rather it is a blueprint of how to construct or extend an application. For further information see
Utility methods for news blueprints
list_news ¶
Get list og new.
Source code in ckanext/saeoss/blueprints/news_utils.py
news_delete_util ¶
Delete a new.
Source code in ckanext/saeoss/blueprints/news_utils.py
news_edit_util ¶
Edit a new.
Source code in ckanext/saeoss/blueprints/news_utils.py
delete_saved_search ¶
deletes a saved search via it's id.
Source code in ckanext/saeoss/blueprints/saved_searches.py
save_current_search ¶
save the current search query with user_id.
Source code in ckanext/saeoss/blueprints/saved_searches.py
re-implement stats blueprint as it's not working
get_deleted_packages ¶
@return: Returns list of deleted pkgs and date when they were deleted, in format: [(id, date_ordinal), ...]
Source code in ckanext/saeoss/blueprints/sys_stats.py
get_new_packages ¶
@return: Returns list of new pkgs and date when they were created, in format: [(id, date_ordinal), ...]
Source code in ckanext/saeoss/blueprints/sys_stats.py
get_package_revisions ¶
@return: Returns list of revisions and date of them, in format: [(id, date), ...]
Source code in ckanext/saeoss/blueprints/sys_stats.py
index ¶
A blueprint rendering stats template.
Source code in ckanext/saeoss/blueprints/sys_stats.py
check_fields_mapping ¶
Construct new checkers (minimum, maximum) with simplified names
Source code in ckanext/saeoss/blueprints/file_parser.py
check_file_fields ¶
Performs different checks over the xml files.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
file |
file returns: ----- object with status: False and a message | status:True.
|
The file to check. |
required |
Source code in ckanext/saeoss/blueprints/file_parser.py
create_ckan_dataset ¶
Create package via ckan api's package_create action.
Source code in ckanext/saeoss/blueprints/file_parser.py
extract_files ¶
The blueprint allows for multiple files to be sent at once, extract each and call parse_xml_dataset. return success after all files parsed.
Source code in ckanext/saeoss/blueprints/file_parser.py
file_has_dataset ¶
Parses the file, checks if file has a dataset within it and returns it.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
file |
file
|
the xml file to parse |
required |
Source code in ckanext/saeoss/blueprints/file_parser.py
handle_date_field ¶
handle_date_fields ¶
Date fields need to be iso compliant inorder to create the package, transform date strings to dates.
Source code in ckanext/saeoss/blueprints/file_parser.py
handle_numeric_choices ¶
Some choices fields have a number value to be submitted these are provided by the user as text, corresponding number values should be returned
Source code in ckanext/saeoss/blueprints/file_parser.py
handle_responsible_party_choices_fields ¶
Choices fields are strict, only a handful of choices to be returned, here were handling different variations that can be provided by the user for choices.
Source code in ckanext/saeoss/blueprints/file_parser.py
lowercase_dataset_values ¶
The metadata creation with CKAN is a very subtle thing, if values provided with xml files are capitalized, some validation rules will fail (e.g. UCS-2 for metadata characteristic will fail vs ucs-2 ) hence lower everything.
Source code in ckanext/saeoss/blueprints/file_parser.py
map_xml_fields ¶
Give more user friendly naming for the different fields, avoid the look of the repeating subfields field_name-0-subfield_name
Source code in ckanext/saeoss/blueprints/file_parser.py
maximum_fields_check ¶
Checking if the provided field is more than the maximum set of EMC datasets fields.
Source code in ckanext/saeoss/blueprints/file_parser.py
minimum_set_check ¶
Checking if the xml file fields has the minimum required set.
Source code in ckanext/saeoss/blueprints/file_parser.py
return_object_root ¶
Transform the xml dom root into an object of tag_name:tag_value
Source code in ckanext/saeoss/blueprints/file_parser.py
send_email_to_creator ¶
Per issue #105 we need to send emails to creator for mail_user function check https://github.com/ckan/ckan/blob/master/ckan/lib/mailer.py
Source code in ckanext/saeoss/blueprints/file_parser.py
set_language_abbreviation ¶
Check if dataset language and metadata language provided as "english" not "en" it will be rejected