1 from django.core.urlresolvers import reverse
2 from django.db import models
3 from django.utils.translation import ugettext_lazy as _
5 class Section(models.Model):
6 name = models.CharField(_('name'), max_length=255)
7 slug = models.SlugField(_('slug'))
8 order = models.IntegerField(_('order'))
12 verbose_name = _('section')
13 verbose_name_plural = _('sections')
15 def __unicode__(self):
18 class Competence(models.Model):
19 section = models.ForeignKey(Section)
20 name = models.CharField(_('name'), max_length=255)
21 slug = models.SlugField(_('slug'))
22 order = models.IntegerField(_('order'))
26 verbose_name = _('competence')
27 verbose_name_plural = _('competences')
29 def __unicode__(self):
32 def get_absolute_url(self):
33 return "%s?c=%d" % (reverse("curriculum"), self.pk)
35 def for_level(self, level):
36 return self.competencelevel_set.get(level=level)
39 def from_text(cls, text):
40 name = text.rsplit(u'\u2013', 1)[-1].strip()
41 return cls.objects.get(name__iexact=name)
43 class Level(models.Model):
44 group = models.CharField(_('group'), max_length=255)
45 name = models.CharField(_('name'), max_length=255)
46 slug = models.CharField(_('slug'), max_length=255)
47 order = models.IntegerField(_('order'))
51 verbose_name = _('educational level')
52 verbose_name_plural = _('educational levels')
54 def __unicode__(self):
57 class CompetenceLevel(models.Model):
58 competence = models.ForeignKey(Competence)
59 level = models.ForeignKey(Level)
60 description = models.TextField(_('description'))
63 ordering = ['competence', 'level']
64 verbose_name = _('competence on level')
65 verbose_name_plural = _('competences on levels')
67 def __unicode__(self):
68 return u"%s/%s" % (self.competence, self.level)
70 def get_absolute_url(self):
71 return "%s?c=%d&level=%s&d=1" % (reverse("curriculum"), self.competence.pk, self.level.slug)