--- /dev/null
+# -*- 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)
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)
- 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(
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 {
.przyporzadkuj .predicate {
list-style: none;
margin: 0;
- padding: 0;
- white-space: nowrap; }
+ padding: 0; }
.przyporzadkuj .predicate > li {
- white-space: normal;
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 {
.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;
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;
}
}
.predicate {
@include list-plain;
- white-space: nowrap;
> li {
- white-space: normal;
@include bubble;
display: inline-block;
background-color: #5e6165;
color: white;
- width: 180*$px;
+ width: 188*$px;
position: relative;
vertical-align: top;
}
}
.comment {
- white-space: normal;
}
}
.subject {
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 {
- color: white; }
+ color: white;
+ padding: 1.063em 0.75em 1.063em 0.75em; }
#sidebar .dl-button {
color: #363a3e;
display: block;
.box-button {
background-color: #ed7831;
border-radius: 15*$px;
- padding: 17*$px 12*$px 17*$px 12*$px;
.dl-button {
color: white;
+ padding: 17*$px 12*$px 17*$px 12*$px;
}
}
.dl-button {
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; }
margin: 0 0 1em 0;
font-size: 1em;
}
-
- .section-lessons {
- padding: 0 0 0 1em;
- }
}
.section-type-synthetic {
width: 300*$px - 2 * 20*$px;
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) {
</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 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 wersji dla ucznia</a></section>
<section class="section-minor">
<h1>Zebrane z wszystkich działów</h1>
<ul class="link-list">
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'^$',
- ListView.as_view(model=Section),
+ SectionView.as_view(),
name="catalogue_lessons"),
url(r'^(?P<slug>[^/]+)/$',
DetailView.as_view(model=Lesson),
-# 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
+CATALOGUE_PACKAGE = "catalogue/edukacjamedialna.zip"
+CATALOGUE_PACKAGE_STUDENT = "catalogue/edukacjamedialna_uczen.zip"
<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>