Skip to content

Commit 46a2ec4

Browse files
authored
Merge pull request #28 from EventAccess/Draft_Frontend
updated the models.
2 parents 2bbe058 + 09dd476 commit 46a2ec4

3 files changed

Lines changed: 65 additions & 6 deletions

File tree

admin.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
11
from django.contrib import admin
2+
from .models import Attendant, Crew
3+
4+
class AttendantAdmin(admin.ModelAdmin):
5+
list_display = ["ticket_id", "nfc_id", "is_crew", "is_valid"]
6+
7+
8+
class CrewAdmin(admin.ModelAdmin):
9+
list_display = ["first_name", "last_name", "email", "phone_number","discord"]
10+
11+
12+
admin.site.register(Crew, CrewAdmin)
13+
admin.site.register(Attendant, AttendantAdmin)
14+
215

316
# Register your models here.
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Generated by Django 5.1.3 on 2025-01-06 22:56
2+
3+
import database.validators
4+
import django.db.models.deletion
5+
from django.db import migrations, models
6+
7+
8+
class Migration(migrations.Migration):
9+
10+
dependencies = [
11+
('database', '0003_attendant_is_valid'),
12+
]
13+
14+
operations = [
15+
migrations.RemoveField(
16+
model_name='attendant',
17+
name='discord',
18+
),
19+
migrations.CreateModel(
20+
name='Crew',
21+
fields=[
22+
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
23+
('first_name', models.CharField(max_length=30)),
24+
('last_name', models.CharField(max_length=30)),
25+
('email', models.EmailField(max_length=100)),
26+
('phone_number', models.CharField(max_length=12)),
27+
('discord', models.CharField(blank=True, max_length=32, null=True, unique=True, validators=[database.validators.discord_username_validator])),
28+
('attendant', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='database.attendant')),
29+
],
30+
),
31+
]

models.py

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,32 @@
77
class Attendant(models.Model):
88
ticket_id = models.CharField(max_length=128, unique=True, null=True, blank=True)
99
nfc_id = models.BinaryField(max_length=7, unique=True, null=False, blank=False)
10+
is_crew = models.BooleanField(default=False)
11+
_is_valid = models.BooleanField(name="is_valid", default=True)
12+
13+
@property
14+
def is_valid(self):
15+
# TODO: Validate daily ticket here
16+
return self._is_valid
17+
18+
19+
20+
class Crew(models.Model):
21+
attendant = models.ForeignKey(Attendant,on_delete=models.CASCADE) ##if we are deleting attandant object, delete crew aswell.
22+
first_name = models.CharField(max_length=30)
23+
last_name = models.CharField(max_length=30)
24+
email = models.EmailField(max_length=100)
25+
phone_number = models.CharField(max_length=12)
26+
1027
discord = models.CharField(
1128
max_length=32,
1229
unique=True,
1330
null=True,
1431
blank=True,
1532
validators=[discord_username_validator],
1633
)
17-
is_crew = models.BooleanField(default=False)
18-
_is_valid = models.BooleanField(name="is_valid", default=True)
1934

20-
@property
21-
def is_valid(self):
22-
# TODO: Validate daily ticket here
23-
return self._is_valid
35+
def __str__(self):
36+
return f"{self.first_name} {self.last_name}"
37+
38+

0 commit comments

Comments
 (0)