summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--devel/views.py27
-rw-r--r--main/models.py24
-rw-r--r--templates/devel/index.html16
3 files changed, 18 insertions, 49 deletions
diff --git a/devel/views.py b/devel/views.py
index 002d2b5..77d4054 100644
--- a/devel/views.py
+++ b/devel/views.py
@@ -13,7 +13,6 @@ def index(request):
# get a list of incomplete package todo lists
todos = Todolist.objects.get_incomplete()
# get flagged-package stats for all maintainers
- stats = Package.objects.get_flag_stats()
if thismaint:
# get list of flagged packages for this maintainer
pkgs = Package.objects.filter(
@@ -22,29 +21,13 @@ def index(request):
else:
pkgs = None
- arch_stats = []
- for xarch in Arch.objects.all():
- arch_stats.append({
- 'name': xarch.name,
- 'count': Package.objects.filter(arch=xarch).count(),
- 'flagged': Package.objects.filter(arch=xarch).filter(
- needupdate=True).exclude(
- repo__name__iexact='testing').count()
- })
-
- repo_stats = []
- for xrepo in Repo.objects.all():
- repo_stats.append({
- 'name': xrepo.name,
- 'count': Package.objects.filter(repo=xrepo).count(),
- 'flagged': Package.objects.filter(
- repo=xrepo).filter(needupdate=True).count()
- })
-
return render_response(
request, 'devel/index.html',
- {'stats': stats, 'pkgs': pkgs, 'todos': todos, 'maint': thismaint,
- 'repos': repo_stats, 'arches': arch_stats})
+ {'pkgs': pkgs, 'todos': todos, 'maint': thismaint,
+ 'repos': Repo.objects.all(), 'arches': Arch.objects.all(),
+ 'maintainers':
+ [User(id=0, first_name="Orphans")] + list(User.objects.all())
+ })
#@is_maintainer
def change_notify(request):
diff --git a/main/models.py b/main/models.py
index e7566c3..a2323c6 100644
--- a/main/models.py
+++ b/main/models.py
@@ -49,23 +49,9 @@ class TodolistManager(models.Manager):
return results
class PackageManager(models.Manager):
- def get_flag_stats(self):
- results = []
- # first the orphans
- noflag = self.filter(maintainer=0)
- flagged = noflag.filter(
- needupdate=True).exclude(
- repo__name__iexact='testing')
- results.append(
- (User(id=0,first_name='Orphans'), noflag.count(), flagged.count()))
- # now the rest
- for maint in User.objects.all().order_by('first_name'):
- noflag = self.filter(maintainer=maint.id)
- flagged = noflag.filter(needupdate=True).exclude(
- repo__name__iexact='testing')
- results.append((maint, noflag.count(), flagged.count()))
- return results
+ def flagged(self):
+ return self.get_query_set().filter(needupdate=True)
#############################
### General Model Classes ###
@@ -151,9 +137,9 @@ class Repo(models.Model):
class Package(models.Model):
id = models.AutoField(primary_key=True)
- repo = models.ForeignKey(Repo)
- arch = models.ForeignKey(Arch)
- maintainer = models.ForeignKey(User, related_name='package_maintainer')
+ repo = models.ForeignKey(Repo, related_name="packages")
+ arch = models.ForeignKey(Arch, related_name="packages")
+ maintainer = models.ForeignKey(User, related_name="maintained_packages")
needupdate = models.BooleanField(default=False)
pkgname = models.CharField(max_length=255)
pkgver = models.CharField(max_length=255)
diff --git a/templates/devel/index.html b/templates/devel/index.html
index 33db1bf..8879496 100644
--- a/templates/devel/index.html
+++ b/templates/devel/index.html
@@ -33,8 +33,8 @@
{% for arch in arches %}
<tr class="{% cycle pkgr2,pkgr1 %}">
<td><strong>{{ arch.name }}</strong></td>
- <td><a href="/packages/?arch={{ arch.name }}"><strong>{{ arch.count }}</strong> packages</a></td>
- <td><a href="/packages/?arch={{ arch.name }}&flagged_only=y"><strong>{{ arch.flagged }}</strong> packages</a></td>
+ <td><a href="/packages/?arch={{ arch.name }}"><strong>{{ arch.packages.count }}</strong> packages</a></td>
+ <td><a href="/packages/?arch={{ arch.name }}&flagged_only=y"><strong>{{ arch.packages.flagged.count }}</strong> packages</a></td>
</tr>
{% endfor %}
</table>
@@ -51,8 +51,8 @@
{% for repo in repos %}
<tr class="{% cycle pkgr2,pkgr1 %}">
<td><strong>{{ repo.name }}</strong></td>
- <td><a href="/packages/?repo={{ repo.name }}"><strong>{{ repo.count }}</strong> packages</a></td>
- <td><a href="/packages/?repo={{ repo.name }}&flagged_only=y"><strong>{{ repo.flagged }}</strong> packages</a></td>
+ <td><a href="/packages/?repo={{ repo.name }}"><strong>{{ repo.packages.count }}</strong> packages</a></td>
+ <td><a href="/packages/?repo={{ repo.name }}&flagged_only=y"><strong>{{ repo.packages.flagged.count }}</strong> packages</a></td>
</tr>
{% endfor %}
</table>
@@ -67,11 +67,11 @@
<th># Packages</th>
<th># Flagged</th>
</tr>
- {% for maint in stats %}
+ {% for maint in maintainers %}
<tr class="{% cycle pkgr2,pkgr1 %}">
- <td><strong>{{ maint.0.get_full_name }}</strong></td>
- <td><a href="/packages/?maint={{ maint.0.id }}"><strong>{{ maint.1 }}</strong> packages</a></td>
- <td><a href="/packages/?maint={{ maint.0.id }}&flagged_only=y"><strong>{{ maint.2 }}</strong> packages</a></td>
+ <td><strong>{{ maint.get_full_name }}</strong></td>
+ <td><a href="/packages/?maint={{ maint.id }}"><strong>{{ maint.maintained_packages.count }}</strong> packages</a></td>
+ <td><a href="/packages/?maint={{ maint.id }}&flagged_only=y"><strong>{{ maint.maintained_packages.flagged.count }}</strong> packages</a></td>
</tr>
{% endfor %}
</table>