Skip to content

Commit

Permalink
Merge pull request #492 from tamuhack-org/admin
Browse files Browse the repository at this point in the history
Allows manually adding an application in the admin panel
  • Loading branch information
NitroGuy10 authored Oct 28, 2024
2 parents 4c669da + aed8d2a commit 61df8c1
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 7 deletions.
4 changes: 2 additions & 2 deletions hiss/application/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ class ApplicationAdmin(admin.ModelAdmin):
readonly_fields = [
"datetime_submitted",
"user",
"is_adult",
# "is_adult",
"gender",
"race",
"major",
Expand Down Expand Up @@ -283,7 +283,7 @@ class ApplicationAdmin(admin.ModelAdmin):
},
),
("Confirmation Deadline", {"fields": ["confirmation_deadline"]}),
("Miscellaneous", {"fields": ["notes"]}),
("Miscellaneous", {"fields": ["notes", "is_adult"]}),
]
formfield_overrides = {
AddressField: {"widget": AddressWidget(attrs={"style": "width: 300px;"})}
Expand Down
28 changes: 28 additions & 0 deletions hiss/application/migrations/0025_auto_20241024_1250.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Generated by Django 2.2.13 on 2024-10-24 17:50

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('application', '0024_auto_20240823_1038'),
]

operations = [
migrations.AlterField(
model_name='application',
name='major',
field=models.CharField(choices=[('Computer Science', 'Computer Science'), ('Computer Engineering', 'Computer Engineering'), ('Computing', 'Computing'), ('Electrical Engineering', 'Electrical Engineering'), ('Management Information Systems', 'Management Information Systems'), ('Data Science/Engineering', 'Data Science/Engineering'), ('General Engineering', 'General Engineering'), ('Biomedical Engineering', 'Biomedical Engineering'), ('Chemical Engineering', 'Chemical Engineering'), ('Civil Engineering', 'Civil Engineering'), ('Industrial Engineering', 'Industrial Engineering'), ('Mechanical Engineering', 'Mechanical Engineering'), ('Aerospace Engineering', 'Aerospace Engineering'), ('Electronic Systems Engineering Technology (ESET)', 'Electronic Systems Engineering Technology (ESET)'), ('Mathematics', 'Mathematics'), ('Physics', 'Physics'), ('Statistics', 'Statistics'), ('Biology', 'Biology'), ('Chemistry', 'Chemistry'), ('Other', 'Other')], default='NA', max_length=100, verbose_name="What's your major?"),
),
migrations.AlterField(
model_name='application',
name='wants_team',
field=models.CharField(choices=[('Friend', 'From a friend'), ('Tabling', 'Tabling outside Zachry'), ('Howdy Week', 'From Howdy Week'), ('Yard Sign', 'Yard sign'), ('Social Media', 'Social media'), ('Student Orgs', 'Though another student org'), ('TH Organizer', 'From a TAMUhack organizer'), ('ENGR Newsletter', 'From the TAMU Engineering Newsletter'), ('MLH', 'Major League Hacking (MLH)'), ('Attended Before', "I've attended HowdyHack before")], max_length=16, verbose_name='How did you hear about HowdyHack?'),
),
migrations.AlterField(
model_name='application',
name='wares',
field=models.CharField(blank=True, choices=[('SW', 'Software'), ('HW', 'Hardware')], default='NA', max_length=8, verbose_name='TAMUhack will be partnering with IEEE to offer a dedicated hardware track and prizes. Participants can choose to compete in this track or in the general software tracks. Would you like to compete in the software or hardware track'),
),
]
27 changes: 22 additions & 5 deletions hiss/application/models.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# pylint: disable=C0330
import uuid
from typing import List, Optional, Tuple
import re

from django.conf import settings
from django.core import exceptions
Expand Down Expand Up @@ -558,12 +559,28 @@ def get_absolute_url(self):

def clean(self):
super().clean()
if not self.is_adult:

def is_valid_name(name):
pattern = r"^(?=.{1,40}$)[a-zA-Z]+(?:[-' ][a-zA-Z]+)*$"

match = re.match(pattern, name)

return bool(match)


if not self.age.isnumeric():
raise exceptions.ValidationError("Age must be a number.")
if not self.is_adult and int(self.age) > 18 or self.is_adult and int(self.age) < 18:
raise exceptions.ValidationError(
"Age and adult status do not match. Please confirm you are 18 or older."
)
#Fixes the obos admin panel bug, idk why the checkbox doesn't show up
if not int(self.age) >= 18 or not self.is_adult:
raise exceptions.ValidationError(
"Unfortunately, we cannot accept hackers under the age of 18. Have additional questions? Email "
f"us at {settings.ORGANIZER_EMAIL}. "
)
if not self.first_name.isalpha():
raise exceptions.ValidationError("First name can only contain letters.")
if not self.last_name.isalpha():
raise exceptions.ValidationError("Last name can only contain letters.")
if not is_valid_name(self.first_name):
raise exceptions.ValidationError("First name can only contain letters, spaces, hyphens, and apostrophes.")
if not is_valid_name(self.last_name):
raise exceptions.ValidationError("Last name can only contain letters, spaces, hyphens, and apostrophes.")

0 comments on commit 61df8c1

Please sign in to comment.