mirror of
https://expo.survex.com/repositories/troggle/.git
synced 2025-12-15 12:27:05 +00:00
cached_slug str now a .slug field & pending fixed
This commit is contained in:
@@ -284,7 +284,6 @@ class Entrance(TroggleModel):
|
||||
alt = models.TextField(blank=True, null=True)
|
||||
approach = models.TextField(blank=True, null=True)
|
||||
bearings = models.TextField(blank=True, null=True)
|
||||
cached_slug = models.CharField(max_length=200, blank=True, null=True)
|
||||
easting = models.TextField(blank=True, null=True)
|
||||
entrance_description = models.TextField(blank=True, null=True)
|
||||
exact_station = models.TextField(blank=True, null=True)
|
||||
@@ -304,6 +303,7 @@ class Entrance(TroggleModel):
|
||||
other_description = models.TextField(blank=True, null=True)
|
||||
other_station = models.TextField(blank=True, null=True)
|
||||
photo = models.TextField(blank=True, null=True)
|
||||
slug = models.SlugField(max_length=50, unique=True, default="default_slug_id")
|
||||
tag_station = models.TextField(blank=True, null=True)
|
||||
underground_description = models.TextField(blank=True, null=True)
|
||||
url = models.CharField(max_length=200, blank=True, null=True)
|
||||
@@ -312,7 +312,7 @@ class Entrance(TroggleModel):
|
||||
ordering = ["caveandentrance__entrance_letter"]
|
||||
|
||||
def __str__(self):
|
||||
return str(self.slug())
|
||||
return str(self.slug)
|
||||
|
||||
def exact_location(self):
|
||||
return SurvexStation.objects.lookup(self.exact_station)
|
||||
@@ -394,16 +394,17 @@ class Entrance(TroggleModel):
|
||||
res = "/".join((self.get_root().cave.get_absolute_url(), self.title))
|
||||
return res
|
||||
|
||||
def slug(self):
|
||||
"""Returns the first slug with primary=True that it can find,
|
||||
if there are none with primary=True, then it returns the first slug it finds
|
||||
"""
|
||||
if not self.cached_slug:
|
||||
slugs = self.entranceslug_set.filter()
|
||||
if slugs:
|
||||
self.cached_slug = slugs[0].slug
|
||||
self.save()
|
||||
return self.cached_slug
|
||||
#REPLACE this with a slug filed on the Entrance itself
|
||||
# def slug(self):
|
||||
# """Returns the first slug with primary=True that it can find,
|
||||
# if there are none with primary=True, then it returns the first slug it finds
|
||||
# """
|
||||
# if not self.cached_slug:
|
||||
# slugs = self.entranceslug_set.filter()
|
||||
# if slugs:
|
||||
# self.cached_slug = slugs[0].slug
|
||||
# self.save()
|
||||
# return self.cached_slug
|
||||
|
||||
def cavelist(self):
|
||||
rs = []
|
||||
|
||||
Reference in New Issue
Block a user