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
|
||||
import django.db.models.deletion
|
||||
import phonenumber_field.modelfields
|
||||
import shiftregister.app.models
|
||||
|
||||
|
||||
|
@ -9,121 +10,63 @@ class Migration(migrations.Migration):
|
|||
|
||||
initial = True
|
||||
|
||||
dependencies = []
|
||||
dependencies = [
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name="Helper",
|
||||
name='Helper',
|
||||
fields=[
|
||||
(
|
||||
"phone",
|
||||
models.CharField(max_length=200, primary_key=True, serialize=False),
|
||||
),
|
||||
("name", models.CharField(max_length=200)),
|
||||
("number_validated", models.BooleanField(default=False)),
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('phone', phonenumber_field.modelfields.PhoneNumberField(editable=False, max_length=128, region=None, unique=True)),
|
||||
('name', models.CharField(max_length=200)),
|
||||
('number_validated', models.BooleanField(default=False)),
|
||||
],
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name="Room",
|
||||
name='Room',
|
||||
fields=[
|
||||
(
|
||||
"name",
|
||||
models.CharField(max_length=200, primary_key=True, serialize=False),
|
||||
),
|
||||
("required_helpers", models.IntegerField()),
|
||||
('name', models.CharField(max_length=200, primary_key=True, serialize=False)),
|
||||
('required_helpers', models.IntegerField()),
|
||||
],
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name="Shift",
|
||||
name='Shift',
|
||||
fields=[
|
||||
(
|
||||
"id",
|
||||
models.BigAutoField(
|
||||
auto_created=True,
|
||||
primary_key=True,
|
||||
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"
|
||||
),
|
||||
),
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('start_at', models.DateTimeField()),
|
||||
('duration', models.DurationField()),
|
||||
('deleted', models.BooleanField(default=False)),
|
||||
('room', models.ForeignKey(on_delete=django.db.models.deletion.RESTRICT, to='app.room')),
|
||||
],
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name="Message",
|
||||
name='Message',
|
||||
fields=[
|
||||
(
|
||||
"id",
|
||||
models.BigAutoField(
|
||||
auto_created=True,
|
||||
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"
|
||||
),
|
||||
),
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('text', models.CharField(max_length=160)),
|
||||
('created_at', models.DateTimeField(auto_now_add=True)),
|
||||
('to', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='app.helper')),
|
||||
],
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name="LoginToken",
|
||||
name='LoginToken',
|
||||
fields=[
|
||||
(
|
||||
"id",
|
||||
models.CharField(
|
||||
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"
|
||||
),
|
||||
),
|
||||
('id', models.CharField(default=shiftregister.app.models.gen_token, editable=False, max_length=20, primary_key=True, serialize=False)),
|
||||
('sent_at', models.DateTimeField(auto_now_add=True)),
|
||||
('helper', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='app.helper')),
|
||||
],
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name="ShiftRegistration",
|
||||
name='ShiftRegistration',
|
||||
fields=[
|
||||
(
|
||||
"id",
|
||||
models.BigAutoField(
|
||||
auto_created=True,
|
||||
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"
|
||||
),
|
||||
),
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('reminder_sent', models.BooleanField(default=False)),
|
||||
('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={
|
||||
"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):
|
||||
phone = PhoneNumberField(primary_key=True, editable=False)
|
||||
phone = PhoneNumberField(unique=True, editable=False)
|
||||
name = models.CharField(max_length=200)
|
||||
# change this to a generic state variable to allow for number blocking/account deactivation?
|
||||
number_validated = models.BooleanField(default=False)
|
||||
|
|
|
@ -98,7 +98,7 @@ def register(request):
|
|||
if not form.is_valid():
|
||||
context["form"] = form
|
||||
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:
|
||||
token = helper.logintoken_set.first()
|
||||
# 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
|
||||
import django.db.models.deletion
|
||||
|
@ -9,41 +9,24 @@ class Migration(migrations.Migration):
|
|||
initial = True
|
||||
|
||||
dependencies = [
|
||||
("app", "0006_shift_deleted"),
|
||||
('app', '0001_initial'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name="Calendar",
|
||||
name='Calendar',
|
||||
fields=[
|
||||
("url", models.URLField(primary_key=True, serialize=False)),
|
||||
("has_errors", models.BooleanField(default=False, editable=False)),
|
||||
('url', models.URLField(primary_key=True, serialize=False)),
|
||||
('has_errors', models.BooleanField(default=False, editable=False)),
|
||||
],
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name="Event",
|
||||
name='Event',
|
||||
fields=[
|
||||
(
|
||||
"shift_ptr",
|
||||
models.OneToOneField(
|
||||
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",
|
||||
),
|
||||
),
|
||||
('shift_ptr', models.OneToOneField(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