Make .ballot_open() available on DocumentInfo instead of on Document, too.

- Legacy-Id: 4807
This commit is contained in:
Henrik Levkowetz 2012-08-24 08:13:33 +00:00
parent fc22a660e7
commit c245f6a020

View file

@ -127,6 +127,12 @@ class DocumentInfo(models.Model):
def author_list(self):
return ", ".join(email.address for email in self.authors.all())
# This, and several other ballot related functions here, assume that there is only one active ballot for a document at any point in time.
# If that assumption is violated, they will only expose the most recently created ballot
def ballot_open(self, ballot_type_slug):
e = self.latest_event(BallotDocEvent, ballot_type__slug=ballot_type_slug)
return e and not e.type == "closed_ballot"
def active_ballot(self):
"""Returns the most recently created ballot if it isn't closed."""
ballot = self.latest_event(BallotDocEvent, type="created_ballot")
@ -267,12 +273,6 @@ class Document(DocumentInfo):
return self.latest_event(type="changed_document", desc__startswith="State changed to <b>IESG Evaluation - Defer</b>")
return None
# This, and several other ballot related functions here, assume that there is only one active ballot for a document at any point in time.
# If that assumption is violated, they will only expose the most recently created ballot
def ballot_open(self, ballot_type_slug):
e = self.latest_event(BallotDocEvent, ballot_type__slug=ballot_type_slug)
return e and not e.type == "closed_ballot"
def most_recent_ietflc(self):
"""Returns the most recent IETF LastCallDocEvent for this document"""
return self.latest_event(LastCallDocEvent,type="sent_last_call")