diff --git a/gen/mixins/__init__.py b/gen/mixins/__init__.py index 7061dab..72e79d4 100644 --- a/gen/mixins/__init__.py +++ b/gen/mixins/__init__.py @@ -195,7 +195,7 @@ class BaseMixin: prevent other users to edit this page at the same time.''' if not hasattr(self.aq_base, 'locks'): # Create the persistent mapping that will store the lock - # ~{s_page: s_userId}~ + # ~{s_page: (s_userId, DateTime_lockDate)}~ from persistent.mapping import PersistentMapping self.locks = PersistentMapping() # Raise an error is the page is already locked by someone else. If the @@ -206,14 +206,15 @@ class BaseMixin: from AccessControl import Unauthorized raise Unauthorized('This page is locked.') # Set the lock - self.locks[page] = userId + from DateTime import DateTime + self.locks[page] = (userId, DateTime()) def isLocked(self, user, page): '''Is this page locked? If the page is locked by the same user, we don't mind and consider the page as unlocked. If the page is locked, this - method returns the id of the user that has locked the page.''' + method returns the tuple (userId, lockDate).''' if hasattr(self.aq_base, 'locks') and (page in self.locks): - if (user.getId() != self.locks[page]): return self.locks[page] + if (user.getId() != self.locks[page][0]): return self.locks[page] def removeLock(self, page): '''Removes the lock on the current page. This happens after the page has @@ -222,7 +223,7 @@ class BaseMixin: # Raise an error if the user that saves changes is not the one that # has locked the page. userId = self.getUser().getId() - if self.locks[page] != userId: + if self.locks[page][0] != userId: from AccessControl import Unauthorized raise Unauthorized('This page was locked by someone else.') # Remove the lock @@ -234,7 +235,7 @@ class BaseMixin: view.pt for this page. In this case, we consider that the user has left the edit page in an unexpected way and we remove the lock.''' if hasattr(self.aq_base, 'locks') and (page in self.locks) and \ - (user.getId() == self.locks[page]): + (user.getId() == self.locks[page][0]): del self.locks[page] def onCreateWithoutForm(self): diff --git a/gen/po.py b/gen/po.py index fc21943..04282bf 100644 --- a/gen/po.py +++ b/gen/po.py @@ -201,7 +201,7 @@ appyLabels = [ ('changes_show', 'Show changes'), ('changes_hide', 'Hide changes'), ('anonymous', 'an anonymous user'), - ('page_locked', 'This page is locked by ${user}.'), + ('page_locked', '${date} - This page is locked by ${user}.'), ] # Some default values for labels whose ids are not fixed (so they can't be diff --git a/gen/ui/lockedBig.png b/gen/ui/lockedBig.png new file mode 100644 index 0000000..224089f Binary files /dev/null and b/gen/ui/lockedBig.png differ diff --git a/gen/ui/page.pt b/gen/ui/page.pt index 4639abc..8c6a5f3 100644 --- a/gen/ui/page.pt +++ b/gen/ui/page.pt @@ -253,9 +253,9 @@ + nextPage python: contextObj.getNextPage(phaseInfo, page)[0]; + isEdit python: layoutType == 'edit'; + pageInfo python: phaseInfo['pagesInfo'][page]"> Previous - Edit - + + + Refresh
@@ -287,14 +287,25 @@ title python: _('object_cancel')"/> - - + + Edit + + + + Locked + + + + diff --git a/gen/ui/portlet.pt b/gen/ui/portlet.pt index 8e00b8d..90b5a46 100644 --- a/gen/ui/portlet.pt +++ b/gen/ui/portlet.pt @@ -116,7 +116,7 @@ + mayEdit contextObj/mayEdit"> The box containing phase-related information @@ -142,8 +142,9 @@ + tal:define="lockDate python: tool.formatDate(locked[1]); + lockMsg python: _('page_locked', mapping={'user':tool.getUserName(locked[0]), 'date': lockDate})" + tal:attributes="src string: $appUrl/ui/locked.png; title lockMsg"/>