Commit 8efbd63d0ee9e569f56533fe2a07e9857ce67f7a
1 parent
ee830676
Exists in
master
and in
5 other branches
create forms delivery material
Showing
4 changed files
with
84 additions
and
1 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 CourseCategory, Course, Subject, Topic, ActivityFile, Activity | |
| 3 | +from .models import CourseCategory, Course, Subject, Topic, ActivityFile, Activity, FileMaterial, LinkMaterial | |
| 4 | 4 | from s3direct.widgets import S3DirectWidget |
| 5 | 5 | |
| 6 | 6 | |
| ... | ... | @@ -188,3 +188,13 @@ class ActivityForm(forms.ModelForm): |
| 188 | 188 | class Meta: |
| 189 | 189 | model = Activity |
| 190 | 190 | fields = ['topic', 'limit_date', 'students','all_students'] |
| 191 | + | |
| 192 | +class FileMaterialForm(forms.ModelForm): | |
| 193 | + class Meta: | |
| 194 | + model = FileMaterial | |
| 195 | + fields = ['material', 'file', 'name'] | |
| 196 | + | |
| 197 | +class LinkMaterialForm(forms.ModelForm): | |
| 198 | + class Meta: | |
| 199 | + model = LinkMaterial | |
| 200 | + fields = ['material', 'name', 'description','url'] | ... | ... |
| ... | ... | @@ -0,0 +1,27 @@ |
| 1 | +# -*- coding: utf-8 -*- | |
| 2 | +# Generated by Django 1.10 on 2016-10-17 04:17 | |
| 3 | +from __future__ import unicode_literals | |
| 4 | + | |
| 5 | +from django.db import migrations | |
| 6 | + | |
| 7 | + | |
| 8 | +class Migration(migrations.Migration): | |
| 9 | + | |
| 10 | + dependencies = [ | |
| 11 | + ('core', '0002_mymetype'), | |
| 12 | + ('courses', '0005_file'), | |
| 13 | + ] | |
| 14 | + | |
| 15 | + operations = [ | |
| 16 | + migrations.RemoveField( | |
| 17 | + model_name='file', | |
| 18 | + name='material_ptr', | |
| 19 | + ), | |
| 20 | + migrations.RemoveField( | |
| 21 | + model_name='file', | |
| 22 | + name='typ', | |
| 23 | + ), | |
| 24 | + migrations.DeleteModel( | |
| 25 | + name='File', | |
| 26 | + ), | |
| 27 | + ] | ... | ... |
| ... | ... | @@ -0,0 +1,35 @@ |
| 1 | +# -*- coding: utf-8 -*- | |
| 2 | +# Generated by Django 1.10 on 2016-10-17 04:55 | |
| 3 | +from __future__ import unicode_literals | |
| 4 | + | |
| 5 | +from django.db import migrations, models | |
| 6 | +import django.db.models.deletion | |
| 7 | + | |
| 8 | + | |
| 9 | +class Migration(migrations.Migration): | |
| 10 | + | |
| 11 | + dependencies = [ | |
| 12 | + ('courses', '0006_auto_20161017_0117'), | |
| 13 | + ] | |
| 14 | + | |
| 15 | + operations = [ | |
| 16 | + migrations.CreateModel( | |
| 17 | + name='FileMaterial', | |
| 18 | + fields=[ | |
| 19 | + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | |
| 20 | + ('file', models.FileField(upload_to='uploads/%Y/%m/%d')), | |
| 21 | + ('name', models.CharField(max_length=100)), | |
| 22 | + ('material', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='material_file', to='courses.Material', verbose_name='Material')), | |
| 23 | + ], | |
| 24 | + ), | |
| 25 | + migrations.CreateModel( | |
| 26 | + name='LinkMaterial', | |
| 27 | + fields=[ | |
| 28 | + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | |
| 29 | + ('name', models.CharField(max_length=100)), | |
| 30 | + ('description', models.TextField()), | |
| 31 | + ('url', models.URLField(max_length=300, verbose_name='Link')), | |
| 32 | + ('material', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='material_link', to='courses.Material', verbose_name='Material')), | |
| 33 | + ], | |
| 34 | + ), | |
| 35 | + ] | ... | ... |
courses/models.py
| ... | ... | @@ -114,6 +114,17 @@ class Material(Resource): |
| 114 | 114 | topic = models.ForeignKey(Topic, verbose_name = _('Topic'), related_name='materials') |
| 115 | 115 | students = models.ManyToManyField(User, verbose_name = _('Students'), related_name='materials') |
| 116 | 116 | all_students = models.BooleanField(_('All Students'), default=False) |
| 117 | + | |
| 118 | +class FileMaterial(models.Model): | |
| 119 | + material = models.ForeignKey(Material, verbose_name = _('Material'), related_name='material_file') | |
| 120 | + file = models.FileField(upload_to='uploads/%Y/%m/%d') | |
| 121 | + name = models.CharField(max_length=100) | |
| 122 | + | |
| 123 | +class LinkMaterial(models.Model): | |
| 124 | + material = models.ForeignKey(Material, verbose_name = _('Material'), related_name='material_link') | |
| 125 | + name = models.CharField(max_length=100) | |
| 126 | + description = models.TextField() | |
| 127 | + url = models.URLField('Link', max_length=300) | |
| 117 | 128 | |
| 118 | 129 | """ |
| 119 | 130 | It is a category for each subject. | ... | ... |