Skip to content

Commit

Permalink
Release qdes-1.1.0 (#194)
Browse files Browse the repository at this point in the history
* [DDCI-139] - added role to the alert

* [DDCI-30] - unique name for series child

* [DDCI-175] - added validator to identifier

* [DDCI-139] - hide success msg

* [DDCI-139] - fix anchor issues for repeater field

* [DDCI-285] - added recommended to multi field

* [DDCI-350 DDCI-377] - added mandatory field to title

* [DDCI-374] - added blank choice for publication status

* [DDCI-299] - printed organization name instead of id

* [DDCI-352] - reorder spatial content fields

* [DDCI-383] - added ignore missing logic to temporal start and end

* [DDCI-384] - populated metadata review date on api create

* [DDCI-385] - refactored functions

* [DDCI-394] - added save record button

* [DDCI-88] - added default zoom and changed label

* [DDCI-411] - added centroid to spatial field when no lower left and upper right

* [DDCI-221] - dataservice access

* [DDCI-367] - added temporal coverage facet

* [DDCI-240] - updated descriptive text

* [DDCI-235] - added error msg below the field

* [DDCI-383] - fix regression issue on package create

* [DDCI-235] -  fix regression issue

* [DDCI-242] - updated wording

* [DDCI-454] - changed primary format dropdown

* [DDCI-449] - added definitions to relationship

* [DDCI-242] - updated error message

* [DDCI-31] Harvest from QSpatial (pull) - once-off (#81)

* [DDCI-151] - added harvest script

* [DDCI-151] - added xml files directory

* WIP changes.

* POC changes for QSpatial migration script.

* [QLDDES-30] Tidy ups
- Added README.md
- Added DES example CSV file (DES_Datasets_Open_data_V1.csv)
- Renamed sub-dir
- Code refactoring
- Renamed some functions for readability
- Added helpers.py file
- Added secure vocab lookup for point of contact
- Added vocab lookup for classification_and_access_restrictions
- Added vocab lookup for Topic or theme
- Added vocab lookup for Publication status

* [DDCI-30] Consolidated error & debug messages.

* [DDCI-30] DQL harvest fixes.

* [DDCI-30] Set resource description for series datasets, and create resource for series datasets.

* [DDCI-30] Ignore .DS_Store files.

* [DDCI-30] Fix topic typos in CSV

* [DDCI-30] Added more error traceability.

* [DDCI-30] Track licenses from source.

* [DDCI-30] Set defaults.

* [DDCI-31]
- Added qspatial mappings
- Refactored helpers into havest_helpers
- Added V1 of 'DES_Datasets_QSpatial_v1.csv' and 'xml_files.zip' which contains all of the harvest xml files
- Fixed a few template bugs

* Added enviroment varables for CKAN route and API key

* Removed logs

* Added contact_other_party metadata mapping

* [DDCI-30] - adjusted import

* Updated qspatial default values
Replace rights_statement with copyright symbol

* Added more scenarios for replacing copy right symbol
Added to resource right statement

* Added fix_url helper for URLs

* Updated QSpatial import to use CSV file to set default mandatory values

* Removed Temporal coverage start ignore_missing validator to match develop

* Added QSpatial URL to error log
Removed unused logging in import
Added get_data_service() function

* Removed duplicate .DS_Store and added comment in gitignore

Co-authored-by: awang setyawan <[email protected]>
Co-authored-by: Nathan Perry <[email protected]>
Co-authored-by: Mark Calvert <[email protected]>

* Refactored helpers to use harvest_helpers

* Set owner_org from environment variable
Fixed data_services issue of id value not been JSON format

* Removed refactored code

* Removed unused import

* [DDCI-244] - added new field for tree selector

* [DDCI-244] - added plural label

* Fixed 'fix_url' bug with not returning the url

* [DDCI-244] - added tooltip and counter

* [PATCH] Chained data services auth overrides.

* [DDCI-149] - added new UI, create new dataset to external schema

* Harvest helper udates:
- Updated 'get_vocabulary_service_term' to use new action 'get_vocabulary_service_term' to find exact term instead of using the search which does a contains search
- Refactored 'convert_size_to_bytes' into helper

Updated file 'DES_Datasets_Open_data_v1.csv' to the latest version

Updated qld harvester to use csv file to set default values
Updated code to handle existing packages and business rules

Fixed issues with qspatial harvester with parent/child packages relataionships

* Updated git ignore

* [DDCI-149] - added publish update logic

* [DDCI-149] - added activity stream

* Refactored code to be more readable
Removed duplicate rows from CSV

* [DDCI-149] - updated identifier and display messages

* [DDCI-149] - updated message

* [DDCI-149] Fix error on dataset/new

* [DDCI-149] Code review remediation
- Fixed check for resource is published on new resource
- Removed CKAN < 2.9 web asset inclusion
- Fixed typo in success message
- Hide validate and publish section of Publish page if dataset not able to be published

* [DDCI-149] Changed route URI for publish.

* Remove resources for parent series datasets from QSpatial
Fixed 'add_dataservice' bug of using wrong variable, removed unused 'resource' variable
Updated logic of updating existing packages and resources

* [DDCI-356] - added publish activity screen

* [DDCI-404] - added series publishing

* [DDCI-244] - updated markup (#114)

* [DDCI-401] - added unpublish dataset

* [DDCI-401] - added accordion style

* [DDCI-356] - added publish activity screen (#115)

* [DDCI-401] - added check access

* [DDCI-404] - added series publishing (#116)

* [DDCI-356] - added publish activity screen

* [DDCI-404] - added series publishing

* [DDCI-244] - fix typo and sizing (#118)

* [DDCI-487] - replaced publishing portal (#119)

* re-added required paramter

* Default `qdes_dataservice_choices` argument

Default `field` argument to `None`.

* Remove `qdes_dataservice_choices` argument

Don't need to send `None` for `field` argument to `qdes_dataservice_choices` template helper function as the default is now `None`.

* [DDCI-74] - added new search display and point the dropdown to same sec vocab

* [DDCI-670] Remove `version` field
- Removed `version` field from dataset metadata schema JSON configuration file
- Changed `View all metadata` link to point to dataset name, not CKAN ID.

* [HOTFIX] Datasets available - catch exception on package_show NotFound.

* [DDCI-392] - added deletion scenarios (#123)

* [DDCI-392] - added deletion scenarios

* [DDCI-572] - added state field

* [DDCI-572] - removed state empty option

Co-authored-by: Mark Calvert <[email protected]>

* [DDCI-393]
- Added accordin sections for metadata display groups for dataset type
- Re-ordered metadata schema fields to match AC's

* Fixing up merge conflicts

* Changed 'state' metadata field label back to 'State

* Changed 'state' metadata field label back to 'State

* [DDCI-356] - added validation error and enhance need republish status logic

* [DDCI-401] - added unpublished activity stream

* [DDCI-569] - fix regression due to accordion

* Closed according section to exclude action buttons

* [DDCI-572] - added other states and hide them

* [DDCI-572] - added a fix to hidden group field

* [DDCI-449] - updated relationship labels

* [DDCI-572] - updated schema for dataservice

* [DDCI-569] - fix delete button on multi text

* [DDCI-396]
- Updated method 'qdes_validate_dataset_relationships' to 'qdes_validate_circular_replaces_relationships'
- Method 'qdes_validate_circular_replaces_relationships' now checks circular replace relationships
- Removed getting package from context because it gets updated on each package_show in the validation loop

* [DDCI-392] Remediation - add deleted suffix to series parent link.

* [DDCI-393]
- Updated incorrect display_group
- Fixed bug where according section element closing before required

* [DDCI-59] - fix dashboard error for non admin

* [DDCI-393]
- Fixed issue with display-group articles not inside parent accordion section

* [DDCI-392] - added more delete label and listen to purge

* [DDCI-74] - updated schema so it won't fail validation for external

* [DDCI-149] - added dataservice to resoruce

* [DDCI-149] - updated link for publish

* [DDCI-401] - removed dataservice and fix issue when unpublish

* Updated migration harvest README.md steps

* [DDCI-392] - implemented helper to pull the correct pkg title

* [DDCI-690] Remediation for displaying deleted collection parent
- Added `try ... except` to `get_package_dict` helper function to avoid internal server error on exception (e.g. `NotAuthorized`)
- Added new helper method `get_collection_parent_title` to `logic/helpers/relationship_helpers.py`
- Adjusted display of collection(s) snippet in cases where user not authorised to see collection parent dataset

* [DDCI-87] - added lifecycle

* [DDCI-356] - keep unpublish to show when dataset/distribution needs update

* [DDCI-441]
- Chained auth 'package_show'
- If user has no access, return different abort message if the dataset is private

* [DDCI-441]
- Added template override for 'search_form' snippet
- If field is 'collection_package_id' display the package title

* [DDCI-149] - prevented from republishing, fix publish issue

* [DDCI-229] - added helptext

* [DDCI-677] - upated field placeholder

* [DDCI-353] - fix first activity stream to link to recent

* [DDCI-199] - added validation for forward relationship

* [DDCI-702] Dataset's Related Datasets tab is not being populated
- Added context to `package_show` call in `related_datasets` blueprint method

* [DDCI-432] - enhanced error message for multi group field

* [DDCI-51]
- Changed `vocabulary_service_name` for `classification` field in `qdes_dataservice.json` to `dataservice_classification`

* [DDCI-392] - displayed correct deteled pkg title and added try except

* [DDCI-699] Incorrect related_resources error
- Don't run the Package `after_update` method when adding or editing a resource
- Don't run the `qdes_validate_related_resources` method when adding or editing a resource

* [DDCI-727] - prevented get_action to raise an exception

* [DDCI-441]
Updated auth function 'package_show' to allow user access to view private datasets in the 'Related Datasets' tab

* [DDCI-707]
- Updated publishing to Open Data Portal
    - Added mapping from QDes licenses to Data.QLD licenses

* [DDCI-199] - accepted forward relationship on create/update/patch

* [DDCI-392] - updated error msg

* [DDCI-441]
- Added `ignore_auth` property to context for `build_versions` and `get_pkg_title`
    - User does not need access to dataset to display the information required eg. private datasets for versions and dataset titles

* [DDCI-392] refactored resource_update action

* [QSpatial harvest]
- harvest_xml.py
    - Added response.text check to see if QSpatial dataset identifier was found
    - Only create the xml file if it was
    - Added extra logging if response was not successful
- import_xml.py
    - Added try/catch around QSpatial object to log error and continue
- DES_Datasets_QSpatial_v1.csv
    - Removed deleted datasets not found on QSpatial

* [DDCI-753] - fix un-publishing issue (#159)

* [DDCI-772]
- qdes_multi_group.html: Moved the 'get_pkg_title' logic for non-url values
- collection.html: Only attempt to set pacakge data if the pkg_id exists, otherwise it must be an external url

* [DDDDCI-787]
Removed 'ignore_missing' validator from 'spatial' field
We still want to call the validator 'qdes_validate_geojson_spatial'
If the key is missing we still want the data to be converted for the spatial field
The key was not set in the QSpatial migration harvest

* [DDCI-699]
We do not need to keep these values any more which can be potentially causing other undesired issues

* [DDCI-780] - improved exception handling (#160)

* Fixed issue with API calls trying to reconcile_relationships and causing issues.
Only reconcile_relationships when coming from the Web UI

* Added more debug messages to QSpatial import
Removed files

* Do not add parent package as a series or collection if ID is not there

* [DDCI-835] refactored public log status (#161)

* [DDCI-791] - updated dataset related fields (#162)

* Remove error.csv which should not have been checked in

* Updated mapped format to the correct key for `tiff`

* [DDCI-855] - fix internal error resource field is not set (#164)

* [DDCI-789] added asteriks to accordion (#163)

* Added new V2 csv files for QSpatial & DataQLD migrations

* Updated import scripts to use new V2 csv files for import
Added more audit logging for imports

* [DDCI-790] Add additional help text and link to Spatial Coverage section (#166)

* [DDCI-854] Change warning / error messages to match the changes to "Related datasets" (#167)

* [DDCI-858] enhanced publish log status (#168)

* [DDCI-738] Map catalogue primary formats to Data.QLD formats to allow publishing to QLD open data portal (#169)

* Added ckan worker job titles

* Change link location in schema (#171)

* Set the message to No person assigned (#170)

* [DDCI-870][DDCI-856]
- Fixed related datasets tab error when dataset relationship has not package ID because it is a external URL to a dataset

* Updated QSpatial import with updated vocab service term values
Update Data QLD import with updated vocab service term values
Updated Data QLD publishing mappings with updated vocab service term values

* [DDCI-964] - set private to true when publishing to dataqld (#175)

* [DDCI-874] - added ispartof and haspart relationship (#172)

* [DDCI-876] - updated license to recommended (#173)

* [DDCI-889] - added clear button next to fields (#174)

* [DDCI-140] share metadata records via xml exports (#176)

* Added new 'dataset_export' blueprint endpoint
Added new 'XML_ISO-19139.xml.j2' file template to export

* Updating fields for XML export

* Update the XML template with the values from the blueprint

* Fix issues with converting data

* Fix empty string issue

* [DDCI-140] - pull the label for vocab

* [DDCI-140] - pull the label for vocab

* [DDCI-140] - pull the label for vocab

* Add dropdown button to export XML file

* Remove contact creatorin missing values

Co-authored-by: Mark Calvert <[email protected]>
Co-authored-by: awang setyawan <[email protected]>

* [DDCI-140] - fix xml format (#177)

* Indexing helpers fix and refactoring (#76)

- Bugfix `get_resource_format_labels` to prevent duplicates in `resource_format_labels`
- Refactor scheming schema into separate function

Co-authored-by: Mark Calvert <[email protected]>

* [DDCI-140] - updated xml

* [DDCI-845] - pulled related resource data (#165)

Co-authored-by: Mark Calvert <[email protected]>

* [DDCI-140] - fix missing element on xml (#179)

* [DDCI-891] - added private label

* [DDCI-289] - added validation for positive numbers

* [DDCI-967] - added check for the indexing

* [DDCI-140] - updated xml export

* [DDCI-140] - updated xml export and pretty print (#184)

* [DDCI-140] - added missing fields

* [DDCI-140] - added check for missing license_id

* [DDCI-140] - updated xml export format and add new fields

* Removed unused comment

* [DDCI-181] - added spatial display on dataset (#188)

* [DDCI-181] - removed unused files and update spatial (#189)

* [DDCI-181] - hide map when no centroid or bounding box (#190)

* [DDCI-975] revert publish visibility (#191)

* DDCI-976 Dont export empty dataservice id (#192)

* [DDCI-979] - fixed series detexction

Co-authored-by: awang setyawan <[email protected]>
Co-authored-by: Nathan Perry <[email protected]>
Co-authored-by: Mark Calvert <[email protected]>
Co-authored-by: Konstantin Sivakov <[email protected]>
  • Loading branch information
5 people authored Jul 5, 2021
1 parent 3c47dec commit 068761b
Show file tree
Hide file tree
Showing 137 changed files with 17,946 additions and 178 deletions.
12 changes: 11 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.DS_Store
.ropeproject
node_modules
bower_components
Expand Down Expand Up @@ -39,4 +40,13 @@ nosetests.xml
coverage.xml

# Sphinx documentation
docs/_build/
docs/_build/

# Ignore xml files from harvest and any logs
ckanext/qdes_schema/qspatial_harvest/xml_files/*.xml
ckanext/qdes_schema/qspatial_harvest/json_files/
ckanext/qdes_schema/qspatial_harvest/logs/
ckanext/qdes_schema/qld_harvest/json_files/
ckanext/qdes_schema/qld_harvest/logs/
ckanext/qdes_schema/qld_harvest/json_files_data_qld

75 changes: 75 additions & 0 deletions ckanext/qdes_schema/auth.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
import ckan.authz as authz
import ckan.plugins.toolkit as toolkit
import logging

from ckan.logic.auth import get_package_object

_ = toolkit._
log = logging.getLogger(__name__)


def user_can_manage_dataservices(next_auth, context, data_dict=None):
# Use the context['user'] as per CKAN core logic/auth/create.py -> package_create
user = context['user']

if not data_dict or not isinstance(data_dict, dict):
data_dict = {}

# We only want our auth function to take effect if we are dealing with a data service
# and the user is not an admin of some group - otherwise fall back to default CKAN
# auth function
package_type = data_dict.get('type')

if 'dataservice' in [toolkit.get_endpoint()[0], package_type] \
and not authz.has_user_permission_for_some_org(user, 'admin'):
return {'success': False, 'msg': _('User not authorized to perform action')}

return next_auth(context, data_dict)


@toolkit.chained_auth_function
def package_show(next_auth, context, data_dict):
result = next_auth(context, data_dict)

if not result.get('success', False):
# Check to see if the dataset is private
package = get_package_object(context, data_dict)
if package and package.private:
# Allow access for the related datasets tab to view the private dataset
if toolkit.get_endpoint() == ('qdes_schema', 'related_datasets'):
return {'success': True}
# Make sure the call is coming from dataset view instead of api view
elif toolkit.get_endpoint()[0] == 'dataset':
toolkit.abort(403, 'Record not accessible')

# return default ckan package_show auth result
return result


@toolkit.chained_auth_function
def package_create(next_auth, context, data_dict):
return user_can_manage_dataservices(next_auth, context, data_dict)


@toolkit.chained_auth_function
def package_update(next_auth, context, data_dict):
return user_can_manage_dataservices(next_auth, context, data_dict)


@toolkit.chained_auth_function
def package_patch(next_auth, context, data_dict):
return user_can_manage_dataservices(next_auth, context, data_dict)


@toolkit.chained_auth_function
def package_delete(next_auth, context, data_dict):
return user_can_manage_dataservices(next_auth, context, data_dict)


def dataservice_index(context, data_dict):
# Use the context['user'] as per CKAN core logic/auth/create.py -> package_create
user = context['user']

if not authz.has_user_permission_for_some_org(user, 'admin'):
return {'success': False, 'msg': _('User not authorized to perform action')}
return {'success': True}
Loading

0 comments on commit 068761b

Please sign in to comment.