diff --git a/core/TESTS/test_imports.py b/core/TESTS/test_imports.py
index 46c590d..01e76c7 100644
--- a/core/TESTS/test_imports.py
+++ b/core/TESTS/test_imports.py
@@ -27,7 +27,7 @@ class SimpleTest(SimpleTestCase):
from django.conf import settings
self.assertEqual(settings.EMAIL_BACKEND, 'django.core.mail.backends.locmem.EmailBackend')
def test_import_TroggleModel(self):
- from troggle.core.models import TroggleModel
+ from troggle.core.models.troggle import TroggleModel
def test_import_Cave(self):
from troggle.core.models_caves import Cave
def test_import_parsers_surveys(self):
@@ -36,7 +36,7 @@ class SimpleTest(SimpleTestCase):
from functools import reduce
def test_import_parsers_survex(self):
import troggle.settings as settings
- import troggle.core.models as models
+ import troggle.core.models.troggle as models
import troggle.core.models_caves as models_caves
import troggle.core.models_survex as models_survex
from troggle.parsers.people import GetPersonExpeditionNameLookup
@@ -49,14 +49,14 @@ class SimpleTest(SimpleTestCase):
def test_import_parsers_logbooks(self):
from django.template.defaultfilters import slugify
from django.utils.timezone import get_current_timezone, make_aware
- from troggle.core.models import DataIssue, Expedition
+ from troggle.core.models.troggle import DataIssue, Expedition
from troggle.core.models_caves import Cave, LogbookEntry, PersonTrip
from parsers.people import GetPersonExpeditionNameLookup
def test_import_core_views_caves(self):
from django.http import HttpResponse, HttpResponseRedirect
from django.shortcuts import get_object_or_404, render
import troggle.core.views.expo
- from troggle.core.models import Expedition
+ from troggle.core.models.troggle import Expedition
from troggle.core.models_caves import CaveSlug, Cave, CaveAndEntrance, QM, EntranceSlug, Entrance, Area, SurvexStation
from troggle.core.forms import CaveForm, CaveAndEntranceFormSet, VersionControlCommentForm, EntranceForm, EntranceLetterForm
from troggle.core.views.login import login_required_if_public
diff --git a/core/admin.py b/core/admin.py
index 375bdc7..0a9015b 100644
--- a/core/admin.py
+++ b/core/admin.py
@@ -5,7 +5,7 @@ from django.http import HttpResponse
from django.core import serializers
from troggle.core.views.other import downloadLogbook
-from troggle.core.models import Person, PersonExpedition, Expedition, DataIssue
+from troggle.core.models.troggle import Person, PersonExpedition, Expedition, DataIssue
from troggle.core.models_caves import Cave, Area, Entrance, CaveAndEntrance, LogbookEntry, PersonTrip, QM
from troggle.core.models_survex import SurvexBlock, SurvexPersonRole, SurvexStation, ScansFolder, SingleScan
diff --git a/core/context.py b/core/context.py
index 6b3b928..908cd69 100644
--- a/core/context.py
+++ b/core/context.py
@@ -1,5 +1,5 @@
from django.conf import settings
-from troggle.core.models import Expedition
+from troggle.core.models.troggle import Expedition
def troggle_context(request):
return { 'settings':settings, 'Expedition':Expedition }
\ No newline at end of file
diff --git a/core/forms.py b/core/forms.py
index d3941b0..c7eb551 100644
--- a/core/forms.py
+++ b/core/forms.py
@@ -8,7 +8,7 @@ from django.contrib.admin.widgets import AdminDateWidget
#from tinymce.widgets import TinyMCE
-from troggle.core.models import Person, PersonExpedition, Expedition
+from troggle.core.models.troggle import Person, PersonExpedition, Expedition
from troggle.core.models_caves import Cave, LogbookEntry, QM, Entrance, CaveAndEntrance
class CaveForm(ModelForm):
@@ -76,46 +76,6 @@ class EntranceLetterForm(ModelForm):
model = CaveAndEntrance
exclude = ('cave', 'entrance')
-#This was all commneted out by Martin Green in 2012 !
-#class PersonForm(ModelForm):
-# class Meta:
-# model = Person
-
-#class LogbookEntryForm(ModelForm):
-# class Meta:
-# model = LogbookEntry#
-
-# def wikiLinkHints(LogbookEntry=None):
-# """
-# This function returns html-formatted paragraphs for each of the
-# wikilink types that are related to this logbookentry. Each paragraph
-# contains a list of all of the related wikilinks.
-#
-# Perhaps an admin javascript solution would be better.
-# """
-# res = ["Please use the following wikilinks, which are related to this logbook entry:"]
-#
-# res.append(r'
QMs found:')
-# for QM in LogbookEntry.instance.QMs_found.all():
-# res.append(QM.wiki_link())
-
-# res.append(r'
QMs ticked off:')
-# for QM in LogbookEntry.instance.QMs_ticked_off.all():
-# res.append(QM.wiki_link())
-
-# res.append(r'
People')
-# for persontrip in LogbookEntry.instance.persontrip_set.all():
-# res.append(persontrip.wiki_link())
-# res.append(r'
')
-
-# return string.join(res, r'
')
-
-# def __init__(self, *args, **kwargs):
-# super(LogbookEntryForm, self).__init__(*args, **kwargs)
-# self.fields['text'].help_text=self.wikiLinkHints()#
-
-#class CaveForm(forms.Form):
-# html = forms.CharField(widget=TinyMCE(attrs={'cols': 80, 'rows': 30}))
def getTripForm(expedition):
diff --git a/core/models/__init__.py b/core/models/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/core/models.py b/core/models/troggle.py
similarity index 100%
rename from core/models.py
rename to core/models/troggle.py
diff --git a/core/models_caves.py b/core/models_caves.py
index f28f3b6..b0ecb53 100644
--- a/core/models_caves.py
+++ b/core/models_caves.py
@@ -20,9 +20,8 @@ from django.conf import settings
from django.urls import reverse
from django.template import Context, loader
-from troggle.core.models import TroggleModel, Person, Expedition
+from troggle.core.models.troggle import TroggleModel, Person, Expedition, DataIssue
from troggle.core.models_survex import SurvexStation
-from troggle.core.models import DataIssue
class Area(TroggleModel):
short_name = models.CharField(max_length=100)
diff --git a/core/unused.py b/core/unused.py
index e26a212..e9943e7 100644
--- a/core/unused.py
+++ b/core/unused.py
@@ -90,11 +90,11 @@ def html_to_wiki(text, codec = "utf-8"):
lists = ""
#lists
while text:
- mstar = re.match("^(.*?)]*>\s*- ]*>(.*?)
(.*)$", text, re.DOTALL)
- munstar = re.match("^(\s*)
(.*)$", text, re.DOTALL)
- mhash = re.match("^(.*?)]*>\s*- ]*>(.*?)
(.*)$", text, re.DOTALL)
- munhash = re.match("^(\s*)
(.*)$", text, re.DOTALL)
- mitem = re.match("^(\s*)]*>(.*?)(.*)$", text, re.DOTALL)
+ mstar = re.match(r"^(.*?)]*>\s*- ]*>(.*?)
(.*)$", text, re.DOTALL)
+ munstar = re.match(r"^(\s*)
(.*)$", text, re.DOTALL)
+ mhash = re.match(r"^(.*?)]*>\s*- ]*>(.*?)
(.*)$", text, re.DOTALL)
+ munhash = re.match(r"^(\s*)
(.*)$", text, re.DOTALL)
+ mitem = re.match(r"^(\s*)]*>(.*?)(.*)$", text, re.DOTALL)
ms = [len(m.groups()[0]) for m in [mstar, munstar, mhash, munhash, mitem] if m]
def min_(i, l):
try:
diff --git a/core/utils.py b/core/utils.py
index 84a8191..b2a9249 100644
--- a/core/utils.py
+++ b/core/utils.py
@@ -21,13 +21,11 @@ from django.conf import settings
from django.urls import reverse
from django.template import Context, loader
-#import troggle.core.models_survex
-
'''This file declares TROG a globally visible object for caches.
TROG is a dictionary holding gloablly visible indexes and cache functions.
It is a Global Object, see https://python-patterns.guide/python/module-globals/
-troggle.models.TROG
+troggle.utils.TROG
chaosmonkey(n) - used by survex import to regenerate some .3d files
save_carefully() - core function that saves troggle objects in the database
@@ -102,22 +100,6 @@ def save_carefully(objectType, lookupAttribs={}, nonLookupAttribs={}):
logging.info(str(instance) + " existed in the database unchanged since last parse. It was overwritten by the current script. \n")
return (instance, created)
-# def get_related_by_wikilinks(wiki_text):
- # found=re.findall(settings.QM_PATTERN,wiki_text)
- # res=[]
- # for wikilink in found:
- # qmdict={'urlroot':settings.URL_ROOT,'cave':wikilink[2],'year':wikilink[1],'number':wikilink[3]}
- # try:
- # cave_slugs = models_caves.CaveSlug.objects.filter(cave__kataster_number = qmdict['cave'])
- # qm=QM.objects.get(found_by__cave_slug__in = cave_slugs,
- # found_by__date__year = qmdict['year'],
- # number = qmdict['number'])
- # res.append(qm)
- # except QM.DoesNotExist:
- # print(('fail on '+str(wikilink)))
-
- # return res
-
diff --git a/core/views/caves.py b/core/views/caves.py
index e3b114d..8c02ea2 100644
--- a/core/views/caves.py
+++ b/core/views/caves.py
@@ -17,7 +17,7 @@ from django.core.exceptions import ObjectDoesNotExist, MultipleObjectsReturned
import troggle.settings as settings
#import troggle.core.models as models
from troggle.core.views import expo
-from troggle.core.models import Expedition, DataIssue
+from troggle.core.models.troggle import Expedition, DataIssue
from troggle.core.models_caves import CaveSlug, Cave, CaveAndEntrance, QM, EntranceSlug, Entrance, Area, SurvexStation, GetCaveLookup
from troggle.core.forms import CaveForm, CaveAndEntranceFormSet, VersionControlCommentForm, EntranceForm, EntranceLetterForm
from .login import login_required_if_public
diff --git a/core/views/logbooks.py b/core/views/logbooks.py
index 1db2edc..f74c21f 100644
--- a/core/views/logbooks.py
+++ b/core/views/logbooks.py
@@ -14,7 +14,7 @@ from django.views.generic.list import ListView
#import troggle.parsers.logbooks as logbookparsers
from troggle.core.forms import getTripForm # , get_name, PersonForm
-from troggle.core.models import Expedition, Person, PersonExpedition
+from troggle.core.models.troggle import Expedition, Person, PersonExpedition
from troggle.core.utils import TROG
from troggle.core.models_caves import LogbookEntry, PersonTrip
from troggle.core.models_survex import SurvexBlock
diff --git a/core/views/other.py b/core/views/other.py
index d65f3e6..30b3093 100644
--- a/core/views/other.py
+++ b/core/views/other.py
@@ -9,7 +9,7 @@ from django.shortcuts import render
from django.template import Context, loader
import troggle.parsers.imports
-from troggle.core.models import Expedition, Person, PersonExpedition
+from troggle.core.models.troggle import Expedition, Person, PersonExpedition
from troggle.core.models_caves import LogbookEntry, QM, Cave, PersonTrip
from .login import login_required_if_public
from troggle.core.forms import UploadFileForm
diff --git a/core/views/statistics.py b/core/views/statistics.py
index ac1e7ac..9c45f9f 100644
--- a/core/views/statistics.py
+++ b/core/views/statistics.py
@@ -11,7 +11,7 @@ from django.template.defaultfilters import slugify
from django.utils import timezone
#from django.views.generic.list import ListView
-from troggle.core.models import Expedition, Person, PersonExpedition, DataIssue
+from troggle.core.models.troggle import Expedition, Person, PersonExpedition, DataIssue
from troggle.core.models_caves import Cave, LogbookEntry
from troggle.core.models_survex import SurvexBlock
diff --git a/core/views/survex.py b/core/views/survex.py
index 0818e0c..3aee5f8 100644
--- a/core/views/survex.py
+++ b/core/views/survex.py
@@ -14,7 +14,7 @@ from django.core.exceptions import ObjectDoesNotExist, MultipleObjectsReturned
import troggle.settings as settings
import parsers.survex
-from troggle.core.models import Expedition, Person, PersonExpedition
+from troggle.core.models.troggle import Expedition, Person, PersonExpedition
from troggle.core.models_survex import SurvexBlock, SurvexPersonRole, SurvexFile, SurvexDirectory
from troggle.core.models_caves import Cave, PersonTrip, LogbookEntry
from troggle.parsers.people import GetPersonExpeditionNameLookup
diff --git a/databaseReset.py b/databaseReset.py
index 9151a43..aec6922 100644
--- a/databaseReset.py
+++ b/databaseReset.py
@@ -33,7 +33,7 @@ except:
raise
print(" - Memory footprint after loading Django: {:.3f} MB".format(resource.getrusage(resource.RUSAGE_SELF)[2]/1024.0))
-import troggle.core.models
+from troggle.core.models import DataIssue
import troggle.core.models_survex
from django.core import management
@@ -43,7 +43,7 @@ from django.urls import reverse
from django.contrib.auth.models import User
from django.db import transaction
-from troggle.core.models import get_process_memory
+from troggle.core.utils import get_process_memory
from troggle.core.models_caves import Cave, Entrance
from troggle.parsers.imports import import_caves, import_people, import_surveyscans, \
import_logbooks, import_QMs, import_survex, import_loadpos, import_drawingsfiles
diff --git a/parsers/QMs.py b/parsers/QMs.py
index 7449a8a..2816c8a 100644
--- a/parsers/QMs.py
+++ b/parsers/QMs.py
@@ -5,7 +5,7 @@ from datetime import date
from django.conf import settings
-from troggle.core.models import DataIssue
+from troggle.core.models.troggle import DataIssue
from troggle.core.models_caves import QM, Cave, LogbookEntry
from troggle.core.utils import save_carefully
diff --git a/parsers/caves.py b/parsers/caves.py
index 533bf61..8ddc424 100644
--- a/parsers/caves.py
+++ b/parsers/caves.py
@@ -4,7 +4,7 @@ import re
from django.conf import settings
from django.db import transaction
-from troggle.core.models import DataIssue, get_process_memory
+from troggle.core.models.troggle import DataIssue
from troggle.core.models_caves import Area, Cave, Entrance, CaveSlug, EntranceSlug, CaveAndEntrance
'''Reads all the cave description data by parsing the xml files (stored as e.g. :EXPOWEB:/cave-data/1623-161.html )
and creating the various Cave, Entrance and necessary Area objects.
diff --git a/parsers/logbooks.py b/parsers/logbooks.py
index b6a326c..58e425b 100644
--- a/parsers/logbooks.py
+++ b/parsers/logbooks.py
@@ -10,7 +10,7 @@ from django.conf import settings
from django.template.defaultfilters import slugify
from django.utils.timezone import get_current_timezone, make_aware
-from troggle.core.models import DataIssue, Expedition
+from troggle.core.models.troggle import DataIssue, Expedition
from troggle.core.utils import TROG, save_carefully
from troggle.core.models_caves import Cave, LogbookEntry, PersonTrip, GetCaveLookup
from parsers.people import GetPersonExpeditionNameLookup
diff --git a/parsers/surveys.py b/parsers/surveys.py
index 3207194..c75bf7c 100644
--- a/parsers/surveys.py
+++ b/parsers/surveys.py
@@ -12,7 +12,7 @@ from functools import reduce
import settings
from troggle.core.models_survex import SingleScan, ScansFolder, TunnelFile
-from troggle.core.models import DataIssue
+from troggle.core.models.troggle import DataIssue
from troggle.core.utils import save_carefully