Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#2003] start separate file for patch actions
- Loading branch information
Showing
6 changed files
with
38 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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
'''API functions for partial updates of existing data in CKAN''' | ||
|
||
import ckan.logic.action.update as _update | ||
from ckan.logic import get_action as _get_action | ||
|
||
def package_patch(context, data_dict): | ||
'''Patch a dataset (package). | ||
The difference between the update and patch methods is that the patch will | ||
perform an update of the provided parameters, while leaving all other | ||
parameters unchanged, whereas the update methods deletes all parameters | ||
not explicitly provided in the data_dict | ||
You must be authorized to edit the dataset and the groups that it belongs | ||
to. | ||
''' | ||
|
||
_check_access('package_patch', context, data_dict) | ||
|
||
name_or_id = data_dict.get("name") or _get_or_bust(data_dict, "id") | ||
show_context = { | ||
'model': context['model'], | ||
'session': context['session'], | ||
'user': context['user'], | ||
'auth_user_obj': context['auth_user_obj'], | ||
} | ||
|
||
package_dict = _get_action('package_show')(show_context, {'id': name_or_id}) | ||
|
||
patched = dict(package_dict.items() + data_dict.items()) | ||
return _update.package_update(context, patched) |
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
from ckan import logic | ||
import ckan.logic.auth.update as _update | ||
|
||
package_patch = _update.package_update |
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