forked from expo/troggle
create core/models/ directroy
This commit is contained in:
parent
304bbd230a
commit
5b3b0e67e9
@ -27,7 +27,7 @@ class SimpleTest(SimpleTestCase):
|
|||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
self.assertEqual(settings.EMAIL_BACKEND, 'django.core.mail.backends.locmem.EmailBackend')
|
self.assertEqual(settings.EMAIL_BACKEND, 'django.core.mail.backends.locmem.EmailBackend')
|
||||||
def test_import_TroggleModel(self):
|
def test_import_TroggleModel(self):
|
||||||
from troggle.core.models import TroggleModel
|
from troggle.core.models.troggle import TroggleModel
|
||||||
def test_import_Cave(self):
|
def test_import_Cave(self):
|
||||||
from troggle.core.models_caves import Cave
|
from troggle.core.models_caves import Cave
|
||||||
def test_import_parsers_surveys(self):
|
def test_import_parsers_surveys(self):
|
||||||
@ -36,7 +36,7 @@ class SimpleTest(SimpleTestCase):
|
|||||||
from functools import reduce
|
from functools import reduce
|
||||||
def test_import_parsers_survex(self):
|
def test_import_parsers_survex(self):
|
||||||
import troggle.settings as settings
|
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_caves as models_caves
|
||||||
import troggle.core.models_survex as models_survex
|
import troggle.core.models_survex as models_survex
|
||||||
from troggle.parsers.people import GetPersonExpeditionNameLookup
|
from troggle.parsers.people import GetPersonExpeditionNameLookup
|
||||||
@ -49,14 +49,14 @@ class SimpleTest(SimpleTestCase):
|
|||||||
def test_import_parsers_logbooks(self):
|
def test_import_parsers_logbooks(self):
|
||||||
from django.template.defaultfilters import slugify
|
from django.template.defaultfilters import slugify
|
||||||
from django.utils.timezone import get_current_timezone, make_aware
|
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 troggle.core.models_caves import Cave, LogbookEntry, PersonTrip
|
||||||
from parsers.people import GetPersonExpeditionNameLookup
|
from parsers.people import GetPersonExpeditionNameLookup
|
||||||
def test_import_core_views_caves(self):
|
def test_import_core_views_caves(self):
|
||||||
from django.http import HttpResponse, HttpResponseRedirect
|
from django.http import HttpResponse, HttpResponseRedirect
|
||||||
from django.shortcuts import get_object_or_404, render
|
from django.shortcuts import get_object_or_404, render
|
||||||
import troggle.core.views.expo
|
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.models_caves import CaveSlug, Cave, CaveAndEntrance, QM, EntranceSlug, Entrance, Area, SurvexStation
|
||||||
from troggle.core.forms import CaveForm, CaveAndEntranceFormSet, VersionControlCommentForm, EntranceForm, EntranceLetterForm
|
from troggle.core.forms import CaveForm, CaveAndEntranceFormSet, VersionControlCommentForm, EntranceForm, EntranceLetterForm
|
||||||
from troggle.core.views.login import login_required_if_public
|
from troggle.core.views.login import login_required_if_public
|
||||||
|
@ -5,7 +5,7 @@ from django.http import HttpResponse
|
|||||||
from django.core import serializers
|
from django.core import serializers
|
||||||
|
|
||||||
from troggle.core.views.other import downloadLogbook
|
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_caves import Cave, Area, Entrance, CaveAndEntrance, LogbookEntry, PersonTrip, QM
|
||||||
from troggle.core.models_survex import SurvexBlock, SurvexPersonRole, SurvexStation, ScansFolder, SingleScan
|
from troggle.core.models_survex import SurvexBlock, SurvexPersonRole, SurvexStation, ScansFolder, SingleScan
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from troggle.core.models import Expedition
|
from troggle.core.models.troggle import Expedition
|
||||||
|
|
||||||
def troggle_context(request):
|
def troggle_context(request):
|
||||||
return { 'settings':settings, 'Expedition':Expedition }
|
return { 'settings':settings, 'Expedition':Expedition }
|
@ -8,7 +8,7 @@ from django.contrib.admin.widgets import AdminDateWidget
|
|||||||
|
|
||||||
#from tinymce.widgets import TinyMCE
|
#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
|
from troggle.core.models_caves import Cave, LogbookEntry, QM, Entrance, CaveAndEntrance
|
||||||
|
|
||||||
class CaveForm(ModelForm):
|
class CaveForm(ModelForm):
|
||||||
@ -76,46 +76,6 @@ class EntranceLetterForm(ModelForm):
|
|||||||
model = CaveAndEntrance
|
model = CaveAndEntrance
|
||||||
exclude = ('cave', 'entrance')
|
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):
|
def getTripForm(expedition):
|
||||||
|
|
||||||
|
0
core/models/__init__.py
Normal file
0
core/models/__init__.py
Normal file
@ -20,9 +20,8 @@ from django.conf import settings
|
|||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
from django.template import Context, loader
|
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_survex import SurvexStation
|
||||||
from troggle.core.models import DataIssue
|
|
||||||
|
|
||||||
class Area(TroggleModel):
|
class Area(TroggleModel):
|
||||||
short_name = models.CharField(max_length=100)
|
short_name = models.CharField(max_length=100)
|
||||||
|
@ -90,11 +90,11 @@ def html_to_wiki(text, codec = "utf-8"):
|
|||||||
lists = ""
|
lists = ""
|
||||||
#lists
|
#lists
|
||||||
while text:
|
while text:
|
||||||
mstar = re.match("^(.*?)<ul[^>]*>\s*<li[^>]*>(.*?)</li>(.*)$", text, re.DOTALL)
|
mstar = re.match(r"^(.*?)<ul[^>]*>\s*<li[^>]*>(.*?)</li>(.*)$", text, re.DOTALL)
|
||||||
munstar = re.match("^(\s*)</ul>(.*)$", text, re.DOTALL)
|
munstar = re.match(r"^(\s*)</ul>(.*)$", text, re.DOTALL)
|
||||||
mhash = re.match("^(.*?)<ol[^>]*>\s*<li[^>]*>(.*?)</li>(.*)$", text, re.DOTALL)
|
mhash = re.match(r"^(.*?)<ol[^>]*>\s*<li[^>]*>(.*?)</li>(.*)$", text, re.DOTALL)
|
||||||
munhash = re.match("^(\s*)</ol>(.*)$", text, re.DOTALL)
|
munhash = re.match(r"^(\s*)</ol>(.*)$", text, re.DOTALL)
|
||||||
mitem = re.match("^(\s*)<li[^>]*>(.*?)</li>(.*)$", 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]
|
ms = [len(m.groups()[0]) for m in [mstar, munstar, mhash, munhash, mitem] if m]
|
||||||
def min_(i, l):
|
def min_(i, l):
|
||||||
try:
|
try:
|
||||||
|
@ -21,13 +21,11 @@ from django.conf import settings
|
|||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
from django.template import Context, loader
|
from django.template import Context, loader
|
||||||
|
|
||||||
#import troggle.core.models_survex
|
|
||||||
|
|
||||||
'''This file declares TROG a globally visible object for caches.
|
'''This file declares TROG a globally visible object for caches.
|
||||||
|
|
||||||
TROG is a dictionary holding gloablly visible indexes and cache functions.
|
TROG is a dictionary holding gloablly visible indexes and cache functions.
|
||||||
It is a Global Object, see https://python-patterns.guide/python/module-globals/
|
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
|
chaosmonkey(n) - used by survex import to regenerate some .3d files
|
||||||
save_carefully() - core function that saves troggle objects in the database
|
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")
|
logging.info(str(instance) + " existed in the database unchanged since last parse. It was overwritten by the current script. \n")
|
||||||
return (instance, created)
|
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
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ from django.core.exceptions import ObjectDoesNotExist, MultipleObjectsReturned
|
|||||||
import troggle.settings as settings
|
import troggle.settings as settings
|
||||||
#import troggle.core.models as models
|
#import troggle.core.models as models
|
||||||
from troggle.core.views import expo
|
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.models_caves import CaveSlug, Cave, CaveAndEntrance, QM, EntranceSlug, Entrance, Area, SurvexStation, GetCaveLookup
|
||||||
from troggle.core.forms import CaveForm, CaveAndEntranceFormSet, VersionControlCommentForm, EntranceForm, EntranceLetterForm
|
from troggle.core.forms import CaveForm, CaveAndEntranceFormSet, VersionControlCommentForm, EntranceForm, EntranceLetterForm
|
||||||
from .login import login_required_if_public
|
from .login import login_required_if_public
|
||||||
|
@ -14,7 +14,7 @@ from django.views.generic.list import ListView
|
|||||||
|
|
||||||
#import troggle.parsers.logbooks as logbookparsers
|
#import troggle.parsers.logbooks as logbookparsers
|
||||||
from troggle.core.forms import getTripForm # , get_name, PersonForm
|
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.utils import TROG
|
||||||
from troggle.core.models_caves import LogbookEntry, PersonTrip
|
from troggle.core.models_caves import LogbookEntry, PersonTrip
|
||||||
from troggle.core.models_survex import SurvexBlock
|
from troggle.core.models_survex import SurvexBlock
|
||||||
|
@ -9,7 +9,7 @@ from django.shortcuts import render
|
|||||||
from django.template import Context, loader
|
from django.template import Context, loader
|
||||||
|
|
||||||
import troggle.parsers.imports
|
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 troggle.core.models_caves import LogbookEntry, QM, Cave, PersonTrip
|
||||||
from .login import login_required_if_public
|
from .login import login_required_if_public
|
||||||
from troggle.core.forms import UploadFileForm
|
from troggle.core.forms import UploadFileForm
|
||||||
|
@ -11,7 +11,7 @@ from django.template.defaultfilters import slugify
|
|||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
#from django.views.generic.list import ListView
|
#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_caves import Cave, LogbookEntry
|
||||||
from troggle.core.models_survex import SurvexBlock
|
from troggle.core.models_survex import SurvexBlock
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ from django.core.exceptions import ObjectDoesNotExist, MultipleObjectsReturned
|
|||||||
|
|
||||||
import troggle.settings as settings
|
import troggle.settings as settings
|
||||||
import parsers.survex
|
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_survex import SurvexBlock, SurvexPersonRole, SurvexFile, SurvexDirectory
|
||||||
from troggle.core.models_caves import Cave, PersonTrip, LogbookEntry
|
from troggle.core.models_caves import Cave, PersonTrip, LogbookEntry
|
||||||
from troggle.parsers.people import GetPersonExpeditionNameLookup
|
from troggle.parsers.people import GetPersonExpeditionNameLookup
|
||||||
|
@ -33,7 +33,7 @@ except:
|
|||||||
raise
|
raise
|
||||||
print(" - Memory footprint after loading Django: {:.3f} MB".format(resource.getrusage(resource.RUSAGE_SELF)[2]/1024.0))
|
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
|
import troggle.core.models_survex
|
||||||
|
|
||||||
from django.core import management
|
from django.core import management
|
||||||
@ -43,7 +43,7 @@ from django.urls import reverse
|
|||||||
from django.contrib.auth.models import User
|
from django.contrib.auth.models import User
|
||||||
from django.db import transaction
|
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.core.models_caves import Cave, Entrance
|
||||||
from troggle.parsers.imports import import_caves, import_people, import_surveyscans, \
|
from troggle.parsers.imports import import_caves, import_people, import_surveyscans, \
|
||||||
import_logbooks, import_QMs, import_survex, import_loadpos, import_drawingsfiles
|
import_logbooks, import_QMs, import_survex, import_loadpos, import_drawingsfiles
|
||||||
|
@ -5,7 +5,7 @@ from datetime import date
|
|||||||
|
|
||||||
from django.conf import settings
|
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.models_caves import QM, Cave, LogbookEntry
|
||||||
from troggle.core.utils import save_carefully
|
from troggle.core.utils import save_carefully
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ import re
|
|||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.db import transaction
|
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
|
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 )
|
'''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.
|
and creating the various Cave, Entrance and necessary Area objects.
|
||||||
|
@ -10,7 +10,7 @@ from django.conf import settings
|
|||||||
from django.template.defaultfilters import slugify
|
from django.template.defaultfilters import slugify
|
||||||
from django.utils.timezone import get_current_timezone, make_aware
|
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.utils import TROG, save_carefully
|
||||||
from troggle.core.models_caves import Cave, LogbookEntry, PersonTrip, GetCaveLookup
|
from troggle.core.models_caves import Cave, LogbookEntry, PersonTrip, GetCaveLookup
|
||||||
from parsers.people import GetPersonExpeditionNameLookup
|
from parsers.people import GetPersonExpeditionNameLookup
|
||||||
|
@ -12,7 +12,7 @@ from functools import reduce
|
|||||||
|
|
||||||
import settings
|
import settings
|
||||||
from troggle.core.models_survex import SingleScan, ScansFolder, TunnelFile
|
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
|
from troggle.core.utils import save_carefully
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user