mirror of
https://github.com/pacnpal/thrillwiki_django_no_react.git
synced 2025-12-20 16:51:07 -05:00
idk man
This commit is contained in:
@@ -66,17 +66,7 @@ class Park(models.Model):
|
||||
self.slug = slugify(self.name)
|
||||
|
||||
# Update the location field to combine country, region, and city
|
||||
location_parts = []
|
||||
if self.city:
|
||||
location_parts.append(self.city.name)
|
||||
if self.region:
|
||||
location_parts.append(self.region.name)
|
||||
if self.country:
|
||||
location_parts.append(self.country.name)
|
||||
|
||||
# Only update location if we have parts to combine
|
||||
if location_parts:
|
||||
self.location = ', '.join(location_parts)
|
||||
self.location = self.get_formatted_location()
|
||||
|
||||
super().save(*args, **kwargs)
|
||||
|
||||
@@ -93,15 +83,15 @@ class Park(models.Model):
|
||||
raise cls.DoesNotExist("No park found with this slug")
|
||||
|
||||
def get_formatted_location(self):
|
||||
"""Get a formatted location string combining city, region, and country"""
|
||||
location_parts = []
|
||||
if self.city:
|
||||
location_parts.append(self.city.name)
|
||||
if self.region:
|
||||
location_parts.append(self.region.name)
|
||||
if self.country:
|
||||
location_parts.append(self.country.name)
|
||||
return ', '.join(location_parts)
|
||||
"""Get a formatted location string: $COUNTRY, $REGION, $CITY"""
|
||||
location = self.country.name
|
||||
|
||||
if self.region and self.city:
|
||||
location += f", {self.region.name}, {self.city.name}"
|
||||
elif self.region:
|
||||
location += f", {self.region.name}"
|
||||
|
||||
return location
|
||||
|
||||
class ParkArea(models.Model):
|
||||
name = models.CharField(max_length=255)
|
||||
|
||||
Reference in New Issue
Block a user