Commit 36407b10 authored by Michal Čihař's avatar Michal Čihař

Do not list repositories multiple time in status

Fixes #670
Signed-off-by: default avatarMichal Čihař <michal@cihar.com>
parent dcdb7109
...@@ -52,14 +52,12 @@ ...@@ -52,14 +52,12 @@
<div class="panel panel-primary"> <div class="panel panel-primary">
<div class="panel-heading"><h4 class="panel-title">{% trans "Repository details" %}</h4></div> <div class="panel-heading"><h4 class="panel-title">{% trans "Repository details" %}</h4></div>
<div class="panel-body"> <div class="panel-body">
{% if object.subproject_set %} {% for status in statuses %}
{% for sp in object.subproject_set.all %} {% if status.0 %}
<h4>{{ sp }}</h3> <h4>{{ status.0 }}</h4>
<pre>{{ sp.repository.status }}</pre>
{% endfor %}
{% else %}
<pre>{{ object.repository.status }}</pre>
{% endif %} {% endif %}
<pre>{{ status.1 }}</pre>
{% endfor %}
</div> </div>
</div> </div>
......
...@@ -767,12 +767,15 @@ class SubProject(models.Model, PercentMixin, URLMixin, PathMixin): ...@@ -767,12 +767,15 @@ class SubProject(models.Model, PercentMixin, URLMixin, PathMixin):
return True return True
def get_repo_link_url(self):
return 'weblate://%s/%s' % (self.project.slug, self.slug)
def get_linked_childs(self): def get_linked_childs(self):
''' '''
Returns list of subprojects which link repository to us. Returns list of subprojects which link repository to us.
''' '''
return SubProject.objects.filter( return SubProject.objects.filter(
repo='weblate://%s/%s' % (self.project.slug, self.slug) repo=self.get_repo_link_url()
) )
def commit_pending(self, request, from_link=False, skip_push=False): def commit_pending(self, request, from_link=False, skip_push=False):
......
...@@ -132,6 +132,25 @@ def ignore_check(request, check_id): ...@@ -132,6 +132,25 @@ def ignore_check(request, check_id):
def git_status_project(request, project): def git_status_project(request, project):
obj = get_project(request, project) obj = get_project(request, project)
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,
))
return render( return render(
request, request,
'js/git-status.html', 'js/git-status.html',
...@@ -141,6 +160,7 @@ def git_status_project(request, project): ...@@ -141,6 +160,7 @@ def git_status_project(request, project):
subproject__project=obj, subproject__project=obj,
action__in=Change.ACTIONS_REPOSITORY, action__in=Change.ACTIONS_REPOSITORY,
)[:10], )[:10],
'statuses': statuses,
} }
) )
...@@ -161,6 +181,7 @@ def git_status_subproject(request, project, subproject): ...@@ -161,6 +181,7 @@ def git_status_subproject(request, project, subproject):
action__in=Change.ACTIONS_REPOSITORY, action__in=Change.ACTIONS_REPOSITORY,
subproject=obj, subproject=obj,
)[:10], )[:10],
'statuses': [(None, obj.repository.status)],
} }
) )
...@@ -181,6 +202,7 @@ def git_status_translation(request, project, subproject, lang): ...@@ -181,6 +202,7 @@ def git_status_translation(request, project, subproject, lang):
action__in=Change.ACTIONS_REPOSITORY, action__in=Change.ACTIONS_REPOSITORY,
subproject=obj.subproject, subproject=obj.subproject,
)[:10], )[:10],
'statuses': [(None, obj.subproject.repository.status)],
} }
) )
......
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