diff --git a/databaseReset.py b/databaseReset.py index 6a30f28..8ae0f15 100644 --- a/databaseReset.py +++ b/databaseReset.py @@ -1,12 +1,13 @@ -import sys +import json +import locale import os +import resource +import sys import time import timeit -import json -import resource -import locale import settings + """ Command-line utility for loading cave data files into troggle's database. The command line options select which combination of classes of data will be imported, @@ -34,20 +35,22 @@ except: raise print(f" - Memory footprint after loading Django: {resource.getrusage(resource.RUSAGE_SELF)[2] / 1024.0:.3f} MB") -from troggle.core.models.troggle import DataIssue -import troggle.core.models.survex - +from django.contrib.auth.models import User from django.core import management -from django.db import connection, close_old_connections, connections +from django.db import (close_old_connections, connection, connections, + transaction) from django.http import HttpResponse from django.urls import reverse -from django.contrib.auth.models import User -from django.db import transaction -from troggle.core.utils import get_process_memory +import troggle.core.models.survex from troggle.core.models.caves import Cave, Entrance -from troggle.parsers.imports import import_caves, import_people, import_surveyscans, import_ents, \ - import_logbooks, import_logbook, import_QMs, import_survex, import_loadpos, import_drawingsfiles +from troggle.core.models.troggle import DataIssue +from troggle.core.utils import get_process_memory +from troggle.parsers.imports import (import_caves, import_drawingsfiles, + import_ents, import_loadpos, + import_logbook, import_logbooks, + import_people, import_QMs, import_survex, + import_surveyscans) if os.geteuid() == 0: # This protects the server from having the wrong file permissions written on logs and caches diff --git a/manage.py b/manage.py index 37e5ee1..07bfdd7 100644 --- a/manage.py +++ b/manage.py @@ -1,6 +1,7 @@ #!/usr/bin/env python import os import sys + """This file is the route to run the standard Django utilities on the command line. These are the most useful for troggle: diff --git a/modelviz.py b/modelviz.py index 22919ca..a9a1f36 100644 --- a/modelviz.py +++ b/modelviz.py @@ -28,7 +28,8 @@ __contributors__ = [ "Justin Findlay ", ] -import getopt, sys +import getopt +import sys from django.core.management import setup_environ @@ -39,11 +40,11 @@ except ImportError: else: setup_environ(settings) -from django.template import Template, Context from django.db import models from django.db.models import get_models -from django.db.models.fields.related import \ - ForeignKey, OneToOneField, ManyToManyField +from django.db.models.fields.related import (ForeignKey, ManyToManyField, + OneToOneField) +from django.template import Context, Template try: from django.db.models.fields.generic import GenericRelation diff --git a/reset-django.py b/reset-django.py index 893aee1..c847fa4 100644 --- a/reset-django.py +++ b/reset-django.py @@ -1,7 +1,7 @@ -import os +import os import shutil - from pprint import pprint + """Cleans all django-created files and compiled python. Used by the pre-run.sh script which cleans and initialises everything before running: diff --git a/settings.py b/settings.py index 540a6b2..438b0b8 100644 --- a/settings.py +++ b/settings.py @@ -144,5 +144,5 @@ QM_PATTERN="\[\[\s*[Qq][Mm]:([ABC]?)(\d{4})-(\d*)-(\d*)\]\]" TEST_RUNNER = 'django.test.runner.DiscoverRunner' from localsettings import * -#localsettings needs to take precedence. Call it to override any existing vars. +#localsettings needs to take precedence. Call it to override any existing vars. diff --git a/urls.py b/urls.py index 7d486df..b1e2637 100644 --- a/urls.py +++ b/urls.py @@ -1,29 +1,34 @@ from django.conf import settings -from django.urls import include, re_path -from django.views.generic.base import RedirectView +from django.contrib import admin, auth +from django.urls import include, path, re_path, resolve, reverse +from django.views.generic.base import RedirectView from django.views.generic.edit import UpdateView from django.views.generic.list import ListView -from django.contrib import admin -from django.contrib import auth -from django.urls import path, reverse, resolve from troggle.core.views import statistics, survex -from troggle.core.views.scans import scansingle, allscans, cavewallets, walletslistyear, walletslistperson -from troggle.core.views.drawings import dwgallfiles, dwgfilesingle -from troggle.core.views.uploads import dwgupload, scanupload, photoupload -from troggle.core.views.other import troggle404, frontpage, todos, controlpanel, frontpage -from troggle.core.views.other import exportlogbook -from troggle.core.views.caves import ent, cavepage, caveindex, get_entrances, edit_cave, cave3d, caveEntrance, edit_entrance, caveQMs, qm -from troggle.core.views.logbooks import get_logbook_entries, logbookentry -from troggle.core.views.logbooks import notablepersons, person, get_people -from troggle.core.views.logbooks import expedition, personexpedition, Expeditions_tsvListView, Expeditions_jsonListView -from troggle.core.views.prospect import prospecting_image -from troggle.core.views.prospect import prospecting -from troggle.core.views.statistics import pathsreport, stats, dataissues -from troggle.core.views.expo import expofiles_redirect, expofilessingle, expopage, editexpopage, mediapage, map, mapfile -from troggle.core.views.survex import survexcaveslist, survexcavesingle, svx from troggle.core.views.auth import expologin, expologout +from troggle.core.views.caves import (cave3d, caveEntrance, caveindex, + cavepage, caveQMs, edit_cave, + edit_entrance, ent, get_entrances, qm) +from troggle.core.views.drawings import dwgallfiles, dwgfilesingle from troggle.core.views.editor_helpers import image_selector, new_image_form +from troggle.core.views.expo import (editexpopage, expofiles_redirect, + expofilessingle, expopage, map, mapfile, + mediapage) +from troggle.core.views.logbooks import (Expeditions_jsonListView, + Expeditions_tsvListView, expedition, + get_logbook_entries, get_people, + logbookentry, notablepersons, person, + personexpedition) +from troggle.core.views.other import (controlpanel, exportlogbook, frontpage, + todos, troggle404) +from troggle.core.views.prospect import prospecting, prospecting_image +from troggle.core.views.scans import (allscans, cavewallets, scansingle, + walletslistperson, walletslistyear) +from troggle.core.views.statistics import dataissues, pathsreport, stats +from troggle.core.views.survex import survexcavesingle, survexcaveslist, svx +from troggle.core.views.uploads import dwgupload, photoupload, scanupload + """This sets the actualurlpatterns[] and urlpatterns[] lists which django uses to resolve urls - in both directions as these are declarative. diff --git a/wsgi.py b/wsgi.py index 86da323..be477b3 100644 --- a/wsgi.py +++ b/wsgi.py @@ -8,7 +8,9 @@ https://docs.djangoproject.com/en/1.11/howto/deployment/wsgi/ """ import os + os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings") from django.core.wsgi import get_wsgi_application + application = get_wsgi_application()