2
0
mirror of https://expo.survex.com/repositories/troggle/.git synced 2025-12-15 12:37:10 +00:00

EntranceSlug removed from data model.

This commit is contained in:
2023-03-28 19:26:37 +01:00
parent 5738da8566
commit 9a28e93ac6
4 changed files with 33 additions and 60 deletions

View File

@@ -60,7 +60,9 @@ class Area(TroggleModel):
class CaveAndEntrance(models.Model):
"""CASCADE means that if the cave or the entrance is deleted, then this CaveAndEntrance
"""This class is ONLY used to create a FormSet for editing the cave and all its
entrances in one form.
CASCADE means that if the cave or the entrance is deleted, then this CaveAndEntrance
is deleted too
"""
cave = models.ForeignKey("Cave", on_delete=models.CASCADE)
@@ -156,8 +158,6 @@ class Cave(TroggleModel):
pass
else:
self.official_name.lower()
# return settings.URL_ROOT + '/cave/' + href + '/'
# return urljoin(settings.URL_ROOT, reverse('cave',kwargs={'cave_id':href,})) # WRONG. This produces /cave/161 and should be /1623/161
return Path(settings.URL_ROOT) / self.url # not good Django style.. NEEDS actual URL
def url_parent(self):
@@ -260,12 +260,12 @@ class Cave(TroggleModel):
return lowestareas[0]
class EntranceSlug(models.Model):
"""If the Entrance is deleted, then this EntranceSlug is deleted too
"""
entrance = models.ForeignKey("Entrance", on_delete=models.CASCADE)
slug = models.SlugField(max_length=50, unique=True)
# primary = models.BooleanField(default=False)
# class EntranceSlug(models.Model):
# """If the Entrance is deleted, then this EntranceSlug is deleted too
# """
# entrance = models.ForeignKey("Entrance", on_delete=models.CASCADE)
# slug = models.SlugField(max_length=50, unique=True)
# # primary = models.BooleanField(default=False)
class Entrance(TroggleModel):
@@ -385,27 +385,9 @@ class Entrance(TroggleModel):
return self.findability != "S" or not self.has_photo or self.marking != "T"
def get_absolute_url(self):
# ancestor_titles='/'.join([subcave.title for subcave in self.get_ancestors()])
# if ancestor_titles:
# res = '/'.join((self.get_root().cave.get_absolute_url(), ancestor_titles, self.title))
# else:
# res = '/'.jocavein((self.get_root().cave.get_absolute_url(), self.title))
# return res
res = "/".join((self.get_root().cave.get_absolute_url(), self.title))
return res
#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 = []
for e in CaveAndEntrance.objects.filter(entrance=self):