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

Factor out code for iterating over components with unique repos

Signed-off-by: default avatarMichal Čihař <michal@cihar.com>
parent cf1807b9
......@@ -447,6 +447,25 @@ class Project(models.Model, PercentMixin, URLMixin, PathMixin):
return None
return max(changes)
def all_repo_components(self):
"""Returns list of all unique VCS components."""
result = list(
self.subproject_set.exclude(repo__startswith='weblate://')
)
included = set(
[component.get_repo_link_url() for component in result]
)
result.extend(
self.subproject_set.filter(
repo__startswith='weblate://'
).exclude(
repo__in=included
)
)
return result
@receiver(m2m_changed, sender=User.user_permissions.through)
def user_permissions_changed(sender, instance, action, **kwargs):
......
......@@ -139,24 +139,10 @@ def git_status_project(request, project):
if not can_see_repository_status(request.user, obj):
raise PermissionDenied()
statuses = []
included = set()
not_linked = obj.subproject_set.exclude(repo__startswith='weblate://')
linked = obj.subproject_set.filter(repo__startswith='weblate://')
for subproject in not_linked:
statuses.append((
subproject.__unicode__(),
subproject.repository.status,
))
included.add(subproject.get_repo_link_url())
for subproject in linked.exclude(repo__in=included):
statuses.append((
subproject.__unicode__(),
subproject.repository.status,
))
statuses = [
(component.__unicode__(), component.repository.status)
for component in obj.all_repo_components()
]
return render(
request,
......
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