diff --git a/content/admin.py b/content/admin.py index bae393e..75f042a 100644 --- a/content/admin.py +++ b/content/admin.py @@ -1,8 +1,6 @@ from django.contrib import admin -from .models import Category, Content, School, Video +from .models import Category, Content admin.site.register(Category) admin.site.register(Content) -admin.site.register(School) -admin.site.register(Video) diff --git a/vote/admin.py b/vote/admin.py index 9ac7d05..e1df9cc 100644 --- a/vote/admin.py +++ b/vote/admin.py @@ -1,5 +1,5 @@ from django.contrib import admin -from .models import Vote, Voter +from .models import Vote, Poll admin.site.register(Vote) -admin.site.register(Voter) +admin.site.register(Poll) diff --git a/vote/migrations/0001_initial.py b/vote/migrations/0001_initial.py index f8b375d..1692395 100644 --- a/vote/migrations/0001_initial.py +++ b/vote/migrations/0001_initial.py @@ -1,5 +1,6 @@ -# Generated by Django 2.0.1 on 2018-01-21 00:07 +# Generated by Django 2.0.1 on 2018-01-22 13:24 +from django.conf import settings import django.core.validators from django.db import migrations, models import django.db.models.deletion @@ -10,33 +11,28 @@ class Migration(migrations.Migration): initial = True dependencies = [ - ('content', '0004_video'), + ('auth', '0009_alter_user_last_name_max_length'), + migrations.swappable_dependency(settings.AUTH_USER_MODEL), + ('content', '0001_initial'), ] operations = [ + migrations.CreateModel( + name='Poll', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('title', models.CharField(max_length=1024)), + ('contents', models.ManyToManyField(to='content.Content')), + ('voters_group', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='auth.Group')), + ], + ), migrations.CreateModel( name='Vote', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('vote', models.IntegerField(validators=[django.core.validators.MaxValueValidator(5), django.core.validators.MinValueValidator(0)])), - ('categorie', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='content.Category')), - ('video', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='content.Video')), + ('content', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='content.Content')), + ('votant', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), ], ), - migrations.CreateModel( - name='Voter', - fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('name', models.CharField(max_length=100)), - ('firstname', models.CharField(max_length=100)), - ('email', models.EmailField(max_length=200)), - ('password', models.CharField(max_length=100)), - ('ecole', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='content.School')), - ], - ), - migrations.AddField( - model_name='vote', - name='votant', - field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='vote.Voter'), - ), ] diff --git a/vote/models.py b/vote/models.py index 9ded687..ec93860 100644 --- a/vote/models.py +++ b/vote/models.py @@ -13,3 +13,9 @@ class Vote(models.Model): validators.MinValueValidator(0) ] ) + + +class Poll(models.Model): + voters_group = models.ForeignKey(Group, on_delete=models.CASCADE) + contents = models.ManyToManyField(Content) + title = models.CharField(max_length=1024)