remove 'primary' concept from entrance slugs. tested.

This commit is contained in:
2023-03-28 17:08:55 +01:00
parent 6ca5d5bfa8
commit bbc13c4eb9
4 changed files with 15 additions and 22 deletions

View File

@@ -265,7 +265,7 @@ class EntranceSlug(models.Model):
"""
entrance = models.ForeignKey("Entrance", on_delete=models.CASCADE)
slug = models.SlugField(max_length=50, unique=True)
primary = models.BooleanField(default=False)
# primary = models.BooleanField(default=False)
class Entrance(TroggleModel):
@@ -284,7 +284,7 @@ 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_primary_slug = models.CharField(max_length=200, 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)
@@ -398,17 +398,12 @@ class Entrance(TroggleModel):
"""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_primary_slug:
primarySlugs = self.entranceslug_set.filter(primary=True)
if primarySlugs:
self.cached_primary_slug = primarySlugs[0].slug
if not self.cached_slug:
slugs = self.entranceslug_set.filter()
if slugs:
self.cached_slug = slugs[0].slug
self.save()
else:
slugs = self.entranceslug_set.filter()
if slugs:
self.cached_primary_slug = slugs[0].slug
self.save()
return self.cached_primary_slug
return self.cached_slug
def cavelist(self):
rs = []