Skip to content

Commit

Permalink
Merge pull request #6 from FCSCOpendata/fix/approval-reject
Browse files Browse the repository at this point in the history
Admin can view review pending/reject dataset in search page.
  • Loading branch information
MuhammadIsmailShahzad authored Jul 4, 2022
2 parents 3de3e48 + e297707 commit 105b48a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
17 changes: 14 additions & 3 deletions ckanext/datasetapproval/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,16 +88,27 @@ def get_validators(self):

# IPackageController
def before_search(self, search_params):
include_approval_pending= search_params.get('include_approval_pending', False)
if toolkit.c.userobj:
user_is_syadmin = toolkit.c.userobj.sysadmin
else:
user_is_syadmin = False

include_approval_pending = search_params.get('include_approval_pending', False)
include_drafts = search_params.get('include_drafts', False)

if include_drafts:
# show pending dataset in user dashboard.
search_params.update({
'fq': "+creator_user_id:{0} ".format(c.userobj.id) + search_params.get('fq', '')
})
elif include_approval_pending:
search_params.pop('include_approval_pending')
elif include_approval_pending or user_is_syadmin:
search_params.pop('include_approval_pending', None)

# Order dataset by approval state for sysadmin user.
if search_params.get('sort', '').startswith('approval_state'):
search_params.update({
'fq': '!(approval_state:(active OR approved))' + search_params.get('fq', '')
})
return search_params
else:
search_params.update({
Expand Down
8 changes: 4 additions & 4 deletions ckanext/datasetapproval/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ def state_validator(key, data, errors, context):
for org in user_orgs:
if org.get('id') == office_id:
if org.get('capacity') == 'admin':
# If no state provided and user is an admin, default to active
state = state or 'active'
# If no state provided and user is an admin, default to approved
state = state or 'approved'
elif is_ready_to_publish:
# If not admin and not draft, dataset has to go through approval process.
state = 'pending'
else:
state = False

data[key] = state or 'active'
return 'hello'
data[key] = state
return

0 comments on commit 105b48a

Please sign in to comment.