Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions portal/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
"storages",
"portal",
"volunteer",
"speaker",
"portal_account",
"widget_tweaks",
]
Expand Down
1 change: 1 addition & 0 deletions portal/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
urlpatterns = [
path("", views.index, name="index"),
path("volunteer/", include("volunteer.urls", namespace="volunteer")),
path("speaker/", include("speaker.urls", namespace="speaker")),
path("admin/", admin.site.urls),
path("accounts/", include("allauth.urls")),
path(
Expand Down
Empty file added speaker/__init__.py
Empty file.
Empty file added speaker/admin.py
Empty file.
6 changes: 6 additions & 0 deletions speaker/apps.py
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VolunteerConfig needs renamed

Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from django.apps import AppConfig


class VolunteerConfig(AppConfig):
default_auto_field = "django.db.models.BigAutoField"
name = "speaker"
31 changes: 31 additions & 0 deletions speaker/constants.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
from enum import StrEnum


# class RoleTypes(StrEnum):
# """Role types for the volunteer."""

# ADMIN = "Admin"
# STAFF = "Staff"
# VENDOR = "Vendor"
# VOLUNTEER = "Volunteer"


class ApplicationStatus(StrEnum):
"""Application status for the volunteer."""

PENDING = "Pending Review"
APPROVED = "Approved"
REJECTED = "Rejected"
CANCELLED = "Cancelled"


class Region(StrEnum):
"""Region where the volunteer usually reside."""

NO_REGION = ""
ASIA = "Asia"
EUROPE = "Europe"
NORTH_AMERICA = "North America"
SOUTH_AMERICA = "South America"
AFRICA = "Africa"
OCEANIA = "Oceania"
Empty file.
Empty file.
67 changes: 67 additions & 0 deletions speaker/forms.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import re

from django import forms
from django.core.exceptions import ValidationError
from django.forms import ModelForm
from django.forms.widgets import SelectMultiple

from .languages import LANGUAGES
from .models import SpeakerProfile

class LanguageSelectMultiple(SelectMultiple):
"""
A custom widget for selecting multiple languages with autocomplete.
"""

def __init__(self, attrs=None, choices=()):
default_attrs = {
"class": "form-control select2-multiple",
"data-placeholder": "Start typing to select languages...",
}
if attrs:
default_attrs.update(attrs)
super().__init__(default_attrs, choices)

class SpeakerProfileForm(ModelForm):

# discord_username = forms.CharField(required=True)
additional_comments = forms.CharField(widget=forms.Textarea, required=False)

class Meta:
model = SpeakerProfile
exclude = ["user", "application_status"]
help_texts = {
# "github_username": "GitHub username (e.g., username)",
# "discord_username": "Required - Your Discord username for team communication (e.g., username#1234)",
# "instagram_username": "Instagram username without @ (e.g., username)",
# "bluesky_username": "Bluesky username (e.g., username or username.bsky.social)",
# "mastodon_url": "Mastodon handle (e.g., @[email protected] or https://instance.tld/@username)",
# "x_username": "X/Twitter username without @ (e.g., username)",
# "linkedin_url": "LinkedIn URL (e.g., linkedin.com/in/username)",
"region": "Region where you normally reside",
}

def clean(self):
cleaned_data = super().clean()
return cleaned_data

def __init__(self, *args, **kwargs):
self.user = kwargs.pop("user", None)
super().__init__(*args, **kwargs)

sorted_languages = sorted(LANGUAGES, key=lambda x: x[1])

self.fields["discord_username"].required = True
self.fields["languages_spoken"].choices = sorted_languages
self.fields["languages_spoken"].widget = LanguageSelectMultiple(
choices=sorted_languages
)

if self.instance and self.instance.pk:
pass

def save(self, commit=True):
if self.user:
self.instance.user = self.user
volunteer_profile = super().save(commit)
return volunteer_profile
Loading