Commit 9dd7a36b authored by Michal Čihař's avatar Michal Čihař

Simplify lock detection

Signed-off-by: default avatarMichal Čihař <michal@cihar.com>
parent 59c545ed
......@@ -259,21 +259,16 @@ class Translation(models.Model, URLMixin, PercentMixin, LoggerMixin):
}
)
def is_locked(self, request=None, multi=False):
def is_locked(self, request=None):
'''
Check whether the translation is locked and
possibly emits messages if request object is
provided.
'''
prj_lock = self.subproject.locked
usr_lock = self.is_user_locked(request)
# Calculate return value
if multi:
return (prj_lock, usr_lock)
else:
return prj_lock or usr_lock
return (
self.is_user_locked(request) or
self.subproject.locked
)
def is_user_locked(self, request=None):
'''
......
......@@ -464,9 +464,8 @@ def translate(request, project, subproject, lang):
translation = get_translation(request, project, subproject, lang)
# Check locks
project_locked, user_locked = translation.is_locked(
request, True
)
user_locked = translation.is_user_locked(request)
project_locked = translation.subproject.locked
own_lock = self.lock_user == request.user
locked = project_locked or user_locked
......
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