Skip to content

Commit

Permalink
Merge pull request #1070 from vhf/hotfix-tuto-update
Browse files Browse the repository at this point in the history
Éditer un big-tuto donne une 500 #1068
  • Loading branch information
ArnaudCalmettes committed Jul 7, 2014
2 parents 6d93479 + de5a447 commit cff86c8
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions zds/tutorial/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,10 @@ def get_parts(self):
def get_chapter(self):
"""Gets the chapter associated with the tutorial if it's small."""
# We can use get since we know there'll only be one chapter
return Chapter.objects.get(tutorial__pk=self.pk)
try:
return Chapter.objects.get(tutorial__pk=self.pk)
except Chapter.DoesNotExist:
return None

def in_beta(self):
return (self.sha_beta is not None) and (self.sha_beta.strip() != '')
Expand Down Expand Up @@ -303,7 +306,7 @@ def last_read_note(self):
.latest('note__pubdate').note
except Note.DoesNotExist:
return self.first_post()

def first_unread_note(self):
"""Return the first note the user has unread."""
try:
Expand Down Expand Up @@ -344,11 +347,11 @@ def antispam(self, user=None):
if t.total_seconds() < settings.SPAM_LIMIT_SECONDS:
return True
return False

def update_children(self):
for part in self.get_parts():
part.update_children()

chapter = self.get_chapter()
if chapter:
chapter.update_children()
Expand Down Expand Up @@ -830,7 +833,7 @@ def get_path(self, relative=False):
return os.path.join(chapter_path, str(self.pk) + "_" + slugify(self.title)) + '.md'

def get_prod_path(self):

if self.chapter.tutorial:
data = self.chapter.tutorial.load_json_for_public()
mandata = tutorial.load_dic(data)
Expand Down

0 comments on commit cff86c8

Please sign in to comment.