cmsmanage/doorcontrol/migrations/0001_initial.py

286 lines
10 KiB
Python
Raw Permalink Normal View History

# Generated by Django 5.1 on 2024-08-21 18:31
import django.db.models.deletion
from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = [
("membershipworks", "0001_initial"),
]
operations = [
migrations.CreateModel(
name="Door",
fields=[
(
"id",
models.BigAutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
("name", models.CharField(max_length=64, unique=True)),
("ip", models.GenericIPAddressField(protocol="IPv4")),
(
"access_field",
models.TextField(
help_text="Membershipworks field that grants members access to this door",
max_length=128,
),
),
],
),
migrations.CreateModel(
name="HIDEvent",
fields=[
(
"id",
models.BigAutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
("timestamp", models.DateTimeField()),
(
"event_type",
models.IntegerField(
choices=[
(1022, "Denied Access: Card Not Found"),
(1023, "Denied Access Access: PIN Not Found"),
(2020, "Granted Access"),
(2021, "Granted Access: Extended Time"),
(2024, "Denied Access: Schedule"),
(2029, "Denied Access: Wrong PIN"),
(2036, "Denied Access: Card Expired"),
(2042, "Denied Access: PIN Lockout"),
(2043, "Denied Access: Unassigned Card"),
(2044, "Denied Access: Unassigned Access PIN"),
(2046, "Denied Access: PIN Expired"),
(4034, "Alarm Acknowledged"),
(4035, "Door Locked: Scheduled"),
(4036, "Door Unlocked: Scheduled"),
(4041, "Door Forced Alarm"),
(4042, "Door Held Alarm"),
(4043, "Tamper Switch Alarm"),
(4044, "AC Failure"),
(4045, "Battery Failure"),
(4051, "REX Switch Alarm"),
(7020, "Time Set To"),
(12031, "Granted Access: Manual"),
(12032, "Door Unlocked"),
(12033, "Door Locked"),
],
db_column="eventType",
),
),
("reader_address", models.IntegerField(db_column="readerAddress")),
(
"cardholder_id",
models.IntegerField(
blank=True, db_column="cardholderID", null=True
),
),
(
"command_status",
models.BooleanField(
blank=True, db_column="commandStatus", null=True
),
),
("forename", models.TextField(blank=True, null=True)),
("surname", models.TextField(blank=True, null=True)),
(
"io_state",
models.BooleanField(blank=True, db_column="ioState", null=True),
),
(
"new_time",
models.DateTimeField(blank=True, db_column="newTime", null=True),
),
(
"old_time",
models.DateTimeField(blank=True, db_column="oldTime", null=True),
),
(
"raw_card_number",
models.CharField(
blank=True, db_column="rawCardNumber", max_length=8, null=True
),
),
(
"door",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
to="doorcontrol.door",
),
),
(
"is_red",
models.GeneratedField(
db_persist=True,
expression=models.Q(
(
"event_type__in",
[
1022,
1023,
2024,
2029,
2036,
2042,
2043,
2046,
4041,
4042,
4043,
4044,
4045,
],
)
),
output_field=models.BooleanField(),
),
),
],
options={
"db_table": "hidevent",
"ordering": ("-timestamp",),
"constraints": [
models.UniqueConstraint(
fields=("door", "timestamp", "event_type"),
name="unique_hidevent",
)
],
},
),
migrations.CreateModel(
name="DoorCardholderMember",
fields=[
(
"id",
models.BigAutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
("cardholder_id", models.IntegerField()),
(
"door",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
to="doorcontrol.door",
),
),
(
"member",
models.ForeignKey(
db_constraint=False,
on_delete=django.db.models.deletion.CASCADE,
to="membershipworks.member",
),
),
],
options={
"constraints": [
models.UniqueConstraint(
fields=("door", "cardholder_id"),
name="unique_door_cardholder_id",
),
models.UniqueConstraint(
fields=("door", "member"), name="unique_door_member"
),
],
},
),
migrations.CreateModel(
name="Schedule",
fields=[
(
"id",
models.BigAutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
("name", models.CharField(max_length=255, unique=True)),
],
),
migrations.CreateModel(
name="FlagScheduleRule",
fields=[
(
"id",
models.BigAutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
("doors", models.ManyToManyField(to="doorcontrol.door")),
(
"flag",
models.ForeignKey(
blank=True,
db_constraint=False,
null=True,
on_delete=django.db.models.deletion.PROTECT,
to="membershipworks.flag",
),
),
(
"schedule",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
to="doorcontrol.schedule",
),
),
],
options={
"abstract": False,
},
),
migrations.CreateModel(
name="AttributeScheduleRule",
fields=[
(
"id",
models.BigAutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
(
"access_field",
models.CharField(
help_text="Membershipworks field that grants members access to this door using this schedule.",
max_length=128,
),
),
("doors", models.ManyToManyField(to="doorcontrol.door")),
(
"schedule",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
to="doorcontrol.schedule",
),
),
],
options={
"abstract": False,
},
),
]