issue #13 fixed
This commit is contained in:
parent
61a24fefb7
commit
de0ad4b210
@ -145,3 +145,26 @@ class VersionLogQuerySet(models.query.QuerySet, VersionLogMixin):
|
||||
class VersionLogManager(models.Manager, VersionLogMixin):
|
||||
def get_query_set(self):
|
||||
return VersionLogQuerySet(self.model, using=self._db)
|
||||
|
||||
|
||||
class EuscanResultMixin(object):
|
||||
def for_package(self, package):
|
||||
return self.filter(package=package)
|
||||
|
||||
def for_maintainer(self, maintainer):
|
||||
return self.filter(package__maintainers__id=maintainer.id)
|
||||
|
||||
def for_category(self, category):
|
||||
return self.filter(package__category=category)
|
||||
|
||||
def for_herd(self, herd):
|
||||
return self.filter(package__herds__id=herd.id)
|
||||
|
||||
|
||||
class EuscanResultQuerySet(models.query.QuerySet, EuscanResultMixin):
|
||||
pass
|
||||
|
||||
|
||||
class EuscanResultManager(models.Manager, EuscanResultMixin):
|
||||
def get_query_set(self):
|
||||
return EuscanResultQuerySet(self.model, using=self._db)
|
||||
|
@ -1,6 +1,7 @@
|
||||
from django.db import models
|
||||
|
||||
from djeuscan.managers import PackageManager, VersionLogManager
|
||||
from djeuscan.managers import PackageManager, VersionLogManager, \
|
||||
EuscanResultManager
|
||||
|
||||
|
||||
class Herd(models.Model):
|
||||
@ -135,6 +136,8 @@ class EuscanResult(models.Model):
|
||||
datetime = models.DateTimeField()
|
||||
result = models.TextField(blank=True)
|
||||
|
||||
objects = EuscanResultManager()
|
||||
|
||||
class Meta:
|
||||
get_latest_by = "datetime"
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
{% load url from future %}
|
||||
{% load timedelta %}
|
||||
|
||||
<?xml version="1.0" encoding="utf8"?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr">
|
||||
@ -57,6 +58,14 @@
|
||||
{% endblock %}
|
||||
</div>
|
||||
<div id="footer">
|
||||
<p>
|
||||
{% block last_scan %}
|
||||
{% if last_scan %}
|
||||
Last scan: {{ last_scan }} ({{ last_scan|timedelta }})
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Questions, Comments, Corrections ?
|
||||
Email: corentin.chary at gmail.com<br />
|
||||
|
@ -37,7 +37,12 @@ def logs(request):
|
||||
|
||||
@render_to('euscan/categories.html')
|
||||
def categories(request):
|
||||
return {'categories': Package.objects.categories()}
|
||||
try:
|
||||
last_scan = EuscanResult.objects.latest().datetime
|
||||
except EuscanResult.DoesNotExist:
|
||||
last_scan = None
|
||||
|
||||
return {'categories': Package.objects.categories(), 'last_scan': last_scan}
|
||||
|
||||
|
||||
@render_to('euscan/category.html')
|
||||
@ -46,39 +51,81 @@ def category(request, category):
|
||||
|
||||
if not packages:
|
||||
raise Http404
|
||||
return {'category': category, 'packages': packages}
|
||||
|
||||
try:
|
||||
last_scan = \
|
||||
EuscanResult.objects.for_category(category).latest().datetime
|
||||
except EuscanResult.DoesNotExist:
|
||||
last_scan = None
|
||||
|
||||
return {'category': category, 'packages': packages, 'last_scan': last_scan}
|
||||
|
||||
|
||||
@render_to('euscan/herds.html')
|
||||
def herds(request):
|
||||
herds = Package.objects.herds()
|
||||
return {'herds': herds}
|
||||
|
||||
try:
|
||||
last_scan = EuscanResult.objects.latest().datetime
|
||||
except EuscanResult.DoesNotExist:
|
||||
last_scan = None
|
||||
|
||||
return {'herds': herds, 'last_scan': last_scan}
|
||||
|
||||
|
||||
@render_to('euscan/herd.html')
|
||||
def herd(request, herd):
|
||||
herd = get_object_or_404(Herd, herd=herd)
|
||||
packages = Package.objects.for_herd(herd, last_versions=True)
|
||||
return {'herd': herd, 'packages': packages}
|
||||
|
||||
try:
|
||||
last_scan = EuscanResult.objects.for_herd(herd).latest().datetime
|
||||
except EuscanResult.DoesNotExist:
|
||||
last_scan = None
|
||||
|
||||
return {'herd': herd, 'packages': packages, "last_scan": last_scan}
|
||||
|
||||
|
||||
@render_to('euscan/maintainers.html')
|
||||
def maintainers(request):
|
||||
maintainers = Package.objects.maintainers()
|
||||
return {'maintainers': maintainers}
|
||||
|
||||
try:
|
||||
last_scan = EuscanResult.objects.latest().datetime
|
||||
except EuscanResult.DoesNotExist:
|
||||
last_scan = None
|
||||
|
||||
return {'maintainers': maintainers, 'last_scan': last_scan}
|
||||
|
||||
|
||||
@render_to('euscan/maintainer.html')
|
||||
def maintainer(request, maintainer_id):
|
||||
maintainer = get_object_or_404(Maintainer, pk=maintainer_id)
|
||||
packages = Package.objects.for_maintainer(maintainer, last_versions=True)
|
||||
return {'maintainer': maintainer, 'packages': packages}
|
||||
|
||||
try:
|
||||
last_scan = \
|
||||
EuscanResult.objects.for_maintainer(maintainer).latest().datetime
|
||||
except EuscanResult.DoesNotExist:
|
||||
last_scan = None
|
||||
|
||||
return {
|
||||
'maintainer': maintainer,
|
||||
'packages': packages,
|
||||
'last_scan': last_scan
|
||||
}
|
||||
|
||||
|
||||
@render_to('euscan/overlays.html')
|
||||
def overlays(request):
|
||||
overlays = Package.objects.overlays()
|
||||
return {'overlays': overlays}
|
||||
|
||||
try:
|
||||
last_scan = EuscanResult.objects.latest().datetime
|
||||
except EuscanResult.DoesNotExist:
|
||||
last_scan = None
|
||||
|
||||
return {'overlays': overlays, 'last_scan': last_scan}
|
||||
|
||||
|
||||
@render_to('euscan/overlay.html')
|
||||
@ -86,7 +133,13 @@ def overlay(request, overlay):
|
||||
packages = Package.objects.for_overlay(overlay)
|
||||
if not packages:
|
||||
raise Http404
|
||||
return {'overlay': overlay, 'packages': packages}
|
||||
|
||||
try:
|
||||
last_scan = EuscanResult.objects.latest().datetime
|
||||
except EuscanResult.DoesNotExist:
|
||||
last_scan = None
|
||||
|
||||
return {'overlay': overlay, 'packages': packages, 'last_scan': last_scan}
|
||||
|
||||
|
||||
@render_to('euscan/package.html')
|
||||
@ -103,8 +156,19 @@ def package(request, category, package):
|
||||
log = log[0] if log else None
|
||||
vlog = VersionLog.objects.for_package(package, order=True)
|
||||
|
||||
return {'package': package, 'packaged': packaged,
|
||||
'upstream': upstream, 'log': log, 'vlog': vlog}
|
||||
try:
|
||||
last_scan = EuscanResult.objects.for_package(package).latest().datetime
|
||||
except EuscanResult.DoesNotExist:
|
||||
last_scan = None
|
||||
|
||||
return {
|
||||
'package': package,
|
||||
'packaged': packaged,
|
||||
'upstream': upstream,
|
||||
'log': log,
|
||||
'vlog': vlog,
|
||||
'last_scan': last_scan
|
||||
}
|
||||
|
||||
|
||||
@render_to('euscan/world.html')
|
||||
|
Loading…
Reference in New Issue
Block a user