mirror of
https://github.com/pacnpal/thrillwiki_django_no_react.git
synced 2026-01-02 01:47:04 -05:00
feat: Implement initial schema and add various API, service, and management command enhancements across the application.
This commit is contained in:
@@ -348,9 +348,7 @@ class RideForm(forms.ModelForm):
|
||||
# editing
|
||||
if self.instance and self.instance.pk:
|
||||
if self.instance.manufacturer:
|
||||
self.fields["manufacturer_search"].initial = (
|
||||
self.instance.manufacturer.name
|
||||
)
|
||||
self.fields["manufacturer_search"].initial = self.instance.manufacturer.name
|
||||
self.fields["manufacturer"].initial = self.instance.manufacturer
|
||||
if self.instance.designer:
|
||||
self.fields["designer_search"].initial = self.instance.designer.name
|
||||
|
||||
@@ -105,8 +105,8 @@ class BasicInfoForm(BaseFilterForm):
|
||||
status_choices = [(choice.value, choice.label) for choice in get_choices("statuses", "rides")]
|
||||
|
||||
# Update field choices dynamically
|
||||
self.fields['category'].choices = category_choices
|
||||
self.fields['status'].choices = status_choices
|
||||
self.fields["category"].choices = category_choices
|
||||
self.fields["status"].choices = status_choices
|
||||
|
||||
category = forms.MultipleChoiceField(
|
||||
choices=[], # Will be populated in __init__
|
||||
@@ -123,17 +123,13 @@ class BasicInfoForm(BaseFilterForm):
|
||||
park = forms.ModelMultipleChoiceField(
|
||||
queryset=Park.objects.all(),
|
||||
required=False,
|
||||
widget=forms.CheckboxSelectMultiple(
|
||||
attrs={"class": "max-h-48 overflow-y-auto space-y-1"}
|
||||
),
|
||||
widget=forms.CheckboxSelectMultiple(attrs={"class": "max-h-48 overflow-y-auto space-y-1"}),
|
||||
)
|
||||
|
||||
park_area = forms.ModelMultipleChoiceField(
|
||||
queryset=ParkArea.objects.all(),
|
||||
required=False,
|
||||
widget=forms.CheckboxSelectMultiple(
|
||||
attrs={"class": "max-h-48 overflow-y-auto space-y-1"}
|
||||
),
|
||||
widget=forms.CheckboxSelectMultiple(attrs={"class": "max-h-48 overflow-y-auto space-y-1"}),
|
||||
)
|
||||
|
||||
|
||||
@@ -266,7 +262,7 @@ class NumberRangeField(forms.MultiValueField):
|
||||
|
||||
def validate(self, value):
|
||||
super().validate(value)
|
||||
if value and value.get("min") is not None and value.get("max") is not None:
|
||||
if value and value.get("min") is not None and value.get("max") is not None: # noqa: SIM102
|
||||
if value["min"] > value["max"]:
|
||||
raise ValidationError("Minimum value must be less than maximum value.")
|
||||
|
||||
@@ -282,17 +278,13 @@ class HeightSafetyForm(BaseFilterForm):
|
||||
label="Minimum Height (inches)",
|
||||
)
|
||||
|
||||
max_height_range = NumberRangeField(
|
||||
min_val=0, max_val=84, step=1, required=False, label="Maximum Height (inches)"
|
||||
)
|
||||
max_height_range = NumberRangeField(min_val=0, max_val=84, step=1, required=False, label="Maximum Height (inches)")
|
||||
|
||||
|
||||
class PerformanceForm(BaseFilterForm):
|
||||
"""Form for performance metric filters."""
|
||||
|
||||
capacity_range = NumberRangeField(
|
||||
min_val=0, max_val=5000, step=50, required=False, label="Capacity per Hour"
|
||||
)
|
||||
capacity_range = NumberRangeField(min_val=0, max_val=5000, step=50, required=False, label="Capacity per Hour")
|
||||
|
||||
duration_range = NumberRangeField(
|
||||
min_val=0,
|
||||
@@ -302,9 +294,7 @@ class PerformanceForm(BaseFilterForm):
|
||||
label="Duration (seconds)",
|
||||
)
|
||||
|
||||
rating_range = NumberRangeField(
|
||||
min_val=0.0, max_val=10.0, step=0.1, required=False, label="Average Rating"
|
||||
)
|
||||
rating_range = NumberRangeField(min_val=0.0, max_val=10.0, step=0.1, required=False, label="Average Rating")
|
||||
|
||||
|
||||
class RelationshipsForm(BaseFilterForm):
|
||||
@@ -313,25 +303,19 @@ class RelationshipsForm(BaseFilterForm):
|
||||
manufacturer = forms.ModelMultipleChoiceField(
|
||||
queryset=Company.objects.filter(roles__contains=["MANUFACTURER"]),
|
||||
required=False,
|
||||
widget=forms.CheckboxSelectMultiple(
|
||||
attrs={"class": "max-h-48 overflow-y-auto space-y-1"}
|
||||
),
|
||||
widget=forms.CheckboxSelectMultiple(attrs={"class": "max-h-48 overflow-y-auto space-y-1"}),
|
||||
)
|
||||
|
||||
designer = forms.ModelMultipleChoiceField(
|
||||
queryset=Company.objects.filter(roles__contains=["DESIGNER"]),
|
||||
required=False,
|
||||
widget=forms.CheckboxSelectMultiple(
|
||||
attrs={"class": "max-h-48 overflow-y-auto space-y-1"}
|
||||
),
|
||||
widget=forms.CheckboxSelectMultiple(attrs={"class": "max-h-48 overflow-y-auto space-y-1"}),
|
||||
)
|
||||
|
||||
ride_model = forms.ModelMultipleChoiceField(
|
||||
queryset=RideModel.objects.all(),
|
||||
required=False,
|
||||
widget=forms.CheckboxSelectMultiple(
|
||||
attrs={"class": "max-h-48 overflow-y-auto space-y-1"}
|
||||
),
|
||||
widget=forms.CheckboxSelectMultiple(attrs={"class": "max-h-48 overflow-y-auto space-y-1"}),
|
||||
)
|
||||
|
||||
|
||||
@@ -347,28 +331,22 @@ class RollerCoasterForm(BaseFilterForm):
|
||||
# Get choices - let exceptions propagate if registry fails
|
||||
track_material_choices = [(choice.value, choice.label) for choice in get_choices("track_materials", "rides")]
|
||||
coaster_type_choices = [(choice.value, choice.label) for choice in get_choices("coaster_types", "rides")]
|
||||
propulsion_system_choices = [(choice.value, choice.label) for choice in get_choices("propulsion_systems", "rides")]
|
||||
propulsion_system_choices = [
|
||||
(choice.value, choice.label) for choice in get_choices("propulsion_systems", "rides")
|
||||
]
|
||||
|
||||
# Update field choices dynamically
|
||||
self.fields['track_material'].choices = track_material_choices
|
||||
self.fields['coaster_type'].choices = coaster_type_choices
|
||||
self.fields['propulsion_system'].choices = propulsion_system_choices
|
||||
self.fields["track_material"].choices = track_material_choices
|
||||
self.fields["coaster_type"].choices = coaster_type_choices
|
||||
self.fields["propulsion_system"].choices = propulsion_system_choices
|
||||
|
||||
height_ft_range = NumberRangeField(
|
||||
min_val=0, max_val=500, step=1, required=False, label="Height (feet)"
|
||||
)
|
||||
height_ft_range = NumberRangeField(min_val=0, max_val=500, step=1, required=False, label="Height (feet)")
|
||||
|
||||
length_ft_range = NumberRangeField(
|
||||
min_val=0, max_val=10000, step=10, required=False, label="Length (feet)"
|
||||
)
|
||||
length_ft_range = NumberRangeField(min_val=0, max_val=10000, step=10, required=False, label="Length (feet)")
|
||||
|
||||
speed_mph_range = NumberRangeField(
|
||||
min_val=0, max_val=150, step=1, required=False, label="Speed (mph)"
|
||||
)
|
||||
speed_mph_range = NumberRangeField(min_val=0, max_val=150, step=1, required=False, label="Speed (mph)")
|
||||
|
||||
inversions_range = NumberRangeField(
|
||||
min_val=0, max_val=20, step=1, required=False, label="Number of Inversions"
|
||||
)
|
||||
inversions_range = NumberRangeField(min_val=0, max_val=20, step=1, required=False, label="Number of Inversions")
|
||||
|
||||
track_material = forms.MultipleChoiceField(
|
||||
choices=[], # Will be populated in __init__
|
||||
@@ -379,17 +357,13 @@ class RollerCoasterForm(BaseFilterForm):
|
||||
coaster_type = forms.MultipleChoiceField(
|
||||
choices=[], # Will be populated in __init__
|
||||
required=False,
|
||||
widget=forms.CheckboxSelectMultiple(
|
||||
attrs={"class": "grid grid-cols-2 gap-2 max-h-48 overflow-y-auto"}
|
||||
),
|
||||
widget=forms.CheckboxSelectMultiple(attrs={"class": "grid grid-cols-2 gap-2 max-h-48 overflow-y-auto"}),
|
||||
)
|
||||
|
||||
propulsion_system = forms.MultipleChoiceField(
|
||||
choices=[], # Will be populated in __init__
|
||||
required=False,
|
||||
widget=forms.CheckboxSelectMultiple(
|
||||
attrs={"class": "space-y-2 max-h-48 overflow-y-auto"}
|
||||
),
|
||||
widget=forms.CheckboxSelectMultiple(attrs={"class": "space-y-2 max-h-48 overflow-y-auto"}),
|
||||
)
|
||||
|
||||
|
||||
@@ -408,8 +382,8 @@ class CompanyForm(BaseFilterForm):
|
||||
role_choices = rides_roles + parks_roles
|
||||
|
||||
# Update field choices dynamically
|
||||
self.fields['manufacturer_roles'].choices = role_choices
|
||||
self.fields['designer_roles'].choices = role_choices
|
||||
self.fields["manufacturer_roles"].choices = role_choices
|
||||
self.fields["designer_roles"].choices = role_choices
|
||||
|
||||
manufacturer_roles = forms.MultipleChoiceField(
|
||||
choices=[], # Will be populated in __init__
|
||||
@@ -423,9 +397,7 @@ class CompanyForm(BaseFilterForm):
|
||||
widget=forms.CheckboxSelectMultiple(attrs={"class": "space-y-2"}),
|
||||
)
|
||||
|
||||
founded_date_range = DateRangeField(
|
||||
required=False, label="Company Founded Date Range"
|
||||
)
|
||||
founded_date_range = DateRangeField(required=False, label="Company Founded Date Range")
|
||||
|
||||
|
||||
class SortingForm(BaseFilterForm):
|
||||
@@ -452,7 +424,7 @@ class SortingForm(BaseFilterForm):
|
||||
("capacity_desc", "Capacity (Highest)"),
|
||||
]
|
||||
|
||||
self.fields['sort_by'].choices = sort_choices
|
||||
self.fields["sort_by"].choices = sort_choices
|
||||
|
||||
sort_by = forms.ChoiceField(
|
||||
choices=[], # Will be populated in __init__
|
||||
@@ -578,8 +550,7 @@ class MasterFilterForm(BaseFilterForm):
|
||||
{
|
||||
"field": field_name,
|
||||
"value": value,
|
||||
"label": self.fields[field_name].label
|
||||
or field_name.replace("_", " ").title(),
|
||||
"label": self.fields[field_name].label or field_name.replace("_", " ").title(),
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user