Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#1251] add default views for basic types
- Loading branch information
Showing
5 changed files
with
101 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -140,3 +140,13 @@ def get_allowed_view_plugins(data_dict): | |
if plugin.can_view(data_dict): | ||
can_view.append(plugin) | ||
return can_view | ||
|
||
def get_new_resources(context, data_dict): | ||
''' Get out all new resources in this commit, | ||
needs to be run in extension point after_create and after_update ''' | ||
import ckan.lib.dictization.model_dictize as model_dictize | ||
model = context['model'] | ||
new_objs = model.Session()._object_cache['new'] | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
kindly
Author
Contributor
|
||
new_resources = [obj for obj in new_objs | ||
if isinstance(obj, model.Resource)] | ||
return model_dictize.resource_list_dictize(new_resources, context) |
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
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
@kindly There're many tests failing because there's no
model.Session()._object_cache
. Do you think it's safe to test if an_object_cache
exists and, if not, simply return an empty list? If there's no cache, I think it's safe to assume that there're no new resources, and so an empty list would be the correct value for this.Am I wrong?