summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/TESTS/test_imports.py3
-rw-r--r--core/models/caves.py16
-rw-r--r--core/utils.py57
-rw-r--r--core/views/survex.py1
4 files changed, 11 insertions, 66 deletions
diff --git a/core/TESTS/test_imports.py b/core/TESTS/test_imports.py
index 56a5e71..c8bb1b4 100644
--- a/core/TESTS/test_imports.py
+++ b/core/TESTS/test_imports.py
@@ -42,8 +42,7 @@ class SimpleTest(SimpleTestCase):
# from PIL import Image
from functools import reduce
- from troggle.core.utils import save_carefully
-
+
def test_import_parsers_survex(self):
import troggle.core.models.caves as models_caves
import troggle.core.models.survex as models_survex
diff --git a/core/models/caves.py b/core/models/caves.py
index 60ff8d1..ab8414b 100644
--- a/core/models/caves.py
+++ b/core/models/caves.py
@@ -32,7 +32,7 @@ todo = """
- Can we rewrite things to eliminate the CaveSlug and objects? Surely
foreign keys work fine ?!
-- Why do we have CaveAndEntrance objects ?
+- Why do we have CaveAndEntrance objects ? These do not need to be explcit for a many:many relationship these days
- move the aliases list from the code and put into an editable file
@@ -112,12 +112,12 @@ class Cave(TroggleModel):
def get_absolute_url(self):
# we do not use URL_ROOT any more.
- if self.kataster_number:
- pass
- elif self.unofficial_number:
- pass
- else:
- self.official_name.lower()
+ # if self.kataster_number:
+ # pass
+ # elif self.unofficial_number:
+ # pass
+ # else:
+ # self.official_name.lower()
return self.url # not good Django style? NEEDS actual URL
def url_parent(self):
@@ -199,6 +199,8 @@ class Cave(TroggleModel):
return res
def writeDataFile(self):
+ """Seems to be a duplicate of file_output() ?!
+ REFACTOR"""
filepath = os.path.join(settings.CAVEDESCRIPTIONS, self.filename)
t = loader.get_template("dataformat/cave.xml")
diff --git a/core/utils.py b/core/utils.py
index c62dedb..b46e341 100644
--- a/core/utils.py
+++ b/core/utils.py
@@ -159,8 +159,6 @@ def write_and_commit(files, message):
try:
with open(filepath, mode, **kwargs) as f:
print(f"WRITING {cwd}---{filename} ")
- # as the wsgi process www-data, we have group write-access but are not owner, so cannot chmod.
- # os.chmod(filepath, 0o664) # set file permissions to rw-rw-r--
f.write(content)
except PermissionError:
raise WriteAndCommitError(
@@ -278,61 +276,6 @@ def writetrogglefile(filepath, filecontent):
# not catching and re-raising any exceptions yet, inc. the stderr etc.,. We should do that.
-# def save_carefully(objectType, coUniqueAttribs={}, otherAttribs={}):
- # """Looks up instance using coUniqueAttribs and carries out the following:
- # -if instance does not exist in DB: add instance to DB, return (new instance, True)
- # -if instance exists in DB and was modified using Troggle: do nothing, return (existing instance, False)
- # -if instance exists in DB and was not modified using Troggle: overwrite instance, return (instance, False)
-
- # The checking is accomplished using Django's get_or_create and the new_since_parsing boolean field
- # defined in core.models.TroggleModel.
-
- # We are not using new_since_parsing - it is a fossil from Aaron Curtis's design in 2006. So it is always false.
-
- # NOTE: this takes twice as long as simply creating a new object with the given values.
-
- # As of Jan.2023 this function is not used anywhere in troggle.
-
- # """
- # try:
- # instance, created = objectType.objects.get_or_create(defaults=otherAttribs, **coUniqueAttribs)
- # except:
- # print(" !! - FAIL in SAVE CAREFULLY ===================", objectType)
- # print(" !! - -- objects.get_or_create()")
- # print(f" !! - coUniqueAttribs:{coUniqueAttribs}\n !! - otherAttribs:{otherAttribs}")
- # raise
- # if not created and not instance.new_since_parsing:
- # for k, v in list(
- # otherAttribs.items()
- # ): # overwrite the existing attributes from the logbook text (except date and title)
- # setattr(instance, k, v)
- # try:
- # instance.save()
- # except:
- # print(" !! - SAVE CAREFULLY ===================", objectType)
- # print(" !! - -- instance.save()")
- # print(f" !! - coUniqueAttribs:{coUniqueAttribs}\n !! - otherAttribs:{otherAttribs}")
- # raise
- # try:
- # str(instance)
- # except:
- # pass
- # if created:
- # logging.info(str(instance) + " was just added to the database for the first time. \n")
-
- # if not created and instance.new_since_parsing:
- # logging.info(
- # str(instance) + " has been modified using Troggle since parsing, so the current script left it as is. \n"
- # )
-
- # if not created and not instance.new_since_parsing:
- # logging.info(
- # " instance:<"
- # + str(instance)
- # + "> existed in the database unchanged since last parse. It have been overwritten."
- # )
- # return (instance, created)
-
"""The following is a Bard converted version of Radosts's MIT copyrighted Javascript on 2023-10-27
with hand-editing.
diff --git a/core/views/survex.py b/core/views/survex.py
index ab9882d..0437d12 100644
--- a/core/views/survex.py
+++ b/core/views/survex.py
@@ -648,6 +648,7 @@ def survexdir(request):
"""report on all the primary survex files, per cave and per directory
"""
caves = Cave.objects.all()
+
survexfiles = SurvexFile.objects.all().order_by("cave")
for f in survexfiles:
f.pathbad = True