debc4875f12b25b20cb3afcd6f1925de1c2af18b
[edumed.git] / curriculum / models.py
1 from django.db import models
2 from django.utils.translation import ugettext_lazy as _
3
4 class Section(models.Model):
5     name = models.CharField(_('name'), max_length=255)
6     slug = models.SlugField(_('slug'))
7     order = models.IntegerField(_('order'))
8
9     class Meta:
10         ordering = ['order']
11         verbose_name = _('section')
12         verbose_name_plural = _('sections')
13
14     def __unicode__(self):
15         return self.name
16
17 class Competence(models.Model):
18     section = models.ForeignKey(Section)
19     name = models.CharField(_('name'), max_length=255)
20     slug = models.SlugField(_('slug'))
21     order = models.IntegerField(_('order'))
22
23     class Meta:
24         ordering = ['order']
25         verbose_name = _('competence')
26         verbose_name_plural = _('competences')
27
28     def __unicode__(self):
29         return self.name
30
31     def for_level(self, level):
32         return self.competencelevel_set.get(level=level)
33
34 class Level(models.Model):
35     name = models.CharField(_('name'), max_length=255)
36     slug = models.SlugField(_('slug'))
37     order = models.IntegerField(_('order'))
38
39     class Meta:
40         ordering = ['order']
41         verbose_name = _('educational level')
42         verbose_name_plural = _('educational levels')
43
44     def __unicode__(self):
45         return self.name
46
47 class CompetenceLevel(models.Model):
48     competence = models.ForeignKey(Competence)
49     level = models.ForeignKey(Level)
50     description = models.TextField(_('description'))
51
52     class Meta:
53         ordering = ['competence', 'level']
54         verbose_name = _('competence on level')
55         verbose_name_plural = _('competences on levels')
56
57     def __unicode__(self):
58         return "%s/%s" % (self.competence, self.level)