accordion.html 1.89 KB
Newer Older
1 2
<%!
    from django.core.urlresolvers import reverse
3
    from util.date_utils import get_time_display
4
    from django.utils.translation import ugettext as _
5
    from django.conf import settings
6
%>
7

pmitros committed
8
<%def name="make_chapter(chapter)">
9
  <div class="chapter">
10 11 12 13 14 15 16 17 18
      <%
          if chapter.get('active'):
              aria_label = _('{chapter}, current chapter').format(chapter=chapter['display_name'])
              active_class = ' class="active"'
          else:
              aria_label = chapter['display_name']
              active_class = ''
      %>
      <h3 ${active_class} aria-label="${aria_label}">
19 20 21 22
        <a href="#">
          ${chapter['display_name']}
        </a>
      </h3>
kylefiedler committed
23

24 25
    <ul>
      % for section in chapter['sections']:
26
          <li class="${'active' if 'active' in section and section['active'] else ''} ${'graded'  if 'graded' in section and section['graded'] else ''}">
27
            <a href="${reverse('courseware_section', args=[course_id, chapter['url_name'], section['url_name']])}">
28
              <p>${section['display_name']} ${'<span class="sr">, current section</span>' if 'active' in section and section['active'] else ''}</p>
29 30 31 32
              <%
                if section.get('due') is None:
                    due_date = ''
                else:
33
                    formatted_string = get_time_display(section['due'], due_date_display_format, coerce_tz=settings.TIME_ZONE_DISPLAYED_FOR_DEADLINES)
34
                    due_date = '' if len(formatted_string)==0 else _('due {date}').format(date=formatted_string)
35 36
              %>
              <p class="subtitle">${section['format']} ${due_date}</p>
37 38 39 40

              % if 'graded' in section and section['graded']:
                  <img src="/static/images/graded.png" alt="Graded Section">
              % endif
41 42 43 44 45
            </a>
          </li>
      % endfor
    </ul>
  </div>
46
</%def>
pmitros committed
47 48 49 50

% for chapter in toc:
    ${make_chapter(chapter)}
% endfor