1 from django import template
2 from django.utils.datastructures import SortedDict
3 from ..models import Competence, Curriculum
5 register = template.Library()
8 @register.inclusion_tag("curriculum/snippets/competence.html")
11 comps = [Competence.from_text(text) for text in texts]
13 return {'texts': texts}
18 @register.inclusion_tag("curriculum/snippets/curriculum.html")
19 def curriculum(identifiers):
21 currs = [Curriculum.objects.get(identifier=identifier)
22 for identifier in identifiers]
23 except Curriculum.DoesNotExist:
24 return {'identifiers': identifiers}
26 currset = SortedDict()
28 k = curr.course, curr.level
30 currset[k] = SortedDict()
31 typename = Curriculum.TYPES[curr.type]
32 if typename not in currset[k]:
33 currset[k][typename] = []
34 currset[k][typename].append(curr)
42 def url_for_level(comp, level):
44 return comp.for_level(level).get_absolute_url()
46 return comp.get_absolute_url()