Commit ade3280ded641e47faaf9465254bc0589378036e
1 parent
57ec3dfd
Exists in
master
and in
5 other branches
Creating Files app and Model [Issue: #127]
Showing
7 changed files
with
39 additions
and
0 deletions
Show diff stats
... | ... | @@ -0,0 +1,25 @@ |
1 | +from django.db import models | |
2 | +from django.utils.translation import ugettext_lazy as _ | |
3 | + | |
4 | +from courses.models import Activity | |
5 | + | |
6 | +""" | |
7 | + Function to return the path where the file should be saved | |
8 | +""" | |
9 | +def file_path(instance, filename): | |
10 | + return '/'.join([instance.topic.subject.course.slug, instance.topic.subject.slug, instance.topic.slug, filename]) | |
11 | + | |
12 | + | |
13 | +""" | |
14 | + It's one kind of activity available for a Topic. | |
15 | + It's like a support material for the students. | |
16 | +""" | |
17 | +class TopicFiles(Activity): | |
18 | + file_url = models.FileField(verbose_name = _("File"), upload_to = file_path) | |
19 | + | |
20 | + class Meta: | |
21 | + verbose_name = _("File") | |
22 | + verbose_name_plural = _("Files") | |
23 | + | |
24 | + def __str__(self): | |
25 | + return self.name | |
0 | 26 | \ No newline at end of file | ... | ... |