Add global packages, + various visual fixes
authorRadek Czajka <radoslaw.czajka@nowoczesnapolska.org.pl>
Wed, 6 Feb 2013 15:20:23 +0000 (16:20 +0100)
committerRadek Czajka <radoslaw.czajka@nowoczesnapolska.org.pl>
Wed, 6 Feb 2013 15:20:23 +0000 (16:20 +0100)
14 files changed:
catalogue/management/commands/repackage.py [new file with mode: 0755]
catalogue/models.py
catalogue/static/catalogue/css/exercise.css
catalogue/static/catalogue/css/exercise.scss
catalogue/static/catalogue/css/layout.css
catalogue/static/catalogue/css/layout.scss
catalogue/static/catalogue/css/section_list.css
catalogue/static/catalogue/css/section_list.scss
catalogue/static/catalogue/js/edumed.js
catalogue/templates/catalogue/section_list.html
catalogue/urls.py
catalogue/views.py
edumed/settings.d/60-custom.py
edumed/templates/base.html

diff --git a/catalogue/management/commands/repackage.py b/catalogue/management/commands/repackage.py
new file mode 100755 (executable)
index 0000000..e6de171
--- /dev/null
@@ -0,0 +1,50 @@
+# -*- coding: utf-8 -*-
+# This file is part of EduMed, licensed under GNU Affero GPLv3 or later.
+# Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
+#
+import os
+from optparse import make_option
+from django.conf import settings
+from django.core.management.base import BaseCommand
+from catalogue.models import Section
+import zipfile
+
+
+class Command(BaseCommand):
+    option_list = BaseCommand.option_list + (
+        make_option('-q', '--quiet', action='store_false', dest='verbose', default=True,
+            help='Verbosity level; 0=minimal output, 1=normal output, 2=all output'),
+    )
+    help = 'Rebuilds downloadable packages.'
+
+    def build_package(self, zippath, student, verbose):
+        with open(zippath, 'w') as outf:
+            zipf = zipfile.ZipFile(outf, 'w', zipfile.ZIP_STORED)
+            
+            for si, section in enumerate(Section.objects.all()):
+                li = 1
+                for lesson in section.lesson_set.all():
+                    if lesson.type == 'course':
+                        prefix = "%d_%s/%02d_%s/" % (
+                                si, section.slug,
+                                li, lesson.slug,
+                            )
+                        li += 1
+                    elif lesson.type == 'synthetic':
+                        prefix = "%d_%s/synteza_%s/" % (
+                                si, section.slug, lesson.slug)
+                    else:
+                        prefix = "%d_%s/%s/" % (
+                                si, section.slug, lesson.slug)
+                    lesson.add_to_zip(zipf, student, prefix)
+            zipf.close()
+
+    def handle(self, **options):
+        verbose = options.get('verbose')
+
+        self.build_package(
+            os.path.join(settings.MEDIA_ROOT, settings.CATALOGUE_PACKAGE), 
+            False, verbose)
+        self.build_package(
+            os.path.join(settings.MEDIA_ROOT, settings.CATALOGUE_PACKAGE_STUDENT),
+            True, verbose)
index 46338c4..0c3a54c 100644 (file)
@@ -148,17 +148,22 @@ class Lesson(models.Model):
         self.html_file.save("%s.html" % self.slug,
             File(open(html.get_filename())))
 
         self.html_file.save("%s.html" % self.slug,
             File(open(html.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(self.xml_file.path, 
+                "%s%s%s.pdf" % (prefix, self.slug, "_student" if student else ""))
+        
+
     def build_package(self, student=False):
         from StringIO import StringIO
         import zipfile
         from django.core.files.base import ContentFile
         buff = StringIO()
         zipf = zipfile.ZipFile(buff, 'w', zipfile.ZIP_STORED)
     def build_package(self, student=False):
         from StringIO import StringIO
         import zipfile
         from django.core.files.base import ContentFile
         buff = StringIO()
         zipf = zipfile.ZipFile(buff, 'w', zipfile.ZIP_STORED)
-        zipf.write(self.xml_file.path, "pliki-zrodlowe/%s.xml" % self.slug)
-        pdf = self.student_pdf if student else self.pdf
-        if pdf:
-            zipf.write(self.xml_file.path, 
-                "%s%s.pdf" % (self.slug, "_student" if student else ""))
+        self.add_to_zip(zipf, student)
         zipf.close()
         fieldname = "student_package" if student else "package"
         getattr(self, fieldname).save(
         zipf.close()
         fieldname = "student_package" if student else "package"
         getattr(self, fieldname).save(
index b9c91e9..deb48d5 100644 (file)
@@ -21,7 +21,7 @@
   display: inline-block;
   border-radius: 0.5em;
   padding: 0.25em 0.5em;
   display: inline-block;
   border-radius: 0.5em;
   padding: 0.25em 0.5em;
-  margin: -0.25em -0.5em -1em 0.5em;
+  margin: -0.25em -0.5em -0.25em 0.5em;
   background: #ed7831;
   color: white; }
 .exercise .buttons {
   background: #ed7831;
   color: white; }
 .exercise .buttons {
 .przyporzadkuj .predicate {
   list-style: none;
   margin: 0;
 .przyporzadkuj .predicate {
   list-style: none;
   margin: 0;
-  padding: 0;
-  white-space: nowrap; }
+  padding: 0; }
   .przyporzadkuj .predicate > li {
   .przyporzadkuj .predicate > li {
-    white-space: normal;
     border-radius: 0.688em;
     padding: 0.5em 0.688em;
     display: inline-block;
     background-color: #5e6165;
     color: white;
     border-radius: 0.688em;
     padding: 0.5em 0.688em;
     display: inline-block;
     background-color: #5e6165;
     color: white;
-    width: 11.25em;
+    width: 11.75em;
     position: relative;
     vertical-align: top; }
     .przyporzadkuj .predicate > li .subjects {
     position: relative;
     vertical-align: top; }
     .przyporzadkuj .predicate > li .subjects {
       .przyporzadkuj .predicate > li .subjects .placeholder:after {
         content: "upuść tutaj";
         text-style: italic; }
       .przyporzadkuj .predicate > li .subjects .placeholder:after {
         content: "upuść tutaj";
         text-style: italic; }
-  .przyporzadkuj .predicate .comment {
-    white-space: normal; }
 .przyporzadkuj .subject {
   list-style: none;
   margin: 0;
 .przyporzadkuj .subject {
   list-style: none;
   margin: 0;
index 6fe8c9a..6b00e20 100755 (executable)
@@ -72,7 +72,7 @@ $px: 0.0625em;
         display: inline-block;
         border-radius: 8*$px;
         padding: 4*$px 8*$px;
         display: inline-block;
         border-radius: 8*$px;
         padding: 4*$px 8*$px;
-        margin: -4*$px -8*$px -1em 8*$px;
+        margin: -4*$px -8*$px -.25em 8*$px;
         background: #ed7831;
         color: white;
     }
         background: #ed7831;
         color: white;
     }
@@ -166,15 +166,13 @@ $px: 0.0625em;
     }
     .predicate {
         @include list-plain;
     }
     .predicate {
         @include list-plain;
-        white-space: nowrap;
 
         > li {
 
         > li {
-            white-space: normal;
             @include bubble;
             display: inline-block;
             background-color: #5e6165;
             color: white;
             @include bubble;
             display: inline-block;
             background-color: #5e6165;
             color: white;
-            width: 180*$px;
+            width: 188*$px;
             position: relative;
             vertical-align: top;
 
             position: relative;
             vertical-align: top;
 
@@ -206,7 +204,6 @@ $px: 0.0625em;
             }
         }
         .comment {
             }
         }
         .comment {
-            white-space: normal;
         }
     }
     .subject {
         }
     }
     .subject {
index 0757538..1836845 100644 (file)
       text-transform: uppercase; }
   #sidebar .box-button {
     background-color: #ed7831;
       text-transform: uppercase; }
   #sidebar .box-button {
     background-color: #ed7831;
-    border-radius: 0.938em;
-    padding: 1.063em 0.75em 1.063em 0.75em; }
+    border-radius: 0.938em; }
     #sidebar .box-button .dl-button {
     #sidebar .box-button .dl-button {
-      color: white; }
+      color: white;
+      padding: 1.063em 0.75em 1.063em 0.75em; }
   #sidebar .dl-button {
     color: #363a3e;
     display: block;
   #sidebar .dl-button {
     color: #363a3e;
     display: block;
index 318c444..5596539 100755 (executable)
@@ -30,9 +30,9 @@ $new_black: #363a3e;
     .box-button {
         background-color: #ed7831;
         border-radius: 15*$px;
     .box-button {
         background-color: #ed7831;
         border-radius: 15*$px;
-        padding: 17*$px 12*$px 17*$px 12*$px;
         .dl-button {
             color: white;
         .dl-button {
             color: white;
+            padding: 17*$px 12*$px 17*$px 12*$px;
         }
     }
     .dl-button {
         }
     }
     .dl-button {
index 1793d85..99046a0 100644 (file)
@@ -13,8 +13,6 @@
     text-transform: uppercase;
     margin: 0 0 1em 0;
     font-size: 1em; }
     text-transform: uppercase;
     margin: 0 0 1em 0;
     font-size: 1em; }
-  .section-type .section-lessons {
-    padding: 0 0 0 1em; }
 
 .section-type-synthetic {
   width: 16.25em; }
 
 .section-type-synthetic {
   width: 16.25em; }
index 141cba1..ecab3c8 100755 (executable)
@@ -19,10 +19,6 @@ $px: 0.0625em;
         margin: 0 0 1em 0;
         font-size: 1em;
     }
         margin: 0 0 1em 0;
         font-size: 1em;
     }
-
-    .section-lessons {
-        padding: 0 0 0 1em;
-    }
 }
 .section-type-synthetic {
     width: 300*$px - 2 * 20*$px;
 }
 .section-type-synthetic {
     width: 300*$px - 2 * 20*$px;
index cc7b9e1..f11ac36 100644 (file)
       if (!$placeholder.hasClass('multiple')) {
         $placeholder.hide();
       }
       if (!$placeholder.hasClass('multiple')) {
         $placeholder.hide();
       }
-      $added.append('<span class="remove">x</span>');
+      $added.append('<span class="remove">x</span><div class="clr">');
       return $('.remove', $added).click(function(ev) {
         $added.prev(".placeholder:not(.multiple)").show();
         if (!ismultiple) {
       return $('.remove', $added).click(function(ev) {
         $added.prev(".placeholder:not(.multiple)").show();
         if (!ismultiple) {
index 33cf65a..0113684 100755 (executable)
@@ -14,8 +14,8 @@
         </p>
         <p>Czas trwania: 45 minut</p>
     </section>
         </p>
         <p>Czas trwania: 45 minut</p>
     </section>
-    <section class="box-button"><a href="" class="dl-button">Pobierz wszystkie lekcje</a></section>
-    <section><a href="" class="dl-button">Pobierz wszystkie lekcje w&nbsp;wersji dla ucznia</a></section>
+    <section class="box-button"><a href="{{ package_url }}" class="dl-button">Pobierz wszystkie lekcje</a></section>
+    <section><a href="{{ package_student_url }}" class="dl-button">Pobierz wszystkie lekcje w&nbsp;wersji dla ucznia</a></section>
     <section class="section-minor">
         <h1>Zebrane z wszystkich działów</h1>
         <ul class="link-list">
     <section class="section-minor">
         <h1>Zebrane z wszystkich działów</h1>
         <ul class="link-list">
index 649691d..3b40c3a 100755 (executable)
@@ -1,10 +1,11 @@
 from django.conf.urls import patterns, include, url
 from django.views.generic import DetailView, ListView
 from .models import Section, Lesson
 from django.conf.urls import patterns, include, url
 from django.views.generic import DetailView, ListView
 from .models import Section, Lesson
+from .views import SectionView
 
 urlpatterns = patterns('',
     url(r'^$',
 
 urlpatterns = patterns('',
     url(r'^$',
-        ListView.as_view(model=Section),
+        SectionView.as_view(),
         name="catalogue_lessons"),
     url(r'^(?P<slug>[^/]+)/$',
         DetailView.as_view(model=Lesson),
         name="catalogue_lessons"),
     url(r'^(?P<slug>[^/]+)/$',
         DetailView.as_view(model=Lesson),
index 60f00ef..2f511ef 100644 (file)
@@ -1 +1,13 @@
-# Create your views here.
+import os.path
+from django.conf import settings
+from django.views.generic import DetailView, ListView
+from .models import Section
+
+class SectionView(ListView):
+    model = Section
+
+    def get_context_data(self, **kwargs):
+        context = super(SectionView, self).get_context_data(**kwargs)
+        context['package_url'] = os.path.join(settings.MEDIA_URL, settings.CATALOGUE_PACKAGE)
+        context['package_student_url'] = os.path.join(settings.MEDIA_URL, settings.CATALOGUE_PACKAGE_STUDENT)
+        return context
index e69de29..da1b7eb 100644 (file)
@@ -0,0 +1,2 @@
+CATALOGUE_PACKAGE = "catalogue/edukacjamedialna.zip"
+CATALOGUE_PACKAGE_STUDENT = "catalogue/edukacjamedialna_uczen.zip"
index bbfab33..dd92cb4 100644 (file)
@@ -37,7 +37,7 @@
                 <img src="{% static "img/logo_fnp.png" %}" alt="Fundacja Nowoczesna Polska" /></a>
             <nav><ul>
                 <li><a class="menu-lekcje" href="{% url "catalogue_lessons" %}">Lekcje</a></li>
                 <img src="{% static "img/logo_fnp.png" %}" alt="Fundacja Nowoczesna Polska" /></a>
             <nav><ul>
                 <li><a class="menu-lekcje" href="{% url "catalogue_lessons" %}">Lekcje</a></li>
-                <li><a class="menu-kompetencje" href="{% url "curriculum" %}">Katalog kompetencji</a></li>
+                <li><a class="menu-kompetencje" href="{% url "curriculum" %}">Kompetencje</a></li>
                 <li><a class="menu-wspolpraca" href="{% url "info" "wspolpraca/" %}">Współpraca</a></li>
                 <li><a class="menu-szkolenia" href="{% url "info" "szkolenia/" %}">Szkolenia</a></li>
                 <li><a class="menu-wesprzyj" href="{% url "info" "wesprzyj/" %}">Wesprzyj nas</a></li>
                 <li><a class="menu-wspolpraca" href="{% url "info" "wspolpraca/" %}">Współpraca</a></li>
                 <li><a class="menu-szkolenia" href="{% url "info" "szkolenia/" %}">Szkolenia</a></li>
                 <li><a class="menu-wesprzyj" href="{% url "info" "wesprzyj/" %}">Wesprzyj nas</a></li>