class LessonAdmin(admin.ModelAdmin):
inlines = [AttachmentInline]
+ list_display = ['title', 'section', 'type']
admin.site.register(Section)
admin.site.register(Lesson, LessonAdmin)
from django.core.files import File
from librarian import IOFile
-from catalogue.models import Lesson
+from catalogue.models import Lesson, Section
#from search import Index
sys.stdout.flush()
# Import book files
- self.import_book(file_path, options)
- files_imported += 1
- transaction.commit()
+ try:
+ self.import_book(file_path, options)
+ files_imported += 1
+ transaction.commit()
+ except Section.IncompleteError:
+ if file_name not in postponed or postponed[file_name] < files_imported:
+ # Push it back into the queue, maybe the missing lessons will show up.
+ if verbose > 0:
+ print self.style.NOTICE('Waiting for missing lessons.')
+ files.append(file_name)
+ postponed[file_name] = files_imported
+ else:
+ # We're in a loop, nothing's being imported - some lesson is really missing.
+ raise e
+ except BaseException, e:
+ print e
+ files_skipped += 1
# Print results
print
--- /dev/null
+# -*- coding: utf-8 -*-
+import datetime
+from south.db import db
+from south.v2 import SchemaMigration
+from django.db import models
+
+
+class Migration(SchemaMigration):
+
+ def forwards(self, orm):
+ # Adding field 'Lesson.type'
+ db.add_column('catalogue_lesson', 'type',
+ self.gf('django.db.models.fields.CharField')(default='course', max_length=15, db_index=True),
+ keep_default=False)
+
+ # Changing field 'Lesson.section'
+ db.alter_column('catalogue_lesson', 'section_id', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['catalogue.Section'], null=True))
+ # Adding index on 'Lesson', fields ['order']
+ db.create_index('catalogue_lesson', ['order'])
+
+ if not db.dry_run:
+ orm.Lesson.objects.filter(depth=0).update(type='synthetic')
+
+
+ def backwards(self, orm):
+ # Removing index on 'Lesson', fields ['order']
+ db.delete_index('catalogue_lesson', ['order'])
+
+ # Deleting field 'Lesson.type'
+ db.delete_column('catalogue_lesson', 'type')
+
+ section = 0
+ if not db.dry_run:
+ orm.Lesson.objects.filter(type='synthetic').update(depth=0)
+ try:
+ section = orm.Section.objects.all()[0]
+ except orm.Section.DoesNotExist:
+ pass
+
+ # Changing field 'Lesson.section'
+ db.alter_column('catalogue_lesson', 'section_id',
+ self.gf('django.db.models.fields.related.ForeignKey')(default=section, to=orm['catalogue.Section']))
+
+
+ models = {
+ 'catalogue.attachment': {
+ 'Meta': {'ordering': "['slug', 'ext']", 'unique_together': "(['lesson', 'slug', 'ext'],)", 'object_name': 'Attachment'},
+ 'ext': ('django.db.models.fields.CharField', [], {'max_length': '15'}),
+ 'file': ('django.db.models.fields.files.FileField', [], {'max_length': '100'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'lesson': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['catalogue.Lesson']"}),
+ 'slug': ('django.db.models.fields.CharField', [], {'max_length': '255'})
+ },
+ 'catalogue.lesson': {
+ 'Meta': {'ordering': "['section', 'level', 'order']", 'object_name': 'Lesson'},
+ 'dc': ('jsonfield.fields.JSONField', [], {'default': "'{}'"}),
+ 'depth': ('django.db.models.fields.IntegerField', [], {}),
+ 'html_file': ('django.db.models.fields.files.FileField', [], {'max_length': '100', 'null': 'True', 'blank': 'True'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'level': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['curriculum.Level']"}),
+ 'order': ('django.db.models.fields.IntegerField', [], {'db_index': 'True'}),
+ 'package': ('django.db.models.fields.files.FileField', [], {'max_length': '100', 'null': 'True', 'blank': 'True'}),
+ 'pdf': ('django.db.models.fields.files.FileField', [], {'max_length': '100', 'null': 'True', 'blank': 'True'}),
+ 'section': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['catalogue.Section']", 'null': 'True', 'blank': 'True'}),
+ 'slug': ('django.db.models.fields.SlugField', [], {'unique': 'True', 'max_length': '50'}),
+ 'student_package': ('django.db.models.fields.files.FileField', [], {'max_length': '100', 'null': 'True', 'blank': 'True'}),
+ 'student_pdf': ('django.db.models.fields.files.FileField', [], {'max_length': '100', 'null': 'True', 'blank': 'True'}),
+ 'title': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
+ 'type': ('django.db.models.fields.CharField', [], {'max_length': '15', 'db_index': 'True'}),
+ 'xml_file': ('django.db.models.fields.files.FileField', [], {'max_length': '100', 'null': 'True', 'blank': 'True'})
+ },
+ 'catalogue.part': {
+ 'Meta': {'object_name': 'Part'},
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'lesson': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['catalogue.Lesson']"}),
+ 'pdf': ('django.db.models.fields.files.FileField', [], {'max_length': '100', 'null': 'True', 'blank': 'True'}),
+ 'student_pdf': ('django.db.models.fields.files.FileField', [], {'max_length': '100', 'null': 'True', 'blank': 'True'})
+ },
+ 'catalogue.section': {
+ 'Meta': {'ordering': "['order']", 'object_name': 'Section'},
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'order': ('django.db.models.fields.IntegerField', [], {}),
+ 'slug': ('django.db.models.fields.SlugField', [], {'unique': 'True', 'max_length': '50'}),
+ 'title': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'})
+ },
+ 'curriculum.level': {
+ 'Meta': {'ordering': "['order']", 'object_name': 'Level'},
+ 'group': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'name': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
+ 'order': ('django.db.models.fields.IntegerField', [], {}),
+ 'slug': ('django.db.models.fields.CharField', [], {'max_length': '255'})
+ }
+ }
+
+ complete_apps = ['catalogue']
--- /dev/null
+# -*- coding: utf-8 -*-
+import datetime
+from south.db import db
+from south.v2 import SchemaMigration
+from django.db import models
+
+
+class Migration(SchemaMigration):
+
+ def forwards(self, orm):
+ # Deleting field 'Lesson.depth'
+ db.delete_column('catalogue_lesson', 'depth')
+
+
+ def backwards(self, orm):
+ # Adding field 'Lesson.depth'
+ db.add_column('catalogue_lesson', 'depth',
+ self.gf('django.db.models.fields.IntegerField')(default=1),
+ keep_default=False)
+
+
+ models = {
+ 'catalogue.attachment': {
+ 'Meta': {'ordering': "['slug', 'ext']", 'unique_together': "(['lesson', 'slug', 'ext'],)", 'object_name': 'Attachment'},
+ 'ext': ('django.db.models.fields.CharField', [], {'max_length': '15'}),
+ 'file': ('django.db.models.fields.files.FileField', [], {'max_length': '100'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'lesson': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['catalogue.Lesson']"}),
+ 'slug': ('django.db.models.fields.CharField', [], {'max_length': '255'})
+ },
+ 'catalogue.lesson': {
+ 'Meta': {'ordering': "['section', 'level', 'order']", 'object_name': 'Lesson'},
+ 'dc': ('jsonfield.fields.JSONField', [], {'default': "'{}'"}),
+ 'html_file': ('django.db.models.fields.files.FileField', [], {'max_length': '100', 'null': 'True', 'blank': 'True'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'level': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['curriculum.Level']"}),
+ 'order': ('django.db.models.fields.IntegerField', [], {'db_index': 'True'}),
+ 'package': ('django.db.models.fields.files.FileField', [], {'max_length': '100', 'null': 'True', 'blank': 'True'}),
+ 'pdf': ('django.db.models.fields.files.FileField', [], {'max_length': '100', 'null': 'True', 'blank': 'True'}),
+ 'section': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['catalogue.Section']", 'null': 'True', 'blank': 'True'}),
+ 'slug': ('django.db.models.fields.SlugField', [], {'unique': 'True', 'max_length': '50'}),
+ 'student_package': ('django.db.models.fields.files.FileField', [], {'max_length': '100', 'null': 'True', 'blank': 'True'}),
+ 'student_pdf': ('django.db.models.fields.files.FileField', [], {'max_length': '100', 'null': 'True', 'blank': 'True'}),
+ 'title': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
+ 'type': ('django.db.models.fields.CharField', [], {'max_length': '15', 'db_index': 'True'}),
+ 'xml_file': ('django.db.models.fields.files.FileField', [], {'max_length': '100', 'null': 'True', 'blank': 'True'})
+ },
+ 'catalogue.part': {
+ 'Meta': {'object_name': 'Part'},
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'lesson': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['catalogue.Lesson']"}),
+ 'pdf': ('django.db.models.fields.files.FileField', [], {'max_length': '100', 'null': 'True', 'blank': 'True'}),
+ 'student_pdf': ('django.db.models.fields.files.FileField', [], {'max_length': '100', 'null': 'True', 'blank': 'True'})
+ },
+ 'catalogue.section': {
+ 'Meta': {'ordering': "['order']", 'object_name': 'Section'},
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'order': ('django.db.models.fields.IntegerField', [], {}),
+ 'slug': ('django.db.models.fields.SlugField', [], {'unique': 'True', 'max_length': '50'}),
+ 'title': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'})
+ },
+ 'curriculum.level': {
+ 'Meta': {'ordering': "['order']", 'object_name': 'Level'},
+ 'group': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'name': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
+ 'order': ('django.db.models.fields.IntegerField', [], {}),
+ 'slug': ('django.db.models.fields.CharField', [], {'max_length': '255'})
+ }
+ }
+
+ complete_apps = ['catalogue']
--- /dev/null
+# -*- coding: utf-8 -*-
+import datetime
+from south.db import db
+from south.v2 import SchemaMigration
+from django.db import models
+
+
+class Migration(SchemaMigration):
+
+ def forwards(self, orm):
+ # Adding field 'Section.xml_file'
+ db.add_column('catalogue_section', 'xml_file',
+ self.gf('django.db.models.fields.files.FileField')(max_length=100, null=True, blank=True),
+ keep_default=False)
+
+
+ def backwards(self, orm):
+ # Deleting field 'Section.xml_file'
+ db.delete_column('catalogue_section', 'xml_file')
+
+
+ models = {
+ 'catalogue.attachment': {
+ 'Meta': {'ordering': "['slug', 'ext']", 'unique_together': "(['lesson', 'slug', 'ext'],)", 'object_name': 'Attachment'},
+ 'ext': ('django.db.models.fields.CharField', [], {'max_length': '15'}),
+ 'file': ('django.db.models.fields.files.FileField', [], {'max_length': '100'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'lesson': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['catalogue.Lesson']"}),
+ 'slug': ('django.db.models.fields.CharField', [], {'max_length': '255'})
+ },
+ 'catalogue.lesson': {
+ 'Meta': {'ordering': "['section', 'level', 'order']", 'object_name': 'Lesson'},
+ 'dc': ('jsonfield.fields.JSONField', [], {'default': "'{}'"}),
+ 'html_file': ('django.db.models.fields.files.FileField', [], {'max_length': '100', 'null': 'True', 'blank': 'True'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'level': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['curriculum.Level']"}),
+ 'order': ('django.db.models.fields.IntegerField', [], {'db_index': 'True'}),
+ 'package': ('django.db.models.fields.files.FileField', [], {'max_length': '100', 'null': 'True', 'blank': 'True'}),
+ 'pdf': ('django.db.models.fields.files.FileField', [], {'max_length': '100', 'null': 'True', 'blank': 'True'}),
+ 'section': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['catalogue.Section']", 'null': 'True', 'blank': 'True'}),
+ 'slug': ('django.db.models.fields.SlugField', [], {'unique': 'True', 'max_length': '50'}),
+ 'student_package': ('django.db.models.fields.files.FileField', [], {'max_length': '100', 'null': 'True', 'blank': 'True'}),
+ 'student_pdf': ('django.db.models.fields.files.FileField', [], {'max_length': '100', 'null': 'True', 'blank': 'True'}),
+ 'title': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
+ 'type': ('django.db.models.fields.CharField', [], {'max_length': '15', 'db_index': 'True'}),
+ 'xml_file': ('django.db.models.fields.files.FileField', [], {'max_length': '100', 'null': 'True', 'blank': 'True'})
+ },
+ 'catalogue.part': {
+ 'Meta': {'object_name': 'Part'},
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'lesson': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['catalogue.Lesson']"}),
+ 'pdf': ('django.db.models.fields.files.FileField', [], {'max_length': '100', 'null': 'True', 'blank': 'True'}),
+ 'student_pdf': ('django.db.models.fields.files.FileField', [], {'max_length': '100', 'null': 'True', 'blank': 'True'})
+ },
+ 'catalogue.section': {
+ 'Meta': {'ordering': "['order']", 'object_name': 'Section'},
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'order': ('django.db.models.fields.IntegerField', [], {}),
+ 'slug': ('django.db.models.fields.SlugField', [], {'unique': 'True', 'max_length': '50'}),
+ 'title': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}),
+ 'xml_file': ('django.db.models.fields.files.FileField', [], {'max_length': '100', 'null': 'True', 'blank': 'True'})
+ },
+ 'curriculum.level': {
+ 'Meta': {'ordering': "['order']", 'object_name': 'Level'},
+ 'group': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'name': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
+ 'order': ('django.db.models.fields.IntegerField', [], {}),
+ 'slug': ('django.db.models.fields.CharField', [], {'max_length': '255'})
+ }
+ }
+
+ complete_apps = ['catalogue']
\ No newline at end of file
title = models.CharField(max_length=255, unique=True)
slug = models.SlugField(unique=True)
order = models.IntegerField()
+ xml_file = models.FileField(upload_to="catalogue/section/xml",
+ null=True, blank=True)
class Meta:
ordering = ['order']
+ class IncompleteError(BaseException):
+ pass
+
def __unicode__(self):
return self.title
def get_absolute_url(self):
return "%s#%s" % (reverse("catalogue_lessons"), self.slug)
+ @classmethod
+ def publish(cls, infile):
+ from librarian.parser import WLDocument
+ from django.core.files.base import ContentFile
+ xml = infile.get_string()
+ wldoc = WLDocument.from_string(xml)
+
+ try:
+ lessons = [Lesson.objects.get(slug=part.slug)
+ for part in wldoc.book_info.parts]
+ except Lesson.DoesNotExist, e:
+ raise cls.IncompleteError(e)
+
+ slug = wldoc.book_info.url.slug
+ try:
+ section = cls.objects.get(slug=slug)
+ except cls.DoesNotExist:
+ section = cls(slug=slug, order=0)
+
+ # Save XML file
+ section.xml_file.save('%s.xml' % slug, ContentFile(xml), save=False)
+ section.title = wldoc.book_info.title
+ section.save()
+
+ section.lesson_set.all().update(section=None)
+ for i, lesson in enumerate(lessons):
+ lesson.section = section
+ lesson.order = i
+ lesson.save()
+
+ return section
+
+
def syntetic_lesson(self):
try:
- return self.lesson_set.filter(depth=0)[0]
+ return self.lesson_set.filter(type='synthetic')[0]
except IndexError:
return None
class Lesson(models.Model):
- section = models.ForeignKey(Section)
+ section = models.ForeignKey(Section, null=True, blank=True)
level = models.ForeignKey(Level)
title = models.CharField(max_length=255)
slug = models.SlugField(unique=True)
- depth = models.IntegerField()
- order = models.IntegerField()
+ type = models.CharField(max_length=15, db_index=True)
+ order = models.IntegerField(db_index=True)
dc = JSONField(default='{}')
xml_file = models.FileField(upload_to="catalogue/lesson/xml",
null=True, blank=True)
class Meta:
- ordering = ['section', 'level', 'depth', 'order']
+ ordering = ['section', 'level', 'order']
def __unicode__(self):
return self.title
from django.core.files.base import ContentFile
xml = infile.get_string()
wldoc = WLDocument.from_string(xml)
- slug = wldoc.book_info.url.slug
+ # Check if not section metadata block.
+ if wldoc.book_info.parts:
+ return Section.publish(infile)
+
+ slug = wldoc.book_info.url.slug
try:
lesson = cls.objects.get(slug=slug)
except cls.DoesNotExist:
lesson.title = wldoc.book_info.title
lesson.level = Level.objects.get(slug=wldoc.book_info.audience)
- # TODO: no xml data?
- lesson.section = Section.objects.all()[0]
- lesson.order = 1
- lesson.depth = 1
+ lesson.order = 0
lesson.populate_dc()
+ lesson.type = lesson.dc["type"]
lesson.save()
lesson.build_html()
lesson.build_package()
.section-level {
width: 40em;
- border-radius: 0.938em; }
+ border-radius: 0.938em;
+ margin: 1em 0; }
-.section-depth {
+.section-type {
display: inline-block;
vertical-align: top;
padding: 1.25em; }
- .section-depth h1 {
+ .section-type h1 {
text-transform: uppercase;
margin: 0 0 1em 0;
font-size: 1em; }
- .section-depth .section-lessons {
+ .section-type .section-lessons {
padding: 0 0 0 1em; }
-.section-depth-0 {
+.section-type-synthetic {
width: 16.25em; }
-.section-depth-1 {
+.section-type-course {
border-radius: 0 0.938em 0.938em 0;
width: 18.75em; }
color: #67584f; }
.section-level-gimnazjum a {
color: #67584f; }
- .section-level-gimnazjum .section-depth-1 {
+ .section-level-gimnazjum .section-type-course {
background: #ed7831;
color: #fff; }
- .section-level-gimnazjum .section-depth-1 a {
+ .section-level-gimnazjum .section-type-course a {
color: #fff; }
-.section-level-L {
+.section-level-liceum {
background: #f4ae83;
color: #67584f; }
- .section-level-L a {
+ .section-level-liceum a {
color: #67584f; }
- .section-level-L .section-depth-1 {
+ .section-level-liceum .section-type-course {
background: #ed7831;
color: #fff; }
- .section-level-L .section-depth-1 a {
+ .section-level-liceum .section-type-course a {
color: #fff; }
+
+.section-links {
+ float: right; }
+
+h2.section-header {
+ margin: 0; }
.section-level {
width: 640*$px;
border-radius: 15*$px;
+ margin: 1em 0;
}
-.section-depth {
+.section-type {
display: inline-block;
vertical-align: top;
padding: 20*$px;
padding: 0 0 0 1em;
}
}
-.section-depth-0 {
+.section-type-synthetic {
width: 300*$px - 2 * 20*$px;
}
-.section-depth-1 {
+.section-type-course {
border-radius: 0 15*$px 15*$px 0;
width: 340*$px - 2 * 20*$px;
}
color: #67584f;
}
- .section-depth-0 {
+ .section-type-synthetic {
}
- .section-depth-1 {
+ .section-type-course {
background: #ed7831;
color: #fff;
a {
}
-.section-level-L {
+.section-level-liceum {
background: #f4ae83;
color: #67584f;
a {
color: #67584f;
}
- .section-depth-0 {
+ .section-type-synthetic {
}
- .section-depth-1 {
+ .section-type-course {
background: #ed7831;
color: #fff;
a {
}
+.section-links {
+ float: right;
+}
+
+h2.section-header {
+ margin: 0;
+}
<aside id="sidebar">
<section class="box">
<h1 class="realisation">Realizacja i czas lekcji</h1>
- {% if object.depth == 0 %}
+ {% if object.type == 'synthetic' %}
<p>To lekcja jest syntezą działu
<strong>{{ object.section }}</strong>.
Dostępny jest również
<strong><a href="{% url 'catalogue_lessons' %}#{{ object.section.slug }}">szczegółowy kurs</a></strong>
dla tego działu.
</p>
- {% else %}
+ <p>Czas trwania: 45 minut.</p>
+ {% elif object.type == 'course' %}
<p>Ta lekcja jest częścią działu
<strong>{{ object.section }}</strong>.
Dostępna jest również
<strong><a href="{{ object.section.syntetic_lesson.get_absolute_url }}">lekcja syntetyczna</a></strong>
dla tego działu.
</p>
- {% endif %}
<p>Czas trwania: 45 minut.</p>
+ {% else %}
+ <p>?</p>
+ {% endif %}
</section>
{% if object.package %}
</aside>
<div id="main-bar">
+ <a name="top"></a><h2>Tematy</h2>
+ <ul class="link-list">
{% for object in object_list %}
- <h2>{{ object }} <a name="{{ object.slug }}" class="permalink"></a></h2>
+ <li><a href="#{{ object.slug }}">{{ object }}</a></li>
+ {% endfor %}
+ </ul>
+
+ {% for object in object_list %}
+ <div class="section-links">
+ <a href="#top">wróć do spisu treści</a>
+ </div>
+ <h2 class="section-header">{{ object }} <a name="{{ object.slug }}" class="permalink"></a></h2>
{% section_box object %}
{% endfor %}
-{% for level, depths in lessons.items %}
+{% for level, types in lessons.items %}
+{% if level.slug == "liceum" %}
+ <p>Poziom zaawansowany
+ <span class="section-links"><a href="#top">wróć do spisu treści</a></span>
+ </p>
+{% endif %}
<section class="section-level section-level-{{ level.slug }}">
{% spaceless %}
- {% for depth, lesson_list in depths.items %}
- <section class="section-depth section-depth-{{ depth }}">
- {% if depth == 0 %}
+ {% for lesson_type, lesson_list in types.items %}
+ <section class="section-type section-type-{{ lesson_type }}">
+ {% if lesson_type == 'synthetic' %}
<h1>Lekcja syntetyczna</h1>
{% else %}
<h1>Pełny kurs</h1>
<ul class="section-lessons">
{% for lesson in lesson_list %}
<li class="section-lesson">
- <a href="{{ lesson.get_absolute_url }}">{{ lesson }}{% if depth == 0 %}
+ <a href="{{ lesson.get_absolute_url }}">{{ lesson }}{% if depth == 'synthetic' %}
(przegląd całego działu w 45 minut)
{% endif %}</a>
</li>
lessons = SortedDict()
for lesson in section.lesson_set.all():
if lesson.level not in lessons:
- lessons[lesson.level] = SortedDict()
- if lesson.depth not in lessons[lesson.level]:
- lessons[lesson.level][lesson.depth] = []
- lessons[lesson.level][lesson.depth].append(lesson)
+ newdict = SortedDict()
+ newdict['synthetic'] = []
+ newdict['course'] = []
+ lessons[lesson.level] = newdict
+ if lesson.type not in lessons[lesson.level]:
+ lessons[lesson.level][lesson.type] = []
+ lessons[lesson.level][lesson.type].append(lesson)
+ print lessons
return {
"lessons": lessons,
}
@register.inclusion_tag("catalogue/snippets/lesson_nav.html")
def lesson_nav(lesson):
- if lesson.depth == 1:
+ if lesson.type == 'course':
root = lesson.section
- siblings = root.lesson_set.filter(depth=1)
+ siblings = root.lesson_set.filter(type='course')
else:
root = None
- siblings = Lesson.objects.filter(depth=0)
+ siblings = Lesson.objects.filter(type=lesson.type)
return {
"lesson": lesson,
"root": root,