mirror of
https://github.com/pacnpal/thrillwiki_django_no_react.git
synced 2025-12-20 10:51:09 -05:00
72 lines
3.8 KiB
Python
72 lines
3.8 KiB
Python
from django import forms
|
|
from .models import Ride
|
|
|
|
class RideForm(forms.ModelForm):
|
|
class Meta:
|
|
model = Ride
|
|
fields = ['name', 'park_area', 'category', 'manufacturer', 'model_name', 'status',
|
|
'opening_date', 'closing_date', 'status_since', 'min_height_in', 'max_height_in',
|
|
'accessibility_options', 'capacity_per_hour', 'ride_duration_seconds', 'description']
|
|
widgets = {
|
|
'name': forms.TextInput(attrs={
|
|
'class': 'w-full border-gray-300 rounded-lg form-input dark:border-gray-600 dark:bg-gray-700 dark:text-white'
|
|
}),
|
|
'park_area': forms.Select(attrs={
|
|
'class': 'w-full border-gray-300 rounded-lg form-select dark:border-gray-600 dark:bg-gray-700 dark:text-white'
|
|
}),
|
|
'category': forms.Select(attrs={
|
|
'class': 'w-full border-gray-300 rounded-lg form-select dark:border-gray-600 dark:bg-gray-700 dark:text-white'
|
|
}),
|
|
'manufacturer': forms.Select(attrs={
|
|
'class': 'w-full border-gray-300 rounded-lg form-select dark:border-gray-600 dark:bg-gray-700 dark:text-white'
|
|
}),
|
|
'model_name': forms.TextInput(attrs={
|
|
'class': 'w-full border-gray-300 rounded-lg form-input dark:border-gray-600 dark:bg-gray-700 dark:text-white'
|
|
}),
|
|
'status': forms.Select(attrs={
|
|
'class': 'w-full border-gray-300 rounded-lg form-select dark:border-gray-600 dark:bg-gray-700 dark:text-white'
|
|
}),
|
|
'opening_date': forms.DateInput(attrs={
|
|
'type': 'date',
|
|
'class': 'w-full border-gray-300 rounded-lg form-input dark:border-gray-600 dark:bg-gray-700 dark:text-white'
|
|
}),
|
|
'closing_date': forms.DateInput(attrs={
|
|
'type': 'date',
|
|
'class': 'w-full border-gray-300 rounded-lg form-input dark:border-gray-600 dark:bg-gray-700 dark:text-white'
|
|
}),
|
|
'status_since': forms.DateInput(attrs={
|
|
'type': 'date',
|
|
'class': 'w-full border-gray-300 rounded-lg form-input dark:border-gray-600 dark:bg-gray-700 dark:text-white'
|
|
}),
|
|
'min_height_in': forms.NumberInput(attrs={
|
|
'class': 'w-full border-gray-300 rounded-lg form-input dark:border-gray-600 dark:bg-gray-700 dark:text-white',
|
|
'min': '0'
|
|
}),
|
|
'max_height_in': forms.NumberInput(attrs={
|
|
'class': 'w-full border-gray-300 rounded-lg form-input dark:border-gray-600 dark:bg-gray-700 dark:text-white',
|
|
'min': '0'
|
|
}),
|
|
'accessibility_options': forms.TextInput(attrs={
|
|
'class': 'w-full border-gray-300 rounded-lg form-input dark:border-gray-600 dark:bg-gray-700 dark:text-white'
|
|
}),
|
|
'capacity_per_hour': forms.NumberInput(attrs={
|
|
'class': 'w-full border-gray-300 rounded-lg form-input dark:border-gray-600 dark:bg-gray-700 dark:text-white',
|
|
'min': '0'
|
|
}),
|
|
'ride_duration_seconds': forms.NumberInput(attrs={
|
|
'class': 'w-full border-gray-300 rounded-lg form-input dark:border-gray-600 dark:bg-gray-700 dark:text-white',
|
|
'min': '0'
|
|
}),
|
|
'description': forms.Textarea(attrs={
|
|
'rows': 4,
|
|
'class': 'w-full border-gray-300 rounded-lg form-textarea dark:border-gray-600 dark:bg-gray-700 dark:text-white'
|
|
}),
|
|
}
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
park = kwargs.pop('park', None)
|
|
super().__init__(*args, **kwargs)
|
|
if park:
|
|
# Filter park_area choices to only show areas from the current park
|
|
self.fields['park_area'].queryset = park.areas.all()
|