Skip to content

Commit 4783222

Browse files
authored
Merge pull request #42 from EventAccess/draft_user_registration
Biggest-yolo
2 parents 9f60e73 + a33ad33 commit 4783222

21 files changed

Lines changed: 467 additions & 38 deletions

backendapi/admin.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1 @@
11
from django.contrib import admin
2-
from .models import Attendant
3-
4-
5-
class AttendantAdmin(admin.ModelAdmin):
6-
list_display = ["first_name", "last_name", "email", "phone_number"]
7-
8-
9-
admin.site.register(Attendant, AttendantAdmin)

backendapi/converters.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ class BinaryHexConverter:
55
regex = "(?:[0-9a-fA-F]{2})+"
66

77
def to_python(self, value: str) -> bytes:
8-
return b16decode(value, casefold=True)
8+
return b16encode(b16decode(value, casefold=True)).decode
99

1010
def to_url(self, value: bytes) -> str:
11-
return b16encode(value).decode()
11+
return value

backendapi/forms.py

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
from django import forms
2+
from database.models import Attendant, Crewmember, Crews
3+
4+
5+
class AttendantNFCForm(forms.ModelForm):
6+
prefix = "attendant"
7+
8+
class Meta:
9+
model = Attendant
10+
fields = [
11+
"nfc_id",
12+
]
13+
widgets = {
14+
"nfc_id": forms.TextInput(
15+
attrs={
16+
"class": "form-input",
17+
"placeholder": "Scan NFC tag...",
18+
# "disabled": True,
19+
}
20+
),
21+
}
22+
23+
24+
class CrewmemberForm(forms.ModelForm):
25+
# Allow multiple (different) forms in single page
26+
# Can also be specified as an argument to the class init
27+
prefix = "crewmember"
28+
29+
class Meta:
30+
model = Crewmember # Link the form to the Attendant model
31+
fields = [
32+
"first_name",
33+
"last_name",
34+
"email",
35+
"discord",
36+
"phone_number",
37+
"crew",
38+
"profile_image",
39+
]
40+
widgets = {
41+
"first_name": forms.TextInput(
42+
attrs={"class": "form-input", "placeholder": "Ola"}
43+
),
44+
"last_name": forms.TextInput(
45+
attrs={"class": "form-input", "placeholder": "Nordmann"}
46+
),
47+
"email": forms.EmailInput(
48+
attrs={"class": "form-input", "placeholder": "email@example.com"}
49+
),
50+
"discord": forms.TextInput(
51+
attrs={"class": "form-input", "placeholder": "Discord#1234"}
52+
),
53+
"phone_number": forms.TextInput(
54+
attrs={"class": "form-input", "placeholder": "+47012345678"}
55+
),
56+
"crew": forms.TextInput(
57+
# Crews.objects.all(),
58+
attrs={"class": "form-input", "placeholder": "Select crew..."},
59+
),
60+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Generated by Django 5.1.3 on 2025-01-06 22:56
2+
3+
from django.db import migrations
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
("backendapi", "0001_initial"),
10+
]
11+
12+
operations = [
13+
migrations.DeleteModel(
14+
name="Attendant",
15+
),
16+
]
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Generated by Django 4.2.7 on 2025-02-14 20:48
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
initial = True
9+
10+
dependencies = [
11+
("backendapi", "0002_delete_attendant"),
12+
]
13+
14+
operations = [
15+
migrations.CreateModel(
16+
name="Attendant",
17+
fields=[
18+
(
19+
"id",
20+
models.BigAutoField(
21+
auto_created=True,
22+
primary_key=True,
23+
serialize=False,
24+
verbose_name="ID",
25+
),
26+
),
27+
("first_name", models.CharField(max_length=30)),
28+
("last_name", models.CharField(max_length=30)),
29+
("email", models.EmailField(max_length=100)),
30+
("phone_number", models.CharField(max_length=12)),
31+
],
32+
),
33+
]
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# Generated by Django 4.2.7 on 2025-02-19 18:05
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
("backendapi", "0003_initial"),
10+
]
11+
12+
operations = [
13+
migrations.AddField(
14+
model_name="attendant",
15+
name="crew",
16+
field=models.CharField(default="Undefined crew", max_length=100),
17+
),
18+
migrations.AddField(
19+
model_name="attendant",
20+
name="discord",
21+
field=models.CharField(default=False, max_length=100),
22+
preserve_default=False,
23+
),
24+
migrations.AddField(
25+
model_name="attendant",
26+
name="profile_image",
27+
field=models.ImageField(blank=True, null=True, upload_to="profile_images/"),
28+
),
29+
migrations.AddField(
30+
model_name="attendant",
31+
name="ticketCrewID",
32+
field=models.CharField(default=False, max_length=100),
33+
preserve_default=False,
34+
),
35+
migrations.AlterField(
36+
model_name="attendant",
37+
name="email",
38+
field=models.EmailField(max_length=200),
39+
),
40+
migrations.AlterField(
41+
model_name="attendant",
42+
name="first_name",
43+
field=models.CharField(max_length=100),
44+
),
45+
migrations.AlterField(
46+
model_name="attendant",
47+
name="last_name",
48+
field=models.CharField(max_length=100),
49+
),
50+
migrations.AlterField(
51+
model_name="attendant",
52+
name="phone_number",
53+
field=models.CharField(max_length=15),
54+
),
55+
]
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Generated by Django 4.2.7 on 2025-02-19 18:10
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
("backendapi", "0004_attendant_crew_attendant_discord_and_more"),
10+
]
11+
12+
operations = [
13+
migrations.AlterField(
14+
model_name="attendant",
15+
name="crew",
16+
field=models.CharField(max_length=100),
17+
),
18+
migrations.AlterField(
19+
model_name="attendant",
20+
name="ticketCrewID",
21+
field=models.CharField(max_length=100, null=True),
22+
),
23+
]
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Generated by Django 5.1.5 on 2025-02-20 14:45
2+
3+
from django.db import migrations
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
("backendapi", "0005_alter_attendant_crew_alter_attendant_ticketcrewid"),
10+
]
11+
12+
operations = [
13+
migrations.DeleteModel(
14+
name="Attendant",
15+
),
16+
]

backendapi/models.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,4 @@
22
from rest_framework import serializers
33
from django.contrib.auth.models import User
44

5-
6-
# this is the Attendant model, im unsure if we need more data? Maby date of birth? => 18 years maby?
7-
class Attendant(models.Model):
8-
first_name = models.CharField(max_length=30)
9-
last_name = models.CharField(max_length=30)
10-
email = models.EmailField(max_length=100)
11-
phone_number = models.CharField(max_length=12)
12-
13-
def __str__(self):
14-
return f"{self.first_name} {self.last_name}"
15-
16-
175
# Create your models here.

backendapi/serializers.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import re
22
from rest_framework import serializers
33
from django.conf import settings
4-
from .models import Attendant
4+
from database.models import Crewmember
55

66
# Serializer for the Attendant model: handles validation, serialization, and desersialization of data.
77
# Change the model later depending on requirements. Please tell me what, and il remake the model later to fit requirements.
88

99

10-
class AttendantAdmin(serializers.ModelSerializer): # defined a serialiser class
10+
class CrewmemberAdmin(serializers.ModelSerializer): # defined a serialiser class
1111
first_name = serializers.CharField(
1212
label=("First Name* "), # Labels for the field
1313
required=True, # This makes the fields required.
@@ -68,7 +68,7 @@ class AttendantAdmin(serializers.ModelSerializer): # defined a serialiser class
6868
)
6969

7070
class Meta:
71-
model = Attendant
71+
model = Crewmember
7272
fields = ["first_name", "last_name", "email", "phone_number"]
7373

7474

0 commit comments

Comments
 (0)