Commit 2a6cf86ac4be449dfdffc1fa14aad84e42649043
1 parent
82efaefd
Exists in
master
and in
5 other branches
Model of forum's post [Issue: #82]
Showing
1 changed file
with
17 additions
and
1 deletions
Show diff stats
forum/models.py
@@ -4,6 +4,7 @@ from django.db import models | @@ -4,6 +4,7 @@ from django.db import models | ||
4 | from autoslug.fields import AutoSlugField | 4 | from autoslug.fields import AutoSlugField |
5 | 5 | ||
6 | from courses.models import Activity | 6 | from courses.models import Activity |
7 | +from users.models import User | ||
7 | 8 | ||
8 | """ | 9 | """ |
9 | It's one kind of activity available for a Topic. | 10 | It's one kind of activity available for a Topic. |
@@ -12,7 +13,7 @@ It works like a 'topic' of forum, which users can post to it and answer posts of | @@ -12,7 +13,7 @@ It works like a 'topic' of forum, which users can post to it and answer posts of | ||
12 | class Forum(Activity): | 13 | class Forum(Activity): |
13 | title = models.CharField(_('Title'), max_length = 100) | 14 | title = models.CharField(_('Title'), max_length = 100) |
14 | description = models.TextField(_('Description'), blank = True) | 15 | description = models.TextField(_('Description'), blank = True) |
15 | - create_date = models.DateField(_('Create Date'), auto_now_add = True) | 16 | + create_date = models.DateTimeField(_('Create Date'), auto_now_add = True) |
16 | 17 | ||
17 | class Meta: | 18 | class Meta: |
18 | verbose_name = _('Forum') | 19 | verbose_name = _('Forum') |
@@ -20,3 +21,18 @@ class Forum(Activity): | @@ -20,3 +21,18 @@ class Forum(Activity): | ||
20 | 21 | ||
21 | def __str__(self): | 22 | def __str__(self): |
22 | return self.title | 23 | return self.title |
24 | + | ||
25 | +""" | ||
26 | +It represents a post made in a forum (topic) | ||
27 | +""" | ||
28 | +class Post(modes.Model): | ||
29 | + user = models.ForeignKey(User, verbose_name = _('Autor')) | ||
30 | + message = models.TextField(_('Post message'), blank = False) | ||
31 | + post_date = models.DateTimeField(_('Post Date'), auto_now_add = True) | ||
32 | + | ||
33 | + class Meta: | ||
34 | + verbose_name = _('Post') | ||
35 | + verbose_name_plural = _('Posts') | ||
36 | + | ||
37 | + def __str__(self): | ||
38 | + return ''.join([self.user.name, " / ", self.post_date]) | ||
23 | \ No newline at end of file | 39 | \ No newline at end of file |