fairly invasive refactor to developer dashboard to be more django friendly
This commit is contained in:
parent
3d4775486e
commit
fb9158dec8
@ -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):
|
||||
|
@ -49,23 +49,9 @@ def get_incomplete(self):
|
||||
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 Meta:
|
||||
|
||||
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)
|
||||
|
@ -33,8 +33,8 @@ <h3 class="title">Stats by Architecture</h3>
|
||||
{% 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 @@ <h3 class="title">Stats by Repository</h3>
|
||||
{% 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 @@ <h3 class="title">Stats by Maintainer</h3>
|
||||
<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>
|
||||
|
Loading…
Reference in New Issue
Block a user