@@ -807,20 +807,24 @@ def most_recent_occurrence(self):
807807 noc = self .next_occurrence ()
808808 if noc :
809809 return noc
810- aoc = []
811- for occurrence in self .occurrences .all ():
812- aoc += [instance for instance in occurrence .all_occurrences ()]
813- if len (aoc ) > 0 :
814- return aoc [- 1 ] # last one in the list
815810
816811 except AttributeError :
817812 # Triggers when a preview is initiated on an
818813 # EventPage because it uses a FakeQuerySet object.
819814 # Here we manually compute the next_occurrence
820815 occurrences = [e .next_occurrence () for e in self .occurrences .all ()]
821- if occurrences :
816+ # If there are no more occurrences, we find the last one instead
817+ if occurrences and None not in occurrences :
822818 return sorted (occurrences , key = lambda tup : tup [0 ])[0 ]
823819
820+ # If both of the above methods fail to find a future occurrence,
821+ # instead return the last occurrence.
822+ aoc = []
823+ for occurrence in self .occurrences .all ():
824+ aoc += [instance for instance in occurrence .all_occurrences ()]
825+ if len (aoc ) > 0 :
826+ return aoc [- 1 ] # last one in the list
827+
824828 @property
825829 def seo_struct_event_dict (self ) -> dict :
826830 next_occ = self .most_recent_occurrence
@@ -879,7 +883,6 @@ def query_occurrences(self, num_of_instances_to_return=None, **kwargs):
879883
880884 # For each occurrence rule in all of the occurrence rules for this event.
881885 for occurrence in self .occurrences .all ():
882-
883886 # Add the qualifying generated event instances to the list.
884887 event_instances += [
885888 instance
@@ -1280,7 +1283,6 @@ def process_data(self, form, request):
12801283 processed_data = {}
12811284 # Handle file uploads
12821285 for key , val in form .cleaned_data .items ():
1283-
12841286 if (
12851287 type (val ) == InMemoryUploadedFile
12861288 or type (val ) == TemporaryUploadedFile
@@ -1318,7 +1320,6 @@ def get_storage(self):
13181320 def process_form_submission (
13191321 self , request , form , form_submission , processed_data
13201322 ):
1321-
13221323 # Save to database
13231324 if self .save_to_database :
13241325 form_submission .save ()
@@ -1332,7 +1333,6 @@ def process_form_submission(
13321333 context = Context (self .data_to_dict (processed_data , request ))
13331334 # Render emails as if they are django templates.
13341335 for email in self .confirmation_emails .all ():
1335-
13361336 # Build email message parameters.
13371337 message_args = {}
13381338 # From
@@ -1437,7 +1437,6 @@ def send_mail(
14371437 message .send ()
14381438
14391439 def render_landing_page (self , request , form_submission = None ):
1440-
14411440 """
14421441 Renders the landing page.
14431442
@@ -1646,7 +1645,6 @@ class CoderedSubmissionRevision(SubmissionRevision, models.Model):
16461645
16471646
16481647class CoderedSessionFormSubmission (SessionFormSubmission ):
1649-
16501648 INCOMPLETE = "incomplete"
16511649 COMPLETE = "complete"
16521650 REVIEWED = "reviewed"
0 commit comments