Skip to content

Commit

Permalink
first_lesson_url pointing to the first lesson of the course.
Browse files Browse the repository at this point in the history
  • Loading branch information
Leonardo Santagada committed Aug 2, 2013
1 parent 6dc5dae commit 3e5729a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion timtec/templates/course_intro.pt
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
<strong><i class="icon-tasks"></i> Dedicação extra:</strong> ${course.extra_dadication}
</p>
<ul class="no-bullet">
<li class="clearfix"><a href="aula.html" class="btn btn-large btn-course btn-tim span12">Começar o curso</a></li>
<li class="clearfix"><a href="${first_lesson_url}" class="btn btn-large btn-course btn-tim span12">Começar o curso</a></li>
<li tal:repeat="lesson course.lessons">
<span class="title">${lesson.name}</span>
${lesson.desc}
Expand Down
8 changes: 7 additions & 1 deletion timtec/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,13 @@ class CourseController(BaseView):
def intro(self):
course_slug = self.request.matchdict.get('course', 'dbsql')
course = DBSession.query(Course).filter(Course.slug == course_slug).first()
return {u'course': course}
first_lesson = DBSession.query(Course).filter(Course.slug == course_slug) \
.join(Course.lessons).filter(Lesson.position == 1).first()
if first_lesson:
first_lesson_url = self.request.route_path('lesson', course=course_slug, lesson=first_lesson.name)
else:
first_lesson_url = ''
return {u'course': course, u'first_lesson_url': first_lesson_url}

@view_config(route_name='lesson', renderer='templates/lesson.pt')
def lesson(self, course_slug=u'dbsql'):
Expand Down

0 comments on commit 3e5729a

Please sign in to comment.