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):
self.save()
def update_lock(self, request):
def update_lock(self, user):
'''
Updates lock timestamp.
'''
......@@ -354,7 +354,7 @@ class Translation(models.Model, URLMixin, PercentMixin, LoggerMixin):
# Auto lock if we should
if appsettings.AUTO_LOCK:
self.create_lock(request.user)
self.create_lock(user)
return
def _reverse_url_name(self):
......
......@@ -549,13 +549,13 @@ class Unit(models.Model, LoggerMixin):
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
if user is None:
user = request.user
# Update lock timestamp
self.translation.update_lock(user)
# Store to backend
try:
(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