summaryrefslogtreecommitdiffstats
path: root/core/models/caves.py
diff options
context:
space:
mode:
authorPhilip Sargent <philip.sargent@gmail.com>2023-03-28 19:26:37 +0100
committerPhilip Sargent <philip.sargent@gmail.com>2023-03-28 19:26:37 +0100
commit9a28e93ac605b320a998707542ae409ba235cde1 (patch)
tree5b74feabe8a4f54632bfe9e9b3abfcc6360e2ec7 /core/models/caves.py
parent5738da8566cefc54df0cfba83a6bcdc89520c92a (diff)
downloadtroggle-9a28e93ac605b320a998707542ae409ba235cde1.tar.gz
troggle-9a28e93ac605b320a998707542ae409ba235cde1.tar.bz2
troggle-9a28e93ac605b320a998707542ae409ba235cde1.zip
EntranceSlug removed from data model.
Diffstat (limited to 'core/models/caves.py')
-rw-r--r--core/models/caves.py36
1 files changed, 9 insertions, 27 deletions
diff --git a/core/models/caves.py b/core/models/caves.py
index 4737c82..8d94086 100644
--- a/core/models/caves.py
+++ b/core/models/caves.py
@@ -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):