|
|
|
@@ -51,7 +51,6 @@ class HourBuildingLegBaseInLine(nested_admin.NestedStackedPolymorphicInline):
|
|
|
|
form = HourBuildingLegFlightForm
|
|
|
|
form = HourBuildingLegFlightForm
|
|
|
|
fk_name = "hourbuildinglegbase_ptr"
|
|
|
|
fk_name = "hourbuildinglegbase_ptr"
|
|
|
|
fields = ("departure", "time", "destination", "pax", )
|
|
|
|
fields = ("departure", "time", "destination", "pax", )
|
|
|
|
hide_title = True
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class HourBuildingLegStopInLine(nested_admin.NestedStackedPolymorphicInline.Child):
|
|
|
|
class HourBuildingLegStopInLine(nested_admin.NestedStackedPolymorphicInline.Child):
|
|
|
|
model = HourBuildingLegStop
|
|
|
|
model = HourBuildingLegStop
|
|
|
|
@@ -65,7 +64,7 @@ class HourBuildingLegBaseInLine(nested_admin.NestedStackedPolymorphicInline):
|
|
|
|
def has_change_permission(self, request: HttpRequest, obj: HourBuilding | None = None):
|
|
|
|
def has_change_permission(self, request: HttpRequest, obj: HourBuilding | None = None):
|
|
|
|
if hasattr(request.user, "student") and obj:
|
|
|
|
if hasattr(request.user, "student") and obj:
|
|
|
|
current_week = date.today().isocalendar().week
|
|
|
|
current_week = date.today().isocalendar().week
|
|
|
|
if not obj.DoesNotExist and current_week > obj.weekpref.week:
|
|
|
|
if current_week > obj.weekpref.week:
|
|
|
|
return False
|
|
|
|
return False
|
|
|
|
return True
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
|
|
@@ -85,3 +84,16 @@ class HourBuildingInLine(nested_admin.NestedTabularInline):
|
|
|
|
models.TextField: {"widget": Textarea(attrs={"rows":4, "cols":35})},
|
|
|
|
models.TextField: {"widget": Textarea(attrs={"rows":4, "cols":35})},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# If user is a student deny edit permission for week past the current one
|
|
|
|
|
|
|
|
def has_change_permission(self, request: HttpRequest, obj: WeekPreference | None = None):
|
|
|
|
|
|
|
|
if hasattr(request.user, 'student') and obj:
|
|
|
|
|
|
|
|
current_week: int = date.today().isocalendar().week
|
|
|
|
|
|
|
|
if current_week > obj.week:
|
|
|
|
|
|
|
|
return False
|
|
|
|
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def has_delete_permission(self, request: HttpRequest, obj: WeekPreference | None = None):
|
|
|
|
|
|
|
|
return self.has_change_permission(request=request, obj=obj)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def has_add_permission(self, request: HttpRequest, obj: WeekPreference | None = None):
|
|
|
|
|
|
|
|
return self.has_change_permission(request=request, obj=obj)
|
|
|
|
|