dont user helper phne as id anymore. django migrations broke :(
This commit is contained in:
parent
8b22411d6a
commit
944d21f681
|
@ -1,7 +1,8 @@
|
||||||
# Generated by Django 4.0.4 on 2022-04-12 12:19
|
# Generated by Django 4.0.4 on 2022-04-27 14:11
|
||||||
|
|
||||||
from django.db import migrations, models
|
from django.db import migrations, models
|
||||||
import django.db.models.deletion
|
import django.db.models.deletion
|
||||||
|
import phonenumber_field.modelfields
|
||||||
import shiftregister.app.models
|
import shiftregister.app.models
|
||||||
|
|
||||||
|
|
||||||
|
@ -9,121 +10,63 @@ class Migration(migrations.Migration):
|
||||||
|
|
||||||
initial = True
|
initial = True
|
||||||
|
|
||||||
dependencies = []
|
dependencies = [
|
||||||
|
]
|
||||||
|
|
||||||
operations = [
|
operations = [
|
||||||
migrations.CreateModel(
|
migrations.CreateModel(
|
||||||
name="Helper",
|
name='Helper',
|
||||||
fields=[
|
fields=[
|
||||||
(
|
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
"phone",
|
('phone', phonenumber_field.modelfields.PhoneNumberField(editable=False, max_length=128, region=None, unique=True)),
|
||||||
models.CharField(max_length=200, primary_key=True, serialize=False),
|
('name', models.CharField(max_length=200)),
|
||||||
),
|
('number_validated', models.BooleanField(default=False)),
|
||||||
("name", models.CharField(max_length=200)),
|
|
||||||
("number_validated", models.BooleanField(default=False)),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
migrations.CreateModel(
|
migrations.CreateModel(
|
||||||
name="Room",
|
name='Room',
|
||||||
fields=[
|
fields=[
|
||||||
(
|
('name', models.CharField(max_length=200, primary_key=True, serialize=False)),
|
||||||
"name",
|
('required_helpers', models.IntegerField()),
|
||||||
models.CharField(max_length=200, primary_key=True, serialize=False),
|
|
||||||
),
|
|
||||||
("required_helpers", models.IntegerField()),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
migrations.CreateModel(
|
migrations.CreateModel(
|
||||||
name="Shift",
|
name='Shift',
|
||||||
fields=[
|
fields=[
|
||||||
(
|
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
"id",
|
('start_at', models.DateTimeField()),
|
||||||
models.BigAutoField(
|
('duration', models.DurationField()),
|
||||||
auto_created=True,
|
('deleted', models.BooleanField(default=False)),
|
||||||
primary_key=True,
|
('room', models.ForeignKey(on_delete=django.db.models.deletion.RESTRICT, to='app.room')),
|
||||||
serialize=False,
|
|
||||||
verbose_name="ID",
|
|
||||||
),
|
|
||||||
),
|
|
||||||
("start_at", models.DateTimeField()),
|
|
||||||
("duration", models.DurationField()),
|
|
||||||
(
|
|
||||||
"room",
|
|
||||||
models.ForeignKey(
|
|
||||||
on_delete=django.db.models.deletion.RESTRICT, to="app.room"
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
migrations.CreateModel(
|
migrations.CreateModel(
|
||||||
name="Message",
|
name='Message',
|
||||||
fields=[
|
fields=[
|
||||||
(
|
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
"id",
|
('text', models.CharField(max_length=160)),
|
||||||
models.BigAutoField(
|
('created_at', models.DateTimeField(auto_now_add=True)),
|
||||||
auto_created=True,
|
('to', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='app.helper')),
|
||||||
primary_key=True,
|
|
||||||
serialize=False,
|
|
||||||
verbose_name="ID",
|
|
||||||
),
|
|
||||||
),
|
|
||||||
("text", models.CharField(max_length=160)),
|
|
||||||
(
|
|
||||||
"to",
|
|
||||||
models.ForeignKey(
|
|
||||||
on_delete=django.db.models.deletion.CASCADE, to="app.helper"
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
migrations.CreateModel(
|
migrations.CreateModel(
|
||||||
name="LoginToken",
|
name='LoginToken',
|
||||||
fields=[
|
fields=[
|
||||||
(
|
('id', models.CharField(default=shiftregister.app.models.gen_token, editable=False, max_length=20, primary_key=True, serialize=False)),
|
||||||
"id",
|
('sent_at', models.DateTimeField(auto_now_add=True)),
|
||||||
models.CharField(
|
('helper', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='app.helper')),
|
||||||
default=shiftregister.app.models.gen_token,
|
|
||||||
editable=False,
|
|
||||||
max_length=20,
|
|
||||||
primary_key=True,
|
|
||||||
serialize=False,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
(
|
|
||||||
"helper",
|
|
||||||
models.ForeignKey(
|
|
||||||
on_delete=django.db.models.deletion.CASCADE, to="app.helper"
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
migrations.CreateModel(
|
migrations.CreateModel(
|
||||||
name="ShiftRegistration",
|
name='ShiftRegistration',
|
||||||
fields=[
|
fields=[
|
||||||
(
|
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
"id",
|
('reminder_sent', models.BooleanField(default=False)),
|
||||||
models.BigAutoField(
|
('helper', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='app.helper')),
|
||||||
auto_created=True,
|
('shift', models.ForeignKey(on_delete=django.db.models.deletion.RESTRICT, to='app.shift')),
|
||||||
primary_key=True,
|
|
||||||
serialize=False,
|
|
||||||
verbose_name="ID",
|
|
||||||
),
|
|
||||||
),
|
|
||||||
(
|
|
||||||
"helper",
|
|
||||||
models.ForeignKey(
|
|
||||||
on_delete=django.db.models.deletion.CASCADE, to="app.helper"
|
|
||||||
),
|
|
||||||
),
|
|
||||||
(
|
|
||||||
"shift",
|
|
||||||
models.ForeignKey(
|
|
||||||
on_delete=django.db.models.deletion.RESTRICT, to="app.shift"
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
options={
|
options={
|
||||||
"unique_together": {("shift", "helper")},
|
'unique_together': {('shift', 'helper')},
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
|
|
|
@ -1,22 +0,0 @@
|
||||||
# Generated by Django 4.0.4 on 2022-04-20 17:01
|
|
||||||
|
|
||||||
from django.db import migrations, models
|
|
||||||
import django.utils.timezone
|
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
|
||||||
|
|
||||||
dependencies = [
|
|
||||||
("app", "0001_initial"),
|
|
||||||
]
|
|
||||||
|
|
||||||
operations = [
|
|
||||||
migrations.AddField(
|
|
||||||
model_name="logintoken",
|
|
||||||
name="sent_at",
|
|
||||||
field=models.DateTimeField(
|
|
||||||
auto_now_add=True, default=django.utils.timezone.now
|
|
||||||
),
|
|
||||||
preserve_default=False,
|
|
||||||
),
|
|
||||||
]
|
|
|
@ -1,22 +0,0 @@
|
||||||
# Generated by Django 4.0.4 on 2022-04-20 17:06
|
|
||||||
|
|
||||||
from django.db import migrations, models
|
|
||||||
import django.utils.timezone
|
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
|
||||||
|
|
||||||
dependencies = [
|
|
||||||
("app", "0002_logintoken_sent_at"),
|
|
||||||
]
|
|
||||||
|
|
||||||
operations = [
|
|
||||||
migrations.AddField(
|
|
||||||
model_name="message",
|
|
||||||
name="created_at",
|
|
||||||
field=models.DateTimeField(
|
|
||||||
auto_now_add=True, default=django.utils.timezone.now
|
|
||||||
),
|
|
||||||
preserve_default=False,
|
|
||||||
),
|
|
||||||
]
|
|
|
@ -1,18 +0,0 @@
|
||||||
# Generated by Django 4.0.4 on 2022-04-20 17:57
|
|
||||||
|
|
||||||
from django.db import migrations, models
|
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
|
||||||
|
|
||||||
dependencies = [
|
|
||||||
("app", "0003_message_created_at"),
|
|
||||||
]
|
|
||||||
|
|
||||||
operations = [
|
|
||||||
migrations.AddField(
|
|
||||||
model_name="shiftregistration",
|
|
||||||
name="reminder_sent",
|
|
||||||
field=models.BooleanField(default=False),
|
|
||||||
),
|
|
||||||
]
|
|
|
@ -1,20 +0,0 @@
|
||||||
# Generated by Django 4.0.4 on 2022-04-22 00:06
|
|
||||||
|
|
||||||
from django.db import migrations, models
|
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
|
||||||
|
|
||||||
dependencies = [
|
|
||||||
("app", "0004_shiftregistration_reminder_sent"),
|
|
||||||
]
|
|
||||||
|
|
||||||
operations = [
|
|
||||||
migrations.AlterField(
|
|
||||||
model_name="helper",
|
|
||||||
name="phone",
|
|
||||||
field=models.CharField(
|
|
||||||
editable=False, max_length=200, primary_key=True, serialize=False
|
|
||||||
),
|
|
||||||
),
|
|
||||||
]
|
|
|
@ -1,18 +0,0 @@
|
||||||
# Generated by Django 4.0.4 on 2022-04-23 00:40
|
|
||||||
|
|
||||||
from django.db import migrations, models
|
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
|
||||||
|
|
||||||
dependencies = [
|
|
||||||
("app", "0005_alter_helper_phone"),
|
|
||||||
]
|
|
||||||
|
|
||||||
operations = [
|
|
||||||
migrations.AddField(
|
|
||||||
model_name="shift",
|
|
||||||
name="deleted",
|
|
||||||
field=models.BooleanField(default=False),
|
|
||||||
),
|
|
||||||
]
|
|
|
@ -1,25 +0,0 @@
|
||||||
# Generated by Django 4.0.4 on 2022-04-27 12:41
|
|
||||||
|
|
||||||
from django.db import migrations
|
|
||||||
import phonenumber_field.modelfields
|
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
|
||||||
|
|
||||||
dependencies = [
|
|
||||||
("app", "0006_shift_deleted"),
|
|
||||||
]
|
|
||||||
|
|
||||||
operations = [
|
|
||||||
migrations.AlterField(
|
|
||||||
model_name="helper",
|
|
||||||
name="phone",
|
|
||||||
field=phonenumber_field.modelfields.PhoneNumberField(
|
|
||||||
editable=False,
|
|
||||||
max_length=128,
|
|
||||||
primary_key=True,
|
|
||||||
region=None,
|
|
||||||
serialize=False,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
]
|
|
|
@ -33,7 +33,7 @@ class Shift(models.Model):
|
||||||
|
|
||||||
|
|
||||||
class Helper(models.Model):
|
class Helper(models.Model):
|
||||||
phone = PhoneNumberField(primary_key=True, editable=False)
|
phone = PhoneNumberField(unique=True, editable=False)
|
||||||
name = models.CharField(max_length=200)
|
name = models.CharField(max_length=200)
|
||||||
# change this to a generic state variable to allow for number blocking/account deactivation?
|
# change this to a generic state variable to allow for number blocking/account deactivation?
|
||||||
number_validated = models.BooleanField(default=False)
|
number_validated = models.BooleanField(default=False)
|
||||||
|
|
|
@ -98,7 +98,7 @@ def register(request):
|
||||||
if not form.is_valid():
|
if not form.is_valid():
|
||||||
context["form"] = form
|
context["form"] = form
|
||||||
return render(request, "register.html", context)
|
return render(request, "register.html", context)
|
||||||
helper = Helper.objects.filter(pk=form.cleaned_data["phone"]).first()
|
helper = Helper.objects.filter(phone=form.cleaned_data["phone"]).first()
|
||||||
if helper:
|
if helper:
|
||||||
token = helper.logintoken_set.first()
|
token = helper.logintoken_set.first()
|
||||||
# todo: resend login link after x minutes?
|
# todo: resend login link after x minutes?
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
# Generated by Django 4.0.4 on 2022-04-23 00:42
|
# Generated by Django 4.0.4 on 2022-04-27 14:11
|
||||||
|
|
||||||
from django.db import migrations, models
|
from django.db import migrations, models
|
||||||
import django.db.models.deletion
|
import django.db.models.deletion
|
||||||
|
@ -9,41 +9,24 @@ class Migration(migrations.Migration):
|
||||||
initial = True
|
initial = True
|
||||||
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
("app", "0006_shift_deleted"),
|
('app', '0001_initial'),
|
||||||
]
|
]
|
||||||
|
|
||||||
operations = [
|
operations = [
|
||||||
migrations.CreateModel(
|
migrations.CreateModel(
|
||||||
name="Calendar",
|
name='Calendar',
|
||||||
fields=[
|
fields=[
|
||||||
("url", models.URLField(primary_key=True, serialize=False)),
|
('url', models.URLField(primary_key=True, serialize=False)),
|
||||||
("has_errors", models.BooleanField(default=False, editable=False)),
|
('has_errors', models.BooleanField(default=False, editable=False)),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
migrations.CreateModel(
|
migrations.CreateModel(
|
||||||
name="Event",
|
name='Event',
|
||||||
fields=[
|
fields=[
|
||||||
(
|
('shift_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, to='app.shift')),
|
||||||
"shift_ptr",
|
('uuid', models.UUIDField(editable=False, primary_key=True, serialize=False)),
|
||||||
models.OneToOneField(
|
('calendar', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='importer.calendar')),
|
||||||
auto_created=True,
|
|
||||||
on_delete=django.db.models.deletion.CASCADE,
|
|
||||||
parent_link=True,
|
|
||||||
to="app.shift",
|
|
||||||
),
|
|
||||||
),
|
|
||||||
(
|
|
||||||
"uuid",
|
|
||||||
models.UUIDField(editable=False, primary_key=True, serialize=False),
|
|
||||||
),
|
|
||||||
(
|
|
||||||
"calendar",
|
|
||||||
models.ForeignKey(
|
|
||||||
on_delete=django.db.models.deletion.CASCADE,
|
|
||||||
to="importer.calendar",
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
bases=("app.shift",),
|
bases=('app.shift',),
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
|
|
Loading…
Reference in New Issue