Commit f34a20a80cdb013ec646331f0edbf6974d163fd6
1 parent
dbd80467
Exists in
master
and in
5 other branches
Form de subject #30
Showing
2 changed files
with
16 additions
and
14 deletions
Show diff stats
courses/forms.py
1 | 1 | from django import forms |
2 | 2 | from django.utils.translation import ugettext_lazy as _ |
3 | -from .models import Category, Course, Module | |
3 | +from .models import Category, Course, Subject | |
4 | 4 | |
5 | 5 | class CategoryForm(forms.ModelForm): |
6 | 6 | |
... | ... | @@ -49,10 +49,10 @@ class CourseForm(forms.ModelForm): |
49 | 49 | 'categoy': forms.Select(), |
50 | 50 | } |
51 | 51 | |
52 | -class ModuleForm(forms.ModelForm): | |
52 | +class SubjectForm(forms.ModelForm): | |
53 | 53 | |
54 | 54 | class Meta: |
55 | - model = Module | |
55 | + model = Subject | |
56 | 56 | fields = ('name', 'description', 'visible',) |
57 | 57 | labels = { |
58 | 58 | 'name': _('Name'), |
... | ... | @@ -60,7 +60,7 @@ class ModuleForm(forms.ModelForm): |
60 | 60 | 'visible': _('Is it visible?'), |
61 | 61 | } |
62 | 62 | help_texts = { |
63 | - 'name': _("Module's name"), | |
64 | - 'description': _("Modules's description"), | |
65 | - 'visible': _('Is the module visible?'), | |
66 | - } | |
67 | 63 | \ No newline at end of file |
64 | + 'name': _("Subjects's name"), | |
65 | + 'description': _("Subjects's description"), | |
66 | + 'visible': _('Is the subject visible?'), | |
67 | + } | ... | ... |
courses/models.py
1 | 1 | from django.utils.translation import ugettext_lazy as _ |
2 | 2 | from django.db import models |
3 | +from autoslug.fields import AutoSlugField | |
3 | 4 | from users.models import User |
4 | 5 | |
5 | 6 | class Category(models.Model): |
... | ... | @@ -39,19 +40,20 @@ class Course(models.Model): |
39 | 40 | def __str__(self): |
40 | 41 | return self.name |
41 | 42 | |
42 | -class Module(models.Model): | |
43 | +class Subject(models.Model): | |
43 | 44 | |
44 | 45 | name = models.CharField(_('Name'), max_length = 100) |
45 | - slug = models.SlugField(_('Slug'), max_length = 100) | |
46 | + slug = AutoSlugField(_("Slug"),populate_from='name',unique=True) | |
46 | 47 | description = models.TextField(_('Description'), blank = True) |
47 | 48 | visible = models.BooleanField(_('Visible'), default = True, blank = True) |
48 | - create_date = models.DateField(_('Creation Date'), auto_now_add = True) | |
49 | - course = models.ForeignKey(Course, verbose_name = _('Course')) | |
49 | + create_date = models.DateTimeField(_('Creation Date'), auto_now_add = True) | |
50 | + update_date = models.DateTimeField(_('Date of last update'), auto_now=True) | |
51 | + course = models.ForeignKey(Course, verbose_name = _('Course'), related_name="subjects") | |
50 | 52 | |
51 | 53 | class Meta: |
52 | 54 | |
53 | - verbose_name = _('Module') | |
54 | - verbose_name_plural = _('Modules') | |
55 | + verbose_name = _('Subject') | |
56 | + verbose_name_plural = _('Subjects') | |
55 | 57 | |
56 | 58 | def __str__(self): |
57 | - return self.name | |
58 | 59 | \ No newline at end of file |
60 | + return self.name | ... | ... |