Commit ef1da0a5 authored by Michal Čihař's avatar Michal Čihař

Decouple locking from request

Signed-off-by: default avatarMichal Čihař <michal@cihar.com>
parent f0c783ae
...@@ -343,7 +343,7 @@ class Translation(models.Model, URLMixin, PercentMixin, LoggerMixin): ...@@ -343,7 +343,7 @@ class Translation(models.Model, URLMixin, PercentMixin, LoggerMixin):
self.save() self.save()
def update_lock(self, request): def update_lock(self, user):
''' '''
Updates lock timestamp. Updates lock timestamp.
''' '''
...@@ -354,7 +354,7 @@ class Translation(models.Model, URLMixin, PercentMixin, LoggerMixin): ...@@ -354,7 +354,7 @@ class Translation(models.Model, URLMixin, PercentMixin, LoggerMixin):
# Auto lock if we should # Auto lock if we should
if appsettings.AUTO_LOCK: if appsettings.AUTO_LOCK:
self.create_lock(request.user) self.create_lock(user)
return return
def _reverse_url_name(self): def _reverse_url_name(self):
......
...@@ -549,13 +549,13 @@ class Unit(models.Model, LoggerMixin): ...@@ -549,13 +549,13 @@ class Unit(models.Model, LoggerMixin):
Optional user parameters defines authorship of a change. Optional user parameters defines authorship of a change.
""" """
# Update lock timestamp
self.translation.update_lock(request)
# For case when authorship specified, use user from request # For case when authorship specified, use user from request
if user is None: if user is None:
user = request.user user = request.user
# Update lock timestamp
self.translation.update_lock(user)
# Store to backend # Store to backend
try: try:
(saved, pounit) = self.translation.update_unit(self, request, user) (saved, pounit) = self.translation.update_unit(self, request, user)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment