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): ...@@ -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 Check whether the translation is locked and
possibly emits messages if request object is possibly emits messages if request object is
provided. provided.
''' '''
return (
prj_lock = self.subproject.locked self.is_user_locked(request) or
usr_lock = self.is_user_locked(request) self.subproject.locked
)
# Calculate return value
if multi:
return (prj_lock, usr_lock)
else:
return prj_lock or usr_lock
def is_user_locked(self, request=None): def is_user_locked(self, request=None):
''' '''
......
...@@ -464,9 +464,8 @@ def translate(request, project, subproject, lang): ...@@ -464,9 +464,8 @@ def translate(request, project, subproject, lang):
translation = get_translation(request, project, subproject, lang) translation = get_translation(request, project, subproject, lang)
# Check locks # Check locks
project_locked, user_locked = translation.is_locked( user_locked = translation.is_user_locked(request)
request, True project_locked = translation.subproject.locked
)
own_lock = self.lock_user == request.user own_lock = self.lock_user == request.user
locked = project_locked or user_locked 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