Make .active_ballot() available on DocumentInfo instead of on Document, to make charter history snapshots work.

- Legacy-Id: 4803
This commit is contained in:
Henrik Levkowetz 2012-08-23 10:08:41 +00:00
parent d23a769dd9
commit 7c78ed81ef

View file

@ -127,6 +127,12 @@ class DocumentInfo(models.Model):
def author_list(self):
return ", ".join(email.address for email in self.authors.all())
def active_ballot(self):
"""Returns the most recently created ballot if it isn't closed."""
ballot = self.latest_event(BallotDocEvent, type="created_ballot")
open = self.ballot_open(ballot.ballot_type.slug) if ballot else False
return ballot if open else None
class Meta:
abstract = True
@ -267,12 +273,6 @@ class Document(DocumentInfo):
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")
open = self.ballot_open(ballot.ballot_type.slug) if ballot else False
return ballot if open else None
def most_recent_ietflc(self):
"""Returns the most recent IETF LastCallDocEvent for this document"""
return self.latest_event(LastCallDocEvent,type="sent_last_call")