2
0
mirror of https://expo.survex.com/repositories/troggle/.git synced 2024-11-22 07:11:52 +00:00

create core/models/ directroy

This commit is contained in:
Philip Sargent 2021-04-13 00:43:57 +01:00
parent 304bbd230a
commit 5b3b0e67e9
19 changed files with 25 additions and 84 deletions

View File

@ -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

View File

@ -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

View File

@ -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 }

View File

@ -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'</p><p style="float: left;"><b>QMs found:</b>')
# for QM in LogbookEntry.instance.QMs_found.all():
# res.append(QM.wiki_link())
# res.append(r'</p><p style="float: left;"><b>QMs ticked off:</b>')
# for QM in LogbookEntry.instance.QMs_ticked_off.all():
# res.append(QM.wiki_link())
# res.append(r'</p><p style="float: left; "><b>People</b>')
# for persontrip in LogbookEntry.instance.persontrip_set.all():
# res.append(persontrip.wiki_link())
# res.append(r'</p>')
# return string.join(res, r'<br />')
# 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):

0
core/models/__init__.py Normal file
View File

View File

@ -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)

View File

@ -90,11 +90,11 @@ def html_to_wiki(text, codec = "utf-8"):
lists = ""
#lists
while text:
mstar = re.match("^(.*?)<ul[^>]*>\s*<li[^>]*>(.*?)</li>(.*)$", text, re.DOTALL)
munstar = re.match("^(\s*)</ul>(.*)$", text, re.DOTALL)
mhash = re.match("^(.*?)<ol[^>]*>\s*<li[^>]*>(.*?)</li>(.*)$", text, re.DOTALL)
munhash = re.match("^(\s*)</ol>(.*)$", text, re.DOTALL)
mitem = re.match("^(\s*)<li[^>]*>(.*?)</li>(.*)$", text, re.DOTALL)
mstar = re.match(r"^(.*?)<ul[^>]*>\s*<li[^>]*>(.*?)</li>(.*)$", text, re.DOTALL)
munstar = re.match(r"^(\s*)</ul>(.*)$", text, re.DOTALL)
mhash = re.match(r"^(.*?)<ol[^>]*>\s*<li[^>]*>(.*?)</li>(.*)$", text, re.DOTALL)
munhash = re.match(r"^(\s*)</ol>(.*)$", text, re.DOTALL)
mitem = re.match(r"^(\s*)<li[^>]*>(.*?)</li>(.*)$", text, re.DOTALL)
ms = [len(m.groups()[0]) for m in [mstar, munstar, mhash, munhash, mitem] if m]
def min_(i, l):
try:

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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.

View File

@ -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

View File

@ -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