10 changed files with 159 additions and 7 deletions
@ -0,0 +1,20 @@ |
|||||
|
from django import forms |
||||
|
|
||||
|
from .models import Content, Category |
||||
|
|
||||
|
|
||||
|
class CreateContent(forms.ModelForm): |
||||
|
class Meta: |
||||
|
model = Content |
||||
|
fields = [ |
||||
|
'name', |
||||
|
'category', |
||||
|
'file', |
||||
|
] |
||||
|
|
||||
|
def __init__(self, school, *args, **kwargs): |
||||
|
super().__init__(*args, **kwargs) |
||||
|
self.instance.school = school |
||||
|
|
||||
|
already_created = map(lambda x:x.category.pk, school.content_set.select_related('category')) |
||||
|
self.fields['category'].queryset = Category.objects.exclude(pk__in=already_created) |
||||
@ -0,0 +1,19 @@ |
|||||
|
# Generated by Django 2.0.1 on 2018-03-09 11:33 |
||||
|
|
||||
|
from django.db import migrations, models |
||||
|
import django.db.models.deletion |
||||
|
|
||||
|
|
||||
|
class Migration(migrations.Migration): |
||||
|
|
||||
|
dependencies = [ |
||||
|
('content', '0002_auto_20180309_1116'), |
||||
|
] |
||||
|
|
||||
|
operations = [ |
||||
|
migrations.AlterField( |
||||
|
model_name='content', |
||||
|
name='school_owner', |
||||
|
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='users.School'), |
||||
|
), |
||||
|
] |
||||
@ -0,0 +1,19 @@ |
|||||
|
# Generated by Django 2.0.1 on 2018-03-09 11:35 |
||||
|
|
||||
|
import content.models |
||||
|
from django.db import migrations, models |
||||
|
|
||||
|
|
||||
|
class Migration(migrations.Migration): |
||||
|
|
||||
|
dependencies = [ |
||||
|
('content', '0003_auto_20180309_1233'), |
||||
|
] |
||||
|
|
||||
|
operations = [ |
||||
|
migrations.AlterField( |
||||
|
model_name='content', |
||||
|
name='file', |
||||
|
field=models.FileField(upload_to=content.models.get_upload_to, verbose_name='Fichier'), |
||||
|
), |
||||
|
] |
||||
@ -0,0 +1,18 @@ |
|||||
|
# Generated by Django 2.0.1 on 2018-03-09 11:55 |
||||
|
|
||||
|
from django.db import migrations, models |
||||
|
|
||||
|
|
||||
|
class Migration(migrations.Migration): |
||||
|
|
||||
|
dependencies = [ |
||||
|
('content', '0004_auto_20180309_1235'), |
||||
|
] |
||||
|
|
||||
|
operations = [ |
||||
|
migrations.AlterField( |
||||
|
model_name='content', |
||||
|
name='file', |
||||
|
field=models.FileField(upload_to='', verbose_name='Fichier'), |
||||
|
), |
||||
|
] |
||||
@ -0,0 +1,19 @@ |
|||||
|
# Generated by Django 2.0.1 on 2018-03-09 11:57 |
||||
|
|
||||
|
import content.models |
||||
|
from django.db import migrations, models |
||||
|
|
||||
|
|
||||
|
class Migration(migrations.Migration): |
||||
|
|
||||
|
dependencies = [ |
||||
|
('content', '0005_auto_20180309_1255'), |
||||
|
] |
||||
|
|
||||
|
operations = [ |
||||
|
migrations.AlterField( |
||||
|
model_name='content', |
||||
|
name='file', |
||||
|
field=models.FileField(upload_to=content.models.get_upload_to, verbose_name='Fichier'), |
||||
|
), |
||||
|
] |
||||
@ -0,0 +1,25 @@ |
|||||
|
# Generated by Django 2.0.1 on 2018-03-09 12:15 |
||||
|
|
||||
|
import content.models |
||||
|
from django.db import migrations, models |
||||
|
import django.db.models.deletion |
||||
|
|
||||
|
|
||||
|
class Migration(migrations.Migration): |
||||
|
|
||||
|
dependencies = [ |
||||
|
('content', '0006_auto_20180309_1257'), |
||||
|
] |
||||
|
|
||||
|
operations = [ |
||||
|
migrations.AlterField( |
||||
|
model_name='content', |
||||
|
name='file', |
||||
|
field=models.FileField(upload_to=content.models.get_upload_to, validators=[content.models.validate_file_extension], verbose_name='Fichier'), |
||||
|
), |
||||
|
migrations.AlterField( |
||||
|
model_name='content', |
||||
|
name='school_owner', |
||||
|
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='users.School'), |
||||
|
), |
||||
|
] |
||||
Loading…
Reference in new issue