Skip to content

Commit

Permalink
Add side card for the self-paced courses
Browse files Browse the repository at this point in the history
Helps with: #255
  • Loading branch information
encukou committed Oct 29, 2017
1 parent 28570e6 commit c6b9205
Show file tree
Hide file tree
Showing 3 changed files with 113 additions and 36 deletions.
22 changes: 22 additions & 0 deletions naucse/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,13 +117,35 @@ def course(course):
def lesson_url(lesson, *args, **kwargs):
return url_for('course_page', course=course, lesson=lesson, *args, **kwargs)

recent_runs = []
if not course.start_date:
# Build a list of "recent" runs based on this course.
# By recent we mean: haven't ended yet, or ended up to ~2 months ago
# (Note: even if naucse is hosted dynamically,
# it's still beneficial to show recently ended runs.)
today = datetime.date.today()
cutoff = today - datetime.timedelta(days=2*30)
this_year = today.year
for year, run_year in reversed(course.root.run_years.items()):
for run in run_year.runs.values():
if run.base_course is course and run.end_date > cutoff:
recent_runs.append(run)
if year < this_year:
# Assume no run lasts for more than a year,
# e.g. if it's Jan 2018, some run that started in 2017 may
# be included, but don't even look through runs from 2016
# or earlier.
break
recent_runs.sort(key=lambda r: r.start_date, reverse=True)

try:
return render_template(
'course.html',
course=course,
plan=course.sessions,
title=course.title,
lesson_url=lesson_url,
recent_runs=recent_runs,
**vars_functions(course.vars),
edit_path=course.edit_path)
except TemplateNotFound:
Expand Down
4 changes: 4 additions & 0 deletions naucse/static/css/nausce.css
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@ a:hover {
margin-bottom: 1rem;
}

.course-card .recent-runs li {
margin-top: 1em;
}

/*************************/

pre {
Expand Down
123 changes: 87 additions & 36 deletions naucse/templates/course.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,45 +28,16 @@
<hr>
</header>

{% if course.start_date %}
<div class="course-dates card w-lg-25 float-lg-right text-center">
<div class="card-header">
{% if course.vars['coach-present'] %}
Kurz s instruktorem
{% else %}
Termín kurzu
{% endif %}
</div>
<div class="card-body">
<div class="calendar-dates">
{{ (course.start_date, course.end_date) | format_date_range }}
</div>
</div>
<div class="card-footer small text-left">
<ul class="list-unstyled" style="margin-bottom:0;">
<li>
<a href="{{ url_for('course_calendar', course=course) }}">→ Kalendář</a>
</li>
{% if course.base_course %}
<li>
<a href="{{ course_url(course.base_course) }}">→ Ekvivalentní kurz pro samouky</a>
</li>
{% endif %}
</ul>
</div>
</div>
{% endif %}

<h1>{{ course.title }}</h1>
<div class="row">
<div class="col-md-8">
<h1>{{ course.title }}</h1>

{% if course.subtitle is defined and course.subtitle != None %}
<h2>{{ course.subtitle }}</h2>
{% endif%}
{% if course.subtitle is defined and course.subtitle != None %}
<h2>{{ course.subtitle }}</h2>
{% endif%}

{{ course.long_description | markdown }}
{{ course.long_description | markdown }}

<div class="row">
<div class="sections col-xs-12 col-sm-12 col-md-8 col-lg-8">
{% for session in plan.values() %}
<div class="section{{ loop.index }}">
<h4>
Expand All @@ -85,8 +56,88 @@ <h4>
{% endfor %}
</div>
{% endfor %}

</div>
<div class="col-md-4">
{% if course.start_date %}
<div class="card course-card text-center">
<div class="card-header">
Toto jsou podklady pro kurz s instruktorem
</div>
<div class="card-body">
<div class="calendar-dates">
{{ (course.start_date, course.end_date) | format_date_range }}
</div>
</div>
<div class="card-footer small text-left">
<ul class="list-unstyled" style="margin-bottom:0;">
<li>
<a href="{{ url_for('course_calendar', course=course) }}">→ Kalendář</a>
</li>
{% if course.base_course %}
<li>
<a href="{{ course_url(course.base_course) }}">→ Ekvivalentní kurz pro samouky</a>
</li>
{% endif %}
</ul>
</div>
</div>
{% else %}
<div class="card course-card">
<div class="card-header text-center">
Toto jsou materiály pro samouky
</div>
<div class="card-body">
<p>
Doufáme, že naše materiály jsou srozumitelné a přínosné.
Pokud ne, ozvěte se prosím:
</p>
<ul>
<li>
na <a href="https://www.facebook.com/groups/pyonieri/">Facebooku</a>,
</li>
<li>
založením <a href="https://github.com/pyvec/naucse.python.cz/issues/new"><i>issue</i> na Githubu</a>,
</li>
<li>
osobně na <a href="https://pyvo.cz/">srazu</a>, nebo
</li>
<li>
<a href="mailto:[email protected]">mailem</a> do
<a href="https://groups.google.com/forum/#!forum/django-cs">diskusní skupiny</a>.
</li>
</ul>
<p>
Případné nejasnosti rádi vysvětlíme,
ale musíme o nich vědět!
</p>
</div>
{% if recent_runs %}
<div class="card-footer recent-runs">
Na těchto materiálech jshou založeny
i kurzy s instruktorem:
<ul class="list-unstyled">
{% for run in recent_runs %}
<li>
<a href="{{ url_for('course', course=run) }}">
{{ run.title }}
{% if run.subtitle %}
– {{ run.subtitle }}
{% endif %}
</a>
<div>
{{ (run.start_date, run.end_date) | format_date_range }}
</div>
</li>
{% endfor %}
</ul>
</div>
{% endif %}
</div>
{% endif %}
</div>
</div>

</section>
</div>

Expand Down

0 comments on commit c6b9205

Please sign in to comment.