From 482477cced586463d7f342cdde8482a4d97d7685 Mon Sep 17 00:00:00 2001 From: Jan Szejko Date: Mon, 11 Dec 2017 15:08:43 +0100 Subject: [PATCH 1/1] new curriculum --- librarian/dcparser.py | 1 + librarian/pypdf.py | 46 +++++++++++++++++++++++-------------------- 2 files changed, 26 insertions(+), 21 deletions(-) diff --git a/librarian/dcparser.py b/librarian/dcparser.py index 747ac86..0e18051 100644 --- a/librarian/dcparser.py +++ b/librarian/dcparser.py @@ -188,6 +188,7 @@ class WorkInfo(object): Field(DCNS('subject.competence'), 'competences', multiple=True, required=False), Field(DCNS('subject.curriculum'), 'curriculum', multiple=True, required=False), + Field(DCNS('subject.curriculum.new'), 'curriculum_new', multiple=True, required=False), Field(DCNS('language'), 'language'), Field(DCNS('description'), 'description', required=False), diff --git a/librarian/pypdf.py b/librarian/pypdf.py index de0f859..6aadbc4 100644 --- a/librarian/pypdf.py +++ b/librarian/pypdf.py @@ -121,27 +121,31 @@ class EduModule(Xmill): @escape(True) def get_curriculum(self, element): - identifiers = self.get_dc(element, 'subject.curriculum') - if not identifiers: - return '' - try: - from curriculum.templatetags.curriculum_tags import curriculum - curr_elements = curriculum(identifiers) - except ImportError: - curr_elements = {'identifiers': identifiers} - items = ['Podstawa programowa:'] - newline = '\n' - if 'currset' in curr_elements: - for (course, level), types in curr_elements['currset'].iteritems(): - lines = [u'%s, %s poziom edukacyjny' % (course, level)] - for type, currs in types.iteritems(): - lines.append(type) - lines += [curr.title for curr in currs] - items.append(newline.join(lines)) - else: - items += identifiers - return '\n.6em\n'.join( - '%s' % item for item in items) + ret = [] + for dc_tag, new in [('subject.curriculum', False), ('subject.curriculum.new', True)]: + identifiers = self.get_dc(element, dc_tag) + if not identifiers: + continue + try: + from curriculum.templatetags.curriculum_tags import curriculum + curr_elements = curriculum(identifiers) + except ImportError: + curr_elements = {'identifiers': identifiers} + items = ['Nowa podstawa programowa:' if new else 'Podstawa programowa:'] + newline = '\n' + if 'currset' in curr_elements: + for (course, level), types in curr_elements['currset'].iteritems(): + label = u'klasa' if new else u'poziom edukacyjny' + lines = [u'%s, %s %s' % (course, level, label)] + for type, currs in types.iteritems(): + lines.append(type) + lines += [curr.title for curr in currs] + items.append(newline.join(lines)) + else: + items += identifiers + ret.append('\n.6em\n'.join( + '%s' % item for item in items)) + return '\n1em\n'.join(ret) def handle_utwor(self, element): lines = [ -- 2.20.1