Making entrances work for pending caves

This commit is contained in:
Philip Sargent
2021-04-26 02:10:45 +01:00
parent a656ada67a
commit 72fa8a5883
7 changed files with 143 additions and 61 deletions

View File

@@ -5,6 +5,7 @@ import re
import json
from subprocess import call
from collections import defaultdict
from pathlib import Path
from urllib.parse import urljoin
@@ -22,6 +23,20 @@ from django.template import Context, loader
from troggle.core.models.troggle import TroggleModel, Person, Expedition, DataIssue
from troggle.core.models.survex import SurvexStation
'''The model declarations for Areas, Caves and Entrances. Also LogBookENtry, QM, PersonTrip
'''
todo='''- Move utility function into utils.py
- Find out why we have separate objects CaveSlug and EntranceSlug and why
these are not just a single field on the Model. Do we ever need more
than one slug per cave or entrance? Surely that would break everything??
- Move PersonTrip to be with Person and Expedition elsewhere
- Restore constraint: unique_together = (("area", "kataster_number"), ("area", "unofficial_number"))
'''
class Area(TroggleModel):
short_name = models.CharField(max_length=100)
name = models.CharField(max_length=200, blank=True, null=True)
@@ -344,6 +359,9 @@ class Entrance(TroggleModel):
self.save()
return self.cached_primary_slug
def get_file_path(self):
return Path(settings.ENTRANCEDESCRIPTIONS, self.filename)
def writeDataFile(self):
try:
f = open(os.path.join(settings.ENTRANCEDESCRIPTIONS, self.filename), "w")