mirror of
https://github.com/pacnpal/thrillwiki_django_no_react.git
synced 2025-12-30 08:07:01 -05:00
feat: Implement MFA authentication, add ride statistics model, and update various services, APIs, and tests across the application.
This commit is contained in:
@@ -325,10 +325,7 @@ class ParkAdmin(
|
||||
@admin.display(description="Avg Rating")
|
||||
def average_rating(self, obj):
|
||||
"""Display average park review rating."""
|
||||
if hasattr(obj, "_avg_rating"):
|
||||
rating = obj._avg_rating
|
||||
else:
|
||||
rating = obj.reviews.aggregate(avg=Avg("rating"))["avg"]
|
||||
rating = obj._avg_rating if hasattr(obj, "_avg_rating") else obj.reviews.aggregate(avg=Avg("rating"))["avg"]
|
||||
if rating:
|
||||
stars = "★" * int(rating) + "☆" * (5 - int(rating))
|
||||
return format_html('<span style="color: gold;">{}</span> {:.1f}', stars, rating)
|
||||
|
||||
Reference in New Issue
Block a user