diff --git a/ckanext/datarequests/auth.py b/ckanext/datarequests/auth.py index 827b937c..6910642e 100644 --- a/ckanext/datarequests/auth.py +++ b/ckanext/datarequests/auth.py @@ -74,7 +74,7 @@ def update_datarequest(context, data_dict): is_current_creator = auth_if_creator(context, data_dict, constants.SHOW_DATAREQUEST) if (is_current_creator['success'] is True): return is_current_creator - + return auth_if_editor_or_admin(context, data_dict, constants.SHOW_DATAREQUEST) diff --git a/ckanext/datarequests/db.py b/ckanext/datarequests/db.py index cc530512..4b032da0 100644 --- a/ckanext/datarequests/db.py +++ b/ckanext/datarequests/db.py @@ -80,7 +80,7 @@ def get_ordered_by_date(cls, organization_id=None, user_id=None, closed=None, q= order_by_filter = cls.open_time.desc() if desc else cls.open_time.asc() current_user_id = current_user.id if current_user else None - + if current_user_id: current_user_order = case( [(cls.user_id == current_user_id, 1)], diff --git a/ckanext/datarequests/validator.py b/ckanext/datarequests/validator.py index 1f419562..8741e671 100644 --- a/ckanext/datarequests/validator.py +++ b/ckanext/datarequests/validator.py @@ -20,7 +20,7 @@ import datetime import ckan.plugins.toolkit as tk -from ckanext.datarequests import db, common, constants +from ckanext.datarequests import db, common, constants # noqa: F401 def profanity_check_enabled(): @@ -60,7 +60,7 @@ def validate_datarequest(context, request_data): if len(description) > constants.DESCRIPTION_MAX_LENGTH: _add_error(errors, description_field, tk._('Purpose of data use must be a maximum of %d characters long') % constants.DESCRIPTION_MAX_LENGTH) - + if description and not _has_alpha_chars(description, 2): _add_error(errors, description_field, tk._('Purpose of data use need to be longer than two characters and alphabetical')) @@ -89,7 +89,7 @@ def validate_datarequest(context, request_data): who_will_access_this_data_field = tk._('Who will access this data') if not who_will_access_this_data: _add_error(errors, who_will_access_this_data_field, tk._('Who will access this data cannot be empty')) - + if who_will_access_this_data and not _has_alpha_chars(who_will_access_this_data, 2): _add_error(errors, who_will_access_this_data_field, tk._('Who will access this data need to be longer than two characters and alphabetical')) @@ -98,7 +98,7 @@ def validate_datarequest(context, request_data): requesting_organisation_field = tk._('Requesting organisation') if not requesting_organisation: _add_error(errors, requesting_organisation_field, tk._('Requesting organisation cannot be empty')) - + # Check requesting_organisation is a valid organisation in database. if requesting_organisation: try: