Commit b084b59939c8ba63d155d39072fc71444307ca48
1 parent
1ffe6d18
Exists in
master
and in
5 other branches
Files models upddate and migration #127
Showing
2 changed files
with
40 additions
and
3 deletions
Show diff stats
| ... | ... | @@ -0,0 +1,34 @@ |
| 1 | +# -*- coding: utf-8 -*- | |
| 2 | +# Generated by Django 1.10 on 2016-10-13 16:12 | |
| 3 | +from __future__ import unicode_literals | |
| 4 | + | |
| 5 | +from django.db import migrations, models | |
| 6 | +import django.db.models.deletion | |
| 7 | +import files.models | |
| 8 | + | |
| 9 | + | |
| 10 | +class Migration(migrations.Migration): | |
| 11 | + | |
| 12 | + initial = True | |
| 13 | + | |
| 14 | + dependencies = [ | |
| 15 | + ('core', '0002_mymetype'), | |
| 16 | + ('courses', '0004_auto_20161011_1951'), | |
| 17 | + ] | |
| 18 | + | |
| 19 | + operations = [ | |
| 20 | + migrations.CreateModel( | |
| 21 | + name='TopicFile', | |
| 22 | + fields=[ | |
| 23 | + ('material_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='courses.Material')), | |
| 24 | + ('description', models.TextField(blank=True, verbose_name='Description')), | |
| 25 | + ('file_url', models.FileField(upload_to=files.models.file_path, verbose_name='File')), | |
| 26 | + ('file_type', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='topic_files', to='core.MymeType', verbose_name='Type file')), | |
| 27 | + ], | |
| 28 | + options={ | |
| 29 | + 'verbose_name': 'File', | |
| 30 | + 'verbose_name_plural': 'Files', | |
| 31 | + }, | |
| 32 | + bases=('courses.material',), | |
| 33 | + ), | |
| 34 | + ] | ... | ... |
files/models.py
| 1 | 1 | from django.db import models |
| 2 | 2 | from django.utils.translation import ugettext_lazy as _ |
| 3 | - | |
| 4 | -from courses.models import Activity | |
| 3 | +from core.models import MymeType | |
| 4 | +from courses.models import Material | |
| 5 | 5 | |
| 6 | 6 | """ |
| 7 | 7 | Function to return the path where the file should be saved |
| ... | ... | @@ -14,8 +14,11 @@ def file_path(instance, filename): |
| 14 | 14 | It's one kind of activity available for a Topic. |
| 15 | 15 | It's like a support material for the students. |
| 16 | 16 | """ |
| 17 | -class TopicFiles(Activity): | |
| 17 | +class TopicFile(Material): | |
| 18 | + description = models.TextField(_('Description'), blank=True) | |
| 18 | 19 | file_url = models.FileField(verbose_name = _("File"), upload_to = file_path) |
| 20 | + file_type = models.ForeignKey(MymeType, verbose_name=_('Type file'), related_name='topic_files') | |
| 21 | + | |
| 19 | 22 | |
| 20 | 23 | class Meta: |
| 21 | 24 | verbose_name = _("File") | ... | ... |