From: Aleksander Łukasz Date: Tue, 13 Aug 2013 10:52:53 +0000 (+0200) Subject: Merge branch 'master' into forum X-Git-Url: https://git.mdrn.pl/edumed.git/commitdiff_plain/32ac950fc8d6ba7ef7ec4bf1c4b05f2ed25b02fd?hp=311b474e0ac168a93fed2dec0c784d28d7660c6b Merge branch 'master' into forum --- diff --git a/catalogue/management/commands/repackage.py b/catalogue/management/commands/repackage.py index eed8576..3946e82 100755 --- a/catalogue/management/commands/repackage.py +++ b/catalogue/management/commands/repackage.py @@ -42,6 +42,9 @@ class Command(BaseCommand): elif lesson.type == 'synthetic': prefix = "%s/%s (synteza)/" % ( section_dir, lesson.slug) + elif lesson.type == 'project': + prefix = "%s/%s (projekt)/" % ( + section_dir, lesson.slug) else: prefix = "%s/%s/" % ( section_dir, lesson.slug) diff --git a/catalogue/migrations/0013_auto__add_field_section_image.py b/catalogue/migrations/0013_auto__add_field_section_image.py new file mode 100644 index 0000000..e097d57 --- /dev/null +++ b/catalogue/migrations/0013_auto__add_field_section_image.py @@ -0,0 +1,91 @@ +# -*- 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.image' + db.add_column(u'catalogue_section', 'image', + self.gf('django.db.models.fields.files.ImageField')(max_length=100, null=True, blank=True), + keep_default=False) + + + def backwards(self, orm): + # Deleting field 'Section.image' + db.delete_column(u'catalogue_section', 'image') + + + models = { + u'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'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'lesson': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['catalogue.Lesson']"}), + 'slug': ('django.db.models.fields.CharField', [], {'max_length': '255'}) + }, + u'catalogue.lesson': { + 'Meta': {'ordering': "['section', 'level', 'order']", 'object_name': 'Lesson'}, + 'curriculum_courses': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['curriculum.CurriculumCourse']", 'symmetrical': 'False', 'blank': 'True'}), + 'dc': ('jsonfield.fields.JSONField', [], {'default': "'{}'"}), + 'html_file': ('django.db.models.fields.files.FileField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'level': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['curriculum.Level']"}), + 'order': ('django.db.models.fields.IntegerField', [], {'db_index': 'True'}), + 'package': ('django.db.models.fields.files.FileField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}), + 'pdf': ('django.db.models.fields.files.FileField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}), + 'section': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['catalogue.Section']", 'null': 'True', 'blank': 'True'}), + 'slug': ('django.db.models.fields.SlugField', [], {'unique': 'True', 'max_length': '255'}), + 'student_package': ('django.db.models.fields.files.FileField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}), + 'student_pdf': ('django.db.models.fields.files.FileField', [], {'max_length': '255', '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': '255', 'null': 'True', 'blank': 'True'}) + }, + u'catalogue.lessonstub': { + 'Meta': {'ordering': "['section', 'level', 'order']", 'object_name': 'LessonStub'}, + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'level': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['curriculum.Level']"}), + 'order': ('django.db.models.fields.IntegerField', [], {'db_index': 'True'}), + 'section': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['catalogue.Section']", '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'}) + }, + u'catalogue.part': { + 'Meta': {'object_name': 'Part'}, + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'lesson': ('django.db.models.fields.related.ForeignKey', [], {'to': u"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'}) + }, + u'catalogue.section': { + 'Meta': {'ordering': "['order']", 'object_name': 'Section'}, + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'image': ('django.db.models.fields.files.ImageField', [], {'max_length': '100', 'null': 'True', 'blank': 'True'}), + 'order': ('django.db.models.fields.IntegerField', [], {}), + 'slug': ('django.db.models.fields.SlugField', [], {'unique': 'True', 'max_length': '255'}), + 'title': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}), + 'xml_file': ('django.db.models.fields.files.FileField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}) + }, + u'curriculum.curriculumcourse': { + 'Meta': {'ordering': "['slug']", 'object_name': 'CurriculumCourse'}, + 'accusative': ('django.db.models.fields.CharField', [], {'max_length': '255'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'slug': ('django.db.models.fields.CharField', [], {'max_length': '255', 'db_index': 'True'}), + 'title': ('django.db.models.fields.CharField', [], {'max_length': '255'}) + }, + u'curriculum.level': { + 'Meta': {'ordering': "['order']", 'object_name': 'Level'}, + 'group': ('django.db.models.fields.CharField', [], {'max_length': '255'}), + u'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 diff --git a/catalogue/models.py b/catalogue/models.py index 3ae4490..239f60c 100644 --- a/catalogue/models.py +++ b/catalogue/models.py @@ -11,6 +11,8 @@ class Section(models.Model): order = models.IntegerField() xml_file = models.FileField(upload_to="catalogue/section/xml", null=True, blank=True, max_length=255) + image = models.ImageField(upload_to="catalogue/section/image", + null=True, blank=True) class Meta: ordering = ['order'] @@ -122,9 +124,10 @@ class Lesson(models.Model): lesson.populate_dc() lesson.build_html(infile=infile) lesson.build_pdf(infile=infile) - lesson.build_pdf(student=True, infile=infile) lesson.build_package() - lesson.build_package(student=True) + if lesson.type != 'project': + lesson.build_pdf(student=True, infile=infile) + lesson.build_package(student=True) return lesson def populate_dc(self): @@ -176,17 +179,15 @@ class Lesson(models.Model): File(open(pdf.get_filename()))) def add_to_zip(self, zipf, student=False, prefix=''): - zipf.write(self.xml_file.path, - "%spliki-zrodlowe/%s.xml" % (prefix, self.slug)) pdf = self.student_pdf if student else self.pdf if pdf: zipf.write(pdf.path, "%s%s%s.pdf" % (prefix, self.slug, "_student" if student else "")) - for attachment in self.attachment_set.all(): - zipf.write(attachment.file.path, - u"%smaterialy/%s.%s" % (prefix, attachment.slug, attachment.ext)) - - + for attachment in self.attachment_set.all(): + zipf.write(attachment.file.path, + u"%smaterialy/%s.%s" % (prefix, attachment.slug, attachment.ext)) + zipf.write(self.xml_file.path, + "%spliki-zrodlowe/%s.xml" % (prefix, self.slug)) def build_package(self, student=False): from StringIO import StringIO diff --git a/catalogue/static/catalogue/css/section_list.css b/catalogue/static/catalogue/css/section_list.css index d079abe..15c44ca 100644 --- a/catalogue/static/catalogue/css/section_list.css +++ b/catalogue/static/catalogue/css/section_list.css @@ -6,20 +6,28 @@ .section-level a:hover { text-decoration: underline; } +.sections-row { + display: table; } + .section-type { - display: inline-block; + display: table-cell; vertical-align: top; padding: 1.25em; } .section-type h1 { text-transform: uppercase; margin: 0 0 1em 0; font-size: 1em; } + .section-type img { + float: left; + margin-right: 1em; + margin-bottom: 1em; + border: 0.375em solid white; } .section-type-synthetic { - width: 16.25em; } + width: 18.75em; } .section-type-course { - width: 18.75em; } + width: 16.25em; } .section-type-project { width: 37.5em; } @@ -59,6 +67,10 @@ color: #363a3e; } .course-boxes .section-level .section-type { background: white; } +.course-boxes .section-type-synthetic { + width: 16.25em; } +.course-boxes .section-type-course { + width: 18.75em; } .section-links { float: right; } diff --git a/catalogue/static/catalogue/css/section_list.scss b/catalogue/static/catalogue/css/section_list.scss index 72e0f96..a9a1305 100755 --- a/catalogue/static/catalogue/css/section_list.scss +++ b/catalogue/static/catalogue/css/section_list.scss @@ -11,8 +11,12 @@ $px: 0.0625em; } } +.sections-row { + display: table; +} + .section-type { - display: inline-block; + display: table-cell; vertical-align: top; padding: 20*$px; @@ -21,13 +25,21 @@ $px: 0.0625em; margin: 0 0 1em 0; font-size: 1em; } + + img { + float: left; + margin-right: 16*$px; + margin-bottom: 16*$px; + border: 6*$px solid white; + } } .section-type-synthetic { - width: 300*$px - 2 * 20*$px; + width: 340*$px - 2 * 20*$px; } .section-type-course { - width: 340*$px - 2 * 20*$px; + width: 300*$px - 2 * 20*$px; } + .section-type-project { width: 640*$px - 2 * 20*$px; } @@ -90,6 +102,12 @@ $px: 0.0625em; background: white; } } + .section-type-synthetic { + width: 300*$px - 2 * 20*$px; + } + .section-type-course { + width: 340*$px - 2 * 20*$px; + } } diff --git a/catalogue/templates/catalogue/lesson/project/lesson_detail.html b/catalogue/templates/catalogue/lesson/project/lesson_detail.html index d4336ec..ed36341 100755 --- a/catalogue/templates/catalogue/lesson/project/lesson_detail.html +++ b/catalogue/templates/catalogue/lesson/project/lesson_detail.html @@ -15,7 +15,7 @@ {% if object.package %} -
Pobierz całą lekcję
+
Pobierz cały projekt
{% endif %} {% endblock %} diff --git a/catalogue/templates/catalogue/snippets/lesson_nav.html b/catalogue/templates/catalogue/snippets/lesson_nav.html index fa9d8ad..4e36e22 100755 --- a/catalogue/templates/catalogue/snippets/lesson_nav.html +++ b/catalogue/templates/catalogue/snippets/lesson_nav.html @@ -3,6 +3,8 @@ {{ root }} {% elif lesson.type == 'synthetic' %} Lekcje syntetyczne ze wszystkich tematów +{% elif lesson.type == 'project' %} + Projekty ze wszystkich tematów {% else %} Inne {% endif %} @@ -23,6 +25,7 @@ {% endfor %} +{% if link_other_level %} {% with other=lesson.get_other_level %} {% if other %}

Ten temat jest dostępny również na @@ -30,3 +33,4 @@ {% if other.slug == 'liceum' %}zaawansowanym{% else %}podstawowym{% endif %}.

{% endif %} {% endwith %} +{% endif %} diff --git a/catalogue/templates/catalogue/snippets/section_box.html b/catalogue/templates/catalogue/snippets/section_box.html index bbca27a..c505c04 100755 --- a/catalogue/templates/catalogue/snippets/section_box.html +++ b/catalogue/templates/catalogue/snippets/section_box.html @@ -1,3 +1,4 @@ +{% load thumbnail %} {% for level, types in lessons.items %} {% if level.slug == "liceum" %}

{{section.title}}: poziom zaawansowany @@ -6,9 +7,20 @@ {% endif %}

{% spaceless %} +
{% for lesson_type, lesson_list in types.items %} + {% if lesson_type == 'project' %} +
+ {% endif %}
{% if lesson_type == 'synthetic' %} + {% if section.image %} + {% thumbnail section.image "120x160" as im %} + + + + {% endthumbnail %} + {% endif %}

Lekcja syntetyczna

{% elif lesson_type == 'project' %}

Projekt

@@ -34,6 +46,7 @@ {% endif %}
{% endfor %} +
{% endspaceless %}
{% endfor %} diff --git a/catalogue/templatetags/catalogue_tags.py b/catalogue/templatetags/catalogue_tags.py index c642f18..a8d69e6 100755 --- a/catalogue/templatetags/catalogue_tags.py +++ b/catalogue/templatetags/catalogue_tags.py @@ -53,10 +53,11 @@ def lesson_nav(lesson): root = lesson.section siblings = Lesson.objects.filter(type='course', level=lesson.level, section=root) mark_level = False + link_other_level = True else: root = None siblings = Lesson.objects.filter(type=lesson.type) - mark_level = True + mark_level = link_other_level = lesson.type == 'course' return { "lesson": lesson, "root": root, diff --git a/edumed/settings.d/30-apps.py b/edumed/settings.d/30-apps.py index bac06a1..824b44b 100644 --- a/edumed/settings.d/30-apps.py +++ b/edumed/settings.d/30-apps.py @@ -17,6 +17,7 @@ INSTALLED_APPS = ( 'contact', 'pybb', 'django_libravatar', + 'sorl.thumbnail', 'django.contrib.auth', 'django.contrib.contenttypes', diff --git a/requirements.txt b/requirements.txt index ea14e0b..c96b02c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -19,7 +19,7 @@ Feedparser django-honeypot # Librarian -lxml +lxml>=3.0 texml # sponsors @@ -30,5 +30,7 @@ django-haystack>=2.0,<2.1 pysolr>=3,<4 pybbm>=0.14,<0.15 -sorl-thumbnail>=11,<12 django-libravatar + +sorl-thumbnail>=11,<12 +