Skip to content

Commit c3ff43d

Browse files
committed
Merged in [8843] from rjsparks@nostrum.com:\n Reworked the definition of future_presentations and last_presented. Fixes ietf-tools#1571.
- Legacy-Id: 8876 Note: SVN reference [8843] has been migrated to Git commit 8037913
1 parent 0f3f53d commit c3ff43d

1 file changed

Lines changed: 23 additions & 18 deletions

File tree

ietf/doc/models.py

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -195,24 +195,6 @@ def meeting_related(self):
195195
else:
196196
return False
197197

198-
def future_presentations(self):
199-
""" returns related SessionPresentation objects for meetings that
200-
have not yet ended. This implementation allows for 2 week meetings """
201-
candidate_presentations = self.sessionpresentation_set.filter(session__meeting__date__gte=datetime.date.today()-datetime.timedelta(days=15))
202-
return sorted([pres for pres in candidate_presentations if pres.session.meeting.end_date()>=datetime.date.today()], key=lambda x:x.session.meeting.date)
203-
204-
def last_presented(self):
205-
""" returns related SessionPresentation objects for the most recent meeting in the past"""
206-
# Assumes no two meetings have the same start date - if the assumption is violated, one will be chosen arbitrariy
207-
candidate_presentations = self.sessionpresentation_set.filter(session__meeting__date__lte=datetime.date.today())
208-
candidate_meetings = set([p.session.meeting for p in candidate_presentations if p.session.meeting.end_date()<datetime.date.today()])
209-
if candidate_meetings:
210-
mtg = sorted(list(candidate_meetings),key=lambda x:x.date,reverse=True)[0]
211-
return self.sessionpresentation_set.filter(session__meeting=mtg)
212-
else:
213-
return None
214-
215-
216198
class Meta:
217199
abstract = True
218200

@@ -505,6 +487,23 @@ def related_ipr(self):
505487
aliases = IprDocAlias.objects.filter(doc_alias__in=list(self.docalias_set.all())+self.all_related_that_doc(['obs','replaces'])).filter(ipr__status__in=[1,3]).values_list('ipr', flat=True).distinct()
506488
return aliases
507489

490+
def future_presentations(self):
491+
""" returns related SessionPresentation objects for meetings that
492+
have not yet ended. This implementation allows for 2 week meetings """
493+
candidate_presentations = self.sessionpresentation_set.filter(session__meeting__date__gte=datetime.date.today()-datetime.timedelta(days=15))
494+
return sorted([pres for pres in candidate_presentations if pres.session.meeting.end_date()>=datetime.date.today()], key=lambda x:x.session.meeting.date)
495+
496+
def last_presented(self):
497+
""" returns related SessionPresentation objects for the most recent meeting in the past"""
498+
# Assumes no two meetings have the same start date - if the assumption is violated, one will be chosen arbitrariy
499+
candidate_presentations = self.sessionpresentation_set.filter(session__meeting__date__lte=datetime.date.today())
500+
candidate_meetings = set([p.session.meeting for p in candidate_presentations if p.session.meeting.end_date()<datetime.date.today()])
501+
if candidate_meetings:
502+
mtg = sorted(list(candidate_meetings),key=lambda x:x.date,reverse=True)[0]
503+
return self.sessionpresentation_set.filter(session__meeting=mtg)
504+
else:
505+
return None
506+
508507
class RelatedDocHistory(models.Model):
509508
source = models.ForeignKey('DocHistory')
510509
target = models.ForeignKey('DocAlias', related_name="reversely_related_document_history_set")
@@ -542,6 +541,12 @@ def latest_event(self, *args, **kwargs):
542541
kwargs["time__lte"] = self.time
543542
return self.doc.latest_event(*args, **kwargs)
544543

544+
def future_presentations(self):
545+
return self.doc.future_presentations()
546+
547+
def last_presented(self):
548+
return self.doc.last_presented()
549+
545550
class Meta:
546551
verbose_name = "document history"
547552
verbose_name_plural = "document histories"

0 commit comments

Comments
 (0)