Skip to content

Commit

Permalink
Project: Add lock indicator in case all components are locked
Browse files Browse the repository at this point in the history
Fixes #3365

Signed-off-by: Michal Čihař <michal@cihar.com>
  • Loading branch information
nijel committed Jan 13, 2020
1 parent 2f147ac commit 9609734
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
2 changes: 2 additions & 0 deletions docs/changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ Weblate 3.11

Not yet released.

* Add lock indication to projects.

Weblate 3.10.1
--------------

Expand Down
7 changes: 5 additions & 2 deletions weblate/trans/models/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,12 @@ def get_share_url(self):
"""Return absolute URL usable for sharing."""
return get_site_url(reverse('engage', kwargs={'project': self.slug}))

@property
@cached_property
def locked(self):
return any((component.locked for component in self.component_set.iterator()))
return (
self.component_set.exists()
and not self.component_set.filter(locked=False).exists()
)

def _get_path(self):
return os.path.join(data_dir('vcs'), self.slug)
Expand Down
5 changes: 5 additions & 0 deletions weblate/trans/templatetags/translations.py
Original file line number Diff line number Diff line change
Expand Up @@ -783,6 +783,11 @@ def indicate_alerts(context, obj):
)
)

if project.locked:
result.append(
("state/lock.svg", ugettext("This translation is locked."), None)
)

return {"icons": result, "component": component, "project": project}


Expand Down

0 comments on commit 9609734

Please sign in to comment.