From 1934cdb6093a96269dc3ea911776825768fe5ae7 Mon Sep 17 00:00:00 2001 From: Alban Gruin Date: Sun, 15 Apr 2018 15:25:16 +0200 Subject: Légères corrections PEP8 --- models.py | 11 ++++++----- views.py | 1 + 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/models.py b/models.py index f7450dc..e56d33d 100644 --- a/models.py +++ b/models.py @@ -31,7 +31,6 @@ class SlugModel(models.Model): super(SlugModel, self).save(*args, **kwargs) - class Meta: abstract = True @@ -106,11 +105,13 @@ class GroupManager(Manager): source=group.source) def get_relevant_groups(self, start, **criteria): - courses = Course.objects.filter(groups=OuterRef("pk"), begin__gte=start) \ + courses = Course.objects.filter(groups=OuterRef("pk"), + begin__gte=start) \ .only("pk")[:1] - return self.get_queryset().annotate(c=Subquery(courses, - output_field=models.IntegerField())) \ - .filter(c__isnull=False, **criteria).order_by("name") + return self.get_queryset() \ + .annotate(c=Subquery(courses, + output_field=models.IntegerField())) \ + .filter(c__isnull=False, **criteria).order_by("name") class Group(SlugModel): diff --git a/views.py b/views.py index bdbbdc2..de510a3 100644 --- a/views.py +++ b/views.py @@ -34,6 +34,7 @@ if connection.vendor == "postgresql": from django.contrib.postgres.aggregates import ArrayAgg from django.db.models.expressions import RawSQL + def index(request): years = Year.objects.order_by("name") return render(request, "index.html", {"elements": years}) -- cgit v1.2.1