From: Radek Czajka Date: Wed, 7 Aug 2013 11:37:44 +0000 (+0200) Subject: Merge branch 'infographics' X-Git-Url: https://git.mdrn.pl/edumed.git/commitdiff_plain/66639e61ca81cd591cddd58325fee1845eed8e30?hp=3017f6ff905303f7d664d6da40c471c2d86381e3 Merge branch 'infographics' --- 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..ae87ca8 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'] diff --git a/catalogue/static/catalogue/css/section_list.css b/catalogue/static/catalogue/css/section_list.css index d079abe..70ac927 100644 --- a/catalogue/static/catalogue/css/section_list.css +++ b/catalogue/static/catalogue/css/section_list.css @@ -6,20 +6,27 @@ .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; } .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 +66,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..26e5e6c 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,20 @@ $px: 0.0625em; margin: 0 0 1em 0; font-size: 1em; } + + img { + float: left; + margin-right: 16*$px; + margin-bottom: 16*$px; + } } .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 +101,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/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/edumed/settings.d/30-apps.py b/edumed/settings.d/30-apps.py index e98a3ee..521839b 100644 --- a/edumed/settings.d/30-apps.py +++ b/edumed/settings.d/30-apps.py @@ -15,6 +15,7 @@ INSTALLED_APPS = ( 'haystack', 'chunks', 'contact', + 'sorl.thumbnail', 'django.contrib.auth', 'django.contrib.contenttypes', diff --git a/requirements.txt b/requirements.txt index 41857b0..53db32f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -28,3 +28,5 @@ django-sponsors>=1.1,<1.2 django-haystack>=2.0,<2.1 pysolr>=3,<4 + +sorl-thumbnail>=11,<12