Skip to content

Commit 0bc8cdf

Browse files
authored
Merge pull request #43 from EventAccess/Draft_api
Draft api
2 parents b6b96e7 + 31a837d commit 0bc8cdf

21 files changed

Lines changed: 653 additions & 12 deletions

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/exceptions.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from rest_framework.exceptions import APIException
2+
3+
# write your custm exceptions here if we need it later.

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: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Generated by Django 5.1.3 on 2024-11-25 08:50
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
initial = True
9+
10+
dependencies = []
11+
12+
operations = [
13+
migrations.CreateModel(
14+
name="Attendant",
15+
fields=[
16+
(
17+
"id",
18+
models.BigAutoField(
19+
auto_created=True,
20+
primary_key=True,
21+
serialize=False,
22+
verbose_name="ID",
23+
),
24+
),
25+
("first_name", models.CharField(max_length=30)),
26+
("last_name", models.CharField(max_length=30)),
27+
("email", models.EmailField(max_length=100)),
28+
("phone_number", models.CharField(max_length=12)),
29+
],
30+
),
31+
]
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: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
from django.db import models
2+
from rest_framework import serializers
3+
from django.contrib.auth.models import User
24

35
# Create your models here.

0 commit comments

Comments
 (0)