Début du système de vote

This commit is contained in:
Klafyvel 2018-01-22 14:25:19 +01:00
parent 86e2fbaf77
commit 40b718b45c
4 changed files with 25 additions and 25 deletions

View file

@ -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)

View file

@ -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)

View file

@ -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'),
),
]

View file

@ -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)