-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: controller uses common function
- Loading branch information
Showing
2 changed files
with
8 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,11 @@ | ||
# encoding: utf-8 | ||
|
||
from ckantoolkit import ( | ||
BaseController, c, NotAuthorized, ObjectNotFound, | ||
abort, _, render, get_action) | ||
from ckantoolkit import BaseController | ||
|
||
from ckanext.validation import common | ||
|
||
|
||
class ValidationController(BaseController): | ||
|
||
def validation(self, resource_id): | ||
|
||
try: | ||
validation = get_action(u'resource_validation_show')( | ||
{u'user': c.user}, | ||
{u'resource_id': resource_id}) | ||
|
||
resource = get_action(u'resource_show')( | ||
{u'user': c.user}, | ||
{u'id': resource_id}) | ||
|
||
dataset = get_action(u'package_show')( | ||
{u'user': c.user}, | ||
{u'id': resource[u'package_id']}) | ||
|
||
# Needed for core resource templates | ||
c.package = c.pkg_dict = dataset | ||
c.resource = resource | ||
|
||
return render(u'validation/validation_read.html', extra_vars={ | ||
u'validation': validation, | ||
u'resource': resource, | ||
u'dataset': dataset, | ||
}) | ||
|
||
except NotAuthorized: | ||
abort(403, _(u'Unauthorized to read this validation report')) | ||
except ObjectNotFound: | ||
|
||
abort(404, _(u'No validation report exists for this resource')) | ||
return common.validation(resource_id) |