diff options
author | Philip Sargent <philip.sargent@gmail.com> | 2023-03-28 19:08:05 +0100 |
---|---|---|
committer | Philip Sargent <philip.sargent@gmail.com> | 2023-03-28 19:08:05 +0100 |
commit | 5738da8566cefc54df0cfba83a6bcdc89520c92a (patch) | |
tree | b67afeefd9776ef169bda52e386bae193d65da05 /core/models/caves.py | |
parent | bbc13c4eb9a426f483aac48a97e76a1a1b08f053 (diff) | |
download | troggle-5738da8566cefc54df0cfba83a6bcdc89520c92a.tar.gz troggle-5738da8566cefc54df0cfba83a6bcdc89520c92a.tar.bz2 troggle-5738da8566cefc54df0cfba83a6bcdc89520c92a.zip |
cached_slug str now a .slug field & pending fixed
Diffstat (limited to 'core/models/caves.py')
-rw-r--r-- | core/models/caves.py | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/core/models/caves.py b/core/models/caves.py index fc3e80f..4737c82 100644 --- a/core/models/caves.py +++ b/core/models/caves.py @@ -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 = [] |