Improved time widget visualization
This commit is contained in:
@@ -12,13 +12,32 @@ from ..models.weekpref import WeekPreference
|
||||
|
||||
from datetime import date
|
||||
|
||||
class HourBuildingLegForm(forms.ModelForm):
|
||||
class HourBuildingLegFlightForm(forms.ModelForm):
|
||||
class Meta:
|
||||
model = HourBuildingLegFlight
|
||||
fields = "__all__"
|
||||
widgets = {
|
||||
"time": TimeDurationWidget(show_days=False,
|
||||
show_seconds=False)
|
||||
show_seconds=False,
|
||||
attrs={
|
||||
"style": (
|
||||
"margin-right:5px; margin-left:5px; width:40px; min:0; max:5"
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
class HourBuildingLegStopForm(forms.ModelForm):
|
||||
class Meta:
|
||||
model = HourBuildingLegStop
|
||||
fields = "__all__"
|
||||
widgets = {
|
||||
"time": TimeDurationWidget(show_days=False,
|
||||
show_seconds=False,
|
||||
attrs={
|
||||
"style": (
|
||||
"margin-right:5px; margin-left:5px; width:40px;"
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
# Register your models here.
|
||||
@@ -26,36 +45,20 @@ class HourBuildingLegBaseInLine(nested_admin.NestedStackedPolymorphicInline):
|
||||
model = HourBuildingLegBase
|
||||
fk_name = "hb"
|
||||
verbose_name_plural = "Hour Building Legs"
|
||||
|
||||
def get_inline_title(self, obj):
|
||||
return "PIPPO"
|
||||
|
||||
class HourBuildingLegFlightInLine(nested_admin.NestedStackedPolymorphicInline.Child):
|
||||
model = HourBuildingLegFlight
|
||||
form = HourBuildingLegForm
|
||||
form = HourBuildingLegFlightForm
|
||||
fk_name = "hourbuildinglegbase_ptr"
|
||||
fields = ("departure", "time", "destination", "pax", )
|
||||
hide_title = True
|
||||
|
||||
def get_inline_title(self, obj: HourBuildingLegFlight | None = None) -> str:
|
||||
if obj:
|
||||
return f"Flight Leg:"
|
||||
else:
|
||||
return f"New Flight Leg"
|
||||
|
||||
class HourBuildingLegStopInLine(nested_admin.NestedStackedPolymorphicInline.Child):
|
||||
model = HourBuildingLegStop
|
||||
form = HourBuildingLegFlightForm
|
||||
fk_name = "hourbuildinglegbase_ptr"
|
||||
fields = ("time", "refuel", )
|
||||
|
||||
hide_title = True
|
||||
|
||||
def get_inline_title(self, obj: HourBuildingLegStop | None = None) -> str:
|
||||
if obj:
|
||||
return f"Stop at:"
|
||||
else:
|
||||
return f"New Stop"
|
||||
|
||||
child_inlines = (HourBuildingLegFlightInLine, HourBuildingLegStopInLine, )
|
||||
|
||||
# If user is a student deny edit permission for week past the current one
|
||||
|
||||
Reference in New Issue
Block a user