Add patch info to pre_upload_hook.

We got a specific case in which this change
is needed:

An aritifact type that only one instance is
allowed to be in 'active' status.

To enforce that we want to use pre_update_hook,
and check if there is any other artifact in 'active' status.
To do so we need json_patch info (we need to know if the json_patch
change status to "active" or "deactivated". 

This change aim to suuport this case and also support backward 
compatibility.


With this background, if the a user update 'active' artifact
to be with status "deactivated", we must know the patch info.

Change-Id: I6e85ff89144ca6d3a69c7a240de3f41bd1d999e7
This commit is contained in:
Idan 2019-01-02 15:38:57 +00:00 committed by Idan Narotzki
parent 1cee3290ed
commit 26e4184c8d
2 changed files with 5 additions and 1 deletions

View File

@ -151,7 +151,7 @@ class Engine(object):
action_names = ['update']
af_dict = af.to_dict()
policy.authorize('artifact:update', af_dict, context)
af.pre_update_hook(context, af)
af.pre_update_hook_with_patch(context, af, patch)
try:
for operation in patch._ops:
# apply the change to make sure that it's correct

View File

@ -549,6 +549,10 @@ Possible values:
def pre_update_hook(cls, context, af):
pass
@classmethod
def pre_update_hook_with_patch(cls, context, af, json_patch):
cls.pre_update_hook(context, af)
@classmethod
def post_update_hook(cls, context, af):
pass