Skip to content

Commit

Permalink
Refs #22047; added async branch which will improve the workflow of as…
Browse files Browse the repository at this point in the history
…ync creation, in first try we will not allow the user to attempt another creation until the previous creation is completed or errored
  • Loading branch information
ichim-david committed Dec 8, 2014
1 parent 51facbd commit 45156a1
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions eea/versions/versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,7 @@ class CreateVersionAjax(object):
def __init__(self, context, request):
self.context = context
self.request = request
self.annotations = self.context.__annotations__

def __call__(self):
# We use the view instead of calling create_version to allow for
Expand All @@ -318,12 +319,39 @@ def __call__(self):

view = getMultiAdapter((self.context, self.request),
name="createVersion")
self.check_versioning_status()
if getattr(view, 'has_custom_behaviour', False):
self.remove_versioning_status()
return "SEEURL: %s/@@createVersion" % self.context.absolute_url()
else:
self.set_versioning_status()
view.create()
return "OK"

def check_versioning_status(self):
"""
:return:
:rtype:
"""
if self.annotations.get('versioningInProgress'):
return "IN PROGRESS"
else:
return self.set_versioning_status()

def set_versioning_status(self):
"""
:return:
:rtype:
"""
self.annotations['versioningInProgress'] = True

def remove_versioning_status(self):
"""
:return:
:rtype:
"""
del(self.annotations['versioningInProgress'])


def create_version(context, reindex=True):
""" Create a new version of an object
Expand Down

0 comments on commit 45156a1

Please sign in to comment.