From 38251ba37e4cfe24ddf5cde13a2c3ce1a7be1346 Mon Sep 17 00:00:00 2001 From: Ludovic Stephan Date: Fri, 20 Nov 2020 17:45:15 +0100 Subject: [PATCH] Rename app --- {votes => elections}/__init__.py | 0 elections/apps.py | 5 +++ elections/migrations/0001_initial.py | 49 +++++++++++++++++++++ {votes => elections}/migrations/__init__.py | 0 {votes => elections}/models.py | 3 +- {votes => elections}/tests.py | 0 votes/admin.py | 3 -- votes/apps.py | 5 --- votes/views.py | 3 -- 9 files changed, 56 insertions(+), 12 deletions(-) rename {votes => elections}/__init__.py (100%) create mode 100644 elections/apps.py create mode 100644 elections/migrations/0001_initial.py rename {votes => elections}/migrations/__init__.py (100%) rename {votes => elections}/models.py (95%) rename {votes => elections}/tests.py (100%) delete mode 100644 votes/admin.py delete mode 100644 votes/apps.py delete mode 100644 votes/views.py diff --git a/votes/__init__.py b/elections/__init__.py similarity index 100% rename from votes/__init__.py rename to elections/__init__.py diff --git a/elections/apps.py b/elections/apps.py new file mode 100644 index 0000000..39f1259 --- /dev/null +++ b/elections/apps.py @@ -0,0 +1,5 @@ +from django.apps import AppConfig + + +class ElectionsConfig(AppConfig): + name = "elections" diff --git a/elections/migrations/0001_initial.py b/elections/migrations/0001_initial.py new file mode 100644 index 0000000..0ee73e0 --- /dev/null +++ b/elections/migrations/0001_initial.py @@ -0,0 +1,49 @@ +# Generated by Django 2.2.17 on 2020-11-20 15:31 + +from django.conf import settings +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + migrations.swappable_dependency(settings.AUTH_USER_MODEL), + ] + + operations = [ + migrations.CreateModel( + name='Election', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('name', models.CharField(max_length=255, verbose_name='nom')), + ('short_name', models.SlugField(unique=True, verbose_name='nom bref')), + ('description', models.TextField(blank=True, verbose_name='description')), + ('start_time', models.DateTimeField(verbose_name='date et heure de début')), + ('end_time', models.DateTimeField(verbose_name='date et heure de fin')), + ('results_public', models.BooleanField(default=False, verbose_name='résultats publics')), + ('tallied', models.BooleanField(default=False, verbose_name='dépouillée')), + ('archived', models.BooleanField(default=False, verbose_name='archivée')), + ('created_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL)), + ], + ), + migrations.CreateModel( + name='Question', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('text', models.TextField(verbose_name='question')), + ('election', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='questions', to='elections.Election')), + ], + ), + migrations.CreateModel( + name='Option', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('text', models.TextField(verbose_name='texte')), + ('question', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='options', to='elections.Question')), + ('voters', models.ManyToManyField(related_name='votes', to=settings.AUTH_USER_MODEL)), + ], + ), + ] diff --git a/votes/migrations/__init__.py b/elections/migrations/__init__.py similarity index 100% rename from votes/migrations/__init__.py rename to elections/migrations/__init__.py diff --git a/votes/models.py b/elections/models.py similarity index 95% rename from votes/models.py rename to elections/models.py index f614447..3d2056a 100644 --- a/votes/models.py +++ b/elections/models.py @@ -19,6 +19,7 @@ class Election(models.Model): results_public = models.BooleanField(_("résultats publics"), default=False) tallied = models.BooleanField(_("dépouillée"), default=False) + # TODO : cache tally or recompute it each time ? archived = models.BooleanField(_("archivée"), default=False) @@ -38,4 +39,4 @@ class Option(models.Model): voters = models.ManyToManyField( User, related_name="votes", - ) \ No newline at end of file + ) diff --git a/votes/tests.py b/elections/tests.py similarity index 100% rename from votes/tests.py rename to elections/tests.py diff --git a/votes/admin.py b/votes/admin.py deleted file mode 100644 index 8c38f3f..0000000 --- a/votes/admin.py +++ /dev/null @@ -1,3 +0,0 @@ -from django.contrib import admin - -# Register your models here. diff --git a/votes/apps.py b/votes/apps.py deleted file mode 100644 index e896828..0000000 --- a/votes/apps.py +++ /dev/null @@ -1,5 +0,0 @@ -from django.apps import AppConfig - - -class VotesConfig(AppConfig): - name = 'votes' diff --git a/votes/views.py b/votes/views.py deleted file mode 100644 index 91ea44a..0000000 --- a/votes/views.py +++ /dev/null @@ -1,3 +0,0 @@ -from django.shortcuts import render - -# Create your views here.