@@ -144,7 +144,10 @@ def get_parts(self):
144
144
def get_chapter (self ):
145
145
"""Gets the chapter associated with the tutorial if it's small."""
146
146
# We can use get since we know there'll only be one chapter
147
- return Chapter .objects .get (tutorial__pk = self .pk )
147
+ try :
148
+ return Chapter .objects .get (tutorial__pk = self .pk )
149
+ except Chapter .DoesNotExist :
150
+ return None
148
151
149
152
def in_beta (self ):
150
153
return (self .sha_beta is not None ) and (self .sha_beta .strip () != '' )
@@ -303,7 +306,7 @@ def last_read_note(self):
303
306
.latest ('note__pubdate' ).note
304
307
except Note .DoesNotExist :
305
308
return self .first_post ()
306
-
309
+
307
310
def first_unread_note (self ):
308
311
"""Return the first note the user has unread."""
309
312
try :
@@ -344,11 +347,11 @@ def antispam(self, user=None):
344
347
if t .total_seconds () < settings .SPAM_LIMIT_SECONDS :
345
348
return True
346
349
return False
347
-
350
+
348
351
def update_children (self ):
349
352
for part in self .get_parts ():
350
353
part .update_children ()
351
-
354
+
352
355
chapter = self .get_chapter ()
353
356
if chapter :
354
357
chapter .update_children ()
@@ -830,7 +833,7 @@ def get_path(self, relative=False):
830
833
return os .path .join (chapter_path , str (self .pk ) + "_" + slugify (self .title )) + '.md'
831
834
832
835
def get_prod_path (self ):
833
-
836
+
834
837
if self .chapter .tutorial :
835
838
data = self .chapter .tutorial .load_json_for_public ()
836
839
mandata = tutorial .load_dic (data )
0 commit comments