fix: use the intended state machine in person doc searches (#5204)

* fix: use the intended state machine in  person doc searches

* chore: apply black to two touched functions
This commit is contained in:
Robert Sparks 2023-02-24 12:27:17 -06:00 committed by GitHub
parent 91be593c82
commit cbe534ee06
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -187,12 +187,31 @@ class Person(models.Model):
def active_drafts(self):
from ietf.doc.models import Document
return Document.objects.filter(documentauthor__person=self, type='draft', states__slug='active').distinct().order_by('-time')
return (
Document.objects.filter(
documentauthor__person=self,
type="draft",
states__type="draft",
states__slug="active",
)
.distinct()
.order_by("-time")
)
def expired_drafts(self):
from ietf.doc.models import Document
return Document.objects.filter(documentauthor__person=self, type='draft', states__slug__in=['repl', 'expired', 'auth-rm', 'ietf-rm']).distinct().order_by('-time')
return (
Document.objects.filter(
documentauthor__person=self,
type="draft",
states__type="draft",
states__slug__in=["repl", "expired", "auth-rm", "ietf-rm"],
)
.distinct()
.order_by("-time")
)
def save(self, *args, **kwargs):
created = not self.pk