Skip to content

Commit

Permalink
adjust admin displays
Browse files Browse the repository at this point in the history
  • Loading branch information
durandom committed Nov 14, 2024
1 parent 011ec87 commit 08ff594
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 35 deletions.
66 changes: 42 additions & 24 deletions telemetry/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from .models import (
Car,
CarClass,
Coach,
Driver,
FastLap,
Expand All @@ -12,9 +13,9 @@
Landmark,
Lap,
ReferenceSegment,
Segment,
Session,
SessionType,
Segment,
SoundClip,
Track,
TrackGuide,
Expand Down Expand Up @@ -47,6 +48,7 @@ class FastLapSegmentAdmin(AdminChangeLinksMixin, admin.ModelAdmin):


class LapAdmin(AdminChangeLinksMixin, admin.ModelAdmin):
list_display = ["id", "get_driver", "valid", "completed", "number", "get_game", "track", "car", "time", "official_time"]
list_display = [
"id",
"get_driver",
Expand All @@ -71,7 +73,7 @@ class LapAdmin(AdminChangeLinksMixin, admin.ModelAdmin):
("car", RelatedDropdownFilter),
("track", RelatedDropdownFilter),
)
fields = ["number", "valid", "length", "time", "start", "end"]
fields = ["number", "valid", "completed", "length", "time", "official_time", "start", "end", "session", "track", "car", "fast_lap"]
changelist_links = ["session"]
change_links = ["session", "track", "car"]

Expand All @@ -91,7 +93,8 @@ class DriverAdmin(AdminChangeLinksMixin, admin.ModelAdmin):


class SessionAdmin(AdminChangeLinksMixin, admin.ModelAdmin):
list_display = ["session_id", "driver", "game", "session_type", "start", "end"]
list_display = ["session_id", "driver", "game", "track", "car", "session_type", "start"]
fields = ["session_id", "driver", "game", "track", "car", "session_type", "start", "end"]
changelist_links = ["laps"]


Expand All @@ -101,28 +104,27 @@ class TrackAdmin(AdminChangeLinksMixin, admin.ModelAdmin):


class CarAdmin(AdminChangeLinksMixin, admin.ModelAdmin):
list_display = ["name", "game"]
list_display = ["name", "game", "car_class"]
changelist_links = ["laps", "fast_laps"]


class CarClassAdmin(AdminChangeLinksMixin, admin.ModelAdmin):
list_display = ["name", "game"]


class GameAdmin(AdminChangeLinksMixin, admin.ModelAdmin):
list_display = ["name"]
changelist_links = ["tracks", "cars", "sessions"]


# class CoachInline(admin.TabularInline):
# model = Coach


class CoachAdmin(AdminChangeLinksMixin, admin.ModelAdmin):
list_display = ["driver", "mode", "created", "modified"]
fields = ["driver", "error", "status", "mode"]

# changelist_links = ["se"]
list_display = ["driver", "mode", "enabled", "status", "created", "modified"]
fields = ["driver", "error", "status", "mode", "enabled", "fast_lap"]


class LandmarkAdmin(AdminChangeLinksMixin, admin.ModelAdmin):
list_display = ["name", "kind", "start", "end", "created", "modified"]
list_display = ["name", "kind", "track", "start", "end"]
fields = ["name", "kind", "track", "start", "end", "is_overtaking_spot", "from_cc"]


class TrackGuideAdmin(AdminChangeLinksMixin, admin.ModelAdmin):
Expand All @@ -131,25 +133,41 @@ class TrackGuideAdmin(AdminChangeLinksMixin, admin.ModelAdmin):


class TrackGuideNoteAdmin(AdminChangeLinksMixin, admin.ModelAdmin):
list_display = ["segment", "priority", "ref_id", "ref_eval", "message", "eval", "notes"]
list_display = ["track_guide", "segment", "priority", "message"]
fields = ["track_guide", "landmark", "segment", "finish_at", "at", "priority", "ref_id", "ref_eval", "sort_key", "mode", "message", "eval", "notes", "score"]


class SegmentAdmin(AdminChangeLinksMixin, admin.ModelAdmin):
list_display = ["lap", "landmark"]
# fields = ["type", "history", "telemetry_features"]

class ReferenceSegmentAdmin(AdminChangeLinksMixin, admin.ModelAdmin):
list_display = ["lap", "landmark", "driver"]
# fields = ["type", "history", "telemetry_features"]
list_display = ["lap", "landmark", "kind", "braking_point", "apex", "gear"]
fields = [
"lap",
"landmark",
"kind",
"braking_point",
"lift_off_point",
"acceleration_point",
"brake_pressure",
"brake_application_rate",
"brake_release_rate",
"throttle_lift",
"throttle_application_rate",
"throttle_release_rate",
"apex",
"entry_speed",
"corner_speed",
"exit_speed",
"gear",
"coasting_time",
"launch_wheel_slip_time",
]


# class DriverAdmin(admin.ModelAdmin):
# model = Driver
# display = ('name')
# inlines = [CoachInline, ]
class ReferenceSegmentAdmin(AdminChangeLinksMixin, admin.ModelAdmin):
list_display = ["lap", "landmark", "driver", "track"]


admin.site.register(Car, CarAdmin)
admin.site.register(CarClass, CarClassAdmin)
admin.site.register(SessionType)
admin.site.register(Lap, LapAdmin)
admin.site.register(Track, TrackAdmin)
Expand Down
8 changes: 4 additions & 4 deletions telemetry/models/lap.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ class Lap(ExportModelOperationsMixin("lap"), DirtyFieldsMixin, TimeStampedModel)
car = models.ForeignKey("Car", on_delete=models.CASCADE, related_name="laps")
fast_lap = models.ForeignKey("FastLap", on_delete=models.CASCADE, related_name="laps", null=True)

class Meta:
ordering = [
"number",
]
# class Meta:
# ordering = [
# "number",
# ]

def __str__(self):
return f"{self.number}: {self.start.strftime('%H:%M:%S')} - {self.end.strftime('%H:%M:%S')} " + f"{self.time}s {self.length}m valid: {self.valid}"
Expand Down
7 changes: 0 additions & 7 deletions telemetry/pitcrew/persister_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,13 +133,6 @@ def clear_sessions(self, now):
if (now - session.end).seconds > max_session_age:
delete_sessions.append(topic)

# # Delete any lap marked for deletion
# for i in range(len(session.laps) - 1, -1, -1):
# lap = session.laps[i]
# if lap.get("delete", False):
# logging.debug(f"{topic}\n\t deleting lap {lap['number']}")
# del session.laps[i]

if len(delete_sessions) > 0:
logger.debug(f"Inactive sessions: {len(delete_sessions)}")
logger.debug(f"Active sessions: {len(self.sessions) - len(delete_sessions)}")
Expand Down

0 comments on commit 08ff594

Please sign in to comment.