Commit 8fd2d367 authored by Guilhem Saurel's avatar Guilhem Saurel
Browse files

Contributor: Gepettists QuerySet

parent 2bd3b3e6
Pipeline #891 failed with stages
in 45 seconds
from django.contrib.admin import site
from django.contrib.admin import ModelAdmin, site
from . import models
......@@ -12,8 +12,11 @@ for model in [
models.Image,
models.Tag,
models.Target,
models.Contributor,
models.ContributorName,
models.ContributorMail,
]:
site.register(model)
class ContributorAdmin(ModelAdmin):
def queryset(self, request):
return super().queryset(request).gepettist()
......@@ -696,10 +696,17 @@ class Tag(models.Model):
return f'{self.project} {self.name}'
class GepettistQuerySet(models.QuerySet):
def gepettist(self):
return self.filter(projects__from_gepetto=True)
class Contributor(models.Model):
projects = models.ManyToManyField(Project)
agreement_signed = models.BooleanField(default=False)
objects = GepettistQuerySet.as_manager()
def __str__(self):
name = self.contributorname_set.first()
mail = self.contributormail_set.first()
......
......@@ -85,7 +85,7 @@ class DistinctMixin(object):
class ContributorsView(SingleTableMixin, DistinctMixin, FilterView):
queryset = models.Contributor.objects.filter(projects__from_gepetto=True)
queryset = models.Contributor.objects.gepettist()
table_class = tables.ContributorProjectTable
filterset_class = filters.ContributorFilter
......
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