mirror of https://github.com/MieuxVoter/mvapi
parent
dfdd28bdd6
commit
2270b50038
@ -0,0 +1 @@
|
||||
docker exec -it mvapi_web_1 python manage.py dbbackup
|
@ -0,0 +1,18 @@
|
||||
# Generated by Django 3.1.1 on 2021-04-10 15:13
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('election', '0003_remove_token_email'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='election',
|
||||
name='send_mail',
|
||||
field=models.BooleanField(default=True),
|
||||
),
|
||||
]
|
@ -0,0 +1,43 @@
|
||||
"""
|
||||
Add voters to a started election.
|
||||
"""
|
||||
from typing import List, Dict
|
||||
import os
|
||||
import pathlib
|
||||
import argparse
|
||||
import django
|
||||
|
||||
|
||||
def load_mvapi():
|
||||
import os
|
||||
import sys
|
||||
sys.path.append('../')
|
||||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mvapi.settings")
|
||||
django.setup()
|
||||
|
||||
load_mvapi()
|
||||
from election.models import Election, Vote, Token
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("--election_id", type=str)
|
||||
parser.add_argument("--num_tokens", type=int)
|
||||
parser.add_argument("--output", type=str, required=True)
|
||||
args = parser.parse_args()
|
||||
print(args)
|
||||
|
||||
try:
|
||||
election = Election.objects.get(id=args.election_id)
|
||||
except Election.DoesNotExist:
|
||||
raise ValueError(f"The election {election} does not exist")
|
||||
|
||||
tokens = []
|
||||
for email in range(args.num_tokens):
|
||||
token = Token.objects.create(election=election)
|
||||
tokens.append(token.id)
|
||||
# print(token)
|
||||
# send_mail_invitation(email, election, token.id)
|
||||
|
||||
with open(args.output, "w") as fid:
|
||||
fid.write("\n".join([f"https://app.mieuxvoter.fr/vote/{args.election_id}/?token={t}" for t in tokens]))
|
Loading…
Reference in new issue