Skip to content

Commit

Permalink
[QCDP24-19] linting
Browse files Browse the repository at this point in the history
  • Loading branch information
awset committed Aug 20, 2024
1 parent ccf68a1 commit c9f8941
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
2 changes: 1 addition & 1 deletion ckanext/datarequests/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ def _send_mail(action_type, datarequest, job_title=None, context=None):
'email': requester_email,
'name': requester_name
})

followers = _get_datarequest_followers(context, datarequest)
user_list.extend(followers)

Expand Down
21 changes: 9 additions & 12 deletions ckanext/datarequests/validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,24 +40,15 @@ def _has_alpha_chars(string, min_alpha_chars):


def validate_datarequest(context, request_data):

errors = {}

# Run profanity check
if profanity_check_enabled():
if common.profanity_check(title):
_add_error(errors, title_field, tk._("Blocked due to profanity"))
if description_field not in errors and common.profanity_check(description):
_add_error(errors, description_field, tk._("Blocked due to profanity"))

default_title = ''
default_org_id = ''


###################################
# Validating hidden fields
###################################

# Validate requested_dataset
requested_dataset = request_data.get('requested_dataset', None)
requested_dataset_field = tk._('Requested dataset')
Expand All @@ -84,7 +75,6 @@ def validate_datarequest(context, request_data):
except Exception:
_add_error(errors, organization_field, tk._('Organization is not valid'))


###################################
# Validating visible fields
###################################
Expand Down Expand Up @@ -112,6 +102,13 @@ def validate_datarequest(context, request_data):
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'))

# Run profanity check
if profanity_check_enabled():
if common.profanity_check(title):
_add_error(errors, title_field, tk._("Blocked due to profanity"))
if description_field not in errors and common.profanity_check(description):
_add_error(errors, description_field, tk._("Blocked due to profanity"))

# Check data_use_type data, it should not be empty.
data_use_type = request_data.get('data_use_type', '')
data_use_type_field = tk._('Data use type')
Expand Down Expand Up @@ -163,7 +160,7 @@ def validate_datarequest(context, request_data):

if data_outputs_description and not _has_alpha_chars(data_outputs_description, 2):
_add_error(errors, data_outputs_description_field, tk._('Data outputs description need to be longer than two characters and alphabetical'))

# Check status, it should not be empty and have valid value.
valid_statuses = helpers.get_status_list()
status = request_data.get('status', 'Assigned')
Expand Down

0 comments on commit c9f8941

Please sign in to comment.