sort imports using isort. tested.

This commit is contained in:
Philip Sargent 2023-01-19 18:35:56 +00:00
parent 939d3970aa
commit be9fcc522a
26 changed files with 296 additions and 245 deletions

View File

@ -18,11 +18,12 @@ them.
https://docs.djangoproject.com/en/3.0/topics/testing/tools/
"""
import unittest
import re
import subprocess
import unittest
from django.test import Client, SimpleTestCase, TestCase
from django.test import TestCase, SimpleTestCase, Client
class SimpleTest(SimpleTestCase):
def test_test_setting(self):
@ -35,78 +36,93 @@ class SimpleTest(SimpleTestCase):
from troggle.core.models.caves import Cave
def test_import_parsers_surveys(self):
#from PIL import Image
from troggle.core.utils import save_carefully
from functools import reduce
from troggle.core.utils import save_carefully
def test_import_parsers_survex(self):
import troggle.settings as settings
import troggle.core.models.troggle as models
import troggle.core.models.survex as models_survex
import troggle.core.models.caves as models_caves
from troggle.parsers.people import GetPersonExpeditionNameLookup
import troggle.core.models.survex as models_survex
import troggle.core.models.troggle as models
import troggle.settings as settings
from troggle.core.views import (caves, drawings, other, scans,
statistics, survex, uploads)
from troggle.core.views.caves import cavepage, ent
from troggle.core.views.other import frontpage
from troggle.core.views.caves import ent, cavepage
from troggle.core.views import scans, drawings, other, caves, statistics, survex, uploads
from troggle.parsers.people import GetPersonExpeditionNameLookup
def test_import_views_uploads(self):
from troggle.core.views.uploads import dwgupload, scanupload
def test_import_parsers_QMs(self):
from troggle.core.models.caves import QM, Cave, LogbookEntry
def test_import_parsers_people(self):
from html import unescape
from unidecode import unidecode
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.troggle import DataIssue, Expedition
from troggle.core.models.caves import Cave, LogbookEntry, PersonTrip
from parsers.people import GetPersonExpeditionNameLookup
from troggle.core.models.caves import Cave, LogbookEntry, PersonTrip
from troggle.core.models.troggle import DataIssue, Expedition
def test_import_core_views_caves(self):
from django.conf import settings
from django.contrib.auth.decorators import login_required
from django.http import HttpResponse, HttpResponseRedirect
from django.shortcuts import get_object_or_404, render
import troggle.core.views.expo
from troggle.core.forms import (CaveAndEntranceFormSet, CaveForm,
EntranceForm, EntranceLetterForm)
from troggle.core.models.caves import (QM, Area, Cave, CaveAndEntrance,
CaveSlug, Entrance,
EntranceSlug, SurvexStation)
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, EntranceForm, EntranceLetterForm
from troggle.core.views.auth import login_required_if_public
from django.contrib.auth.decorators import login_required
from django.conf import settings
def test_import_parsers_mix(self):
from troggle.parsers.logbooks import GetCaveLookup
import troggle.settings
import troggle.parsers.caves
import troggle.parsers.people
import troggle.parsers.drawings
import troggle.parsers.scans
import troggle.parsers.logbooks
import troggle.parsers.people
import troggle.parsers.QMs
import troggle.parsers.scans
import troggle.parsers.survex
import troggle.settings
from troggle.parsers.logbooks import GetCaveLookup
def test_import_imports(self):
from django.core import management
from django.db import connection, close_old_connections, connections
from django.contrib.auth.models import User
from django.core import management
from django.db import close_old_connections, connection, connections
from django.http import HttpResponse
from django.urls import reverse
def test_import_urls(self):
from django.conf import settings
from django.conf.urls import url, include
from django.contrib import admin
from django.contrib import auth
from django.urls import reverse, resolve
from django.conf.urls import include, url
from django.contrib import admin, auth
from django.urls import resolve, reverse
from django.views.generic.base import RedirectView
from django.views.generic.edit import UpdateView
from django.views.generic.list import ListView
from troggle.core.views import other, caves, statistics, survex
from troggle.core.views import caves, other, statistics, survex
from troggle.core.views.auth import expologin, expologout
from troggle.core.views.caves import ent, cavepage
from troggle.core.views.expo import expofiles_redirect, expofilessingle, expopage, editexpopage, mediapage, map, mapfile
from troggle.core.views.logbooks import expedition, personexpedition, Expeditions_tsvListView, Expeditions_jsonListView
from troggle.core.views.logbooks import get_logbook_entries, logbookentry
from troggle.core.views.logbooks import notablepersons, person, get_people
from troggle.core.views.caves import cavepage, ent
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
from troggle.core.views.prospect import prospecting
from troggle.core.views.prospect import prospecting_image
from troggle.core.views.statistics import pathsreport, stats, dataissues
from troggle.core.views.survex import survexcaveslist, survexcavesingle, svx
from troggle.core.views.prospect import prospecting, prospecting_image
from troggle.core.views.statistics import (dataissues, pathsreport,
stats)
from troggle.core.views.survex import (survexcavesingle,
survexcaveslist, svx)
class SubprocessTest(TestCase):
@ -123,8 +139,8 @@ class SubprocessTest(TestCase):
def test_utf8(self):
'''Expects that utf8 is the default encoding when opening files
'''
import sys
import locale
import sys
self.assertTrue( sys.getdefaultencoding() == "utf-8", f'{sys.getdefaultencoding()} - UTF8 error in getdefaultencoding')
self.assertTrue( sys.getfilesystemencoding() == "utf-8", f'{sys.getfilesystemencoding()} - UTF8 error in getfilesystemencoding')
self.assertTrue( locale.getdefaultlocale()[1] == "UTF-8", f'{locale.getdefaultlocale()} - UTF8 error in locale.getdefaultlocale')
@ -148,6 +164,7 @@ class SubprocessTest(TestCase):
''' Expects clean git repos with no added files and no merge failures
'''
from pathlib import Path
import troggle.settings as settings
TROGGLE_PATH = Path(settings.REPOS_ROOT_PATH) / "troggle"
for cwd in [settings.SURVEX_DATA, settings.EXPOWEB, settings.DRAWINGS_DATA, TROGGLE_PATH]:
@ -179,6 +196,7 @@ class SubprocessTest(TestCase):
''' Expects no failures of survex files
'''
from pathlib import Path
import troggle.settings as settings
cwd = settings.SURVEX_DATA
for survey in ["1623.svx", "1626.svx"]:

View File

@ -18,28 +18,30 @@ $ python manage.py test cuy.club --parallel
Runs the tests in this file only
"""
import unittest
import re
from django.test import TestCase, SimpleTestCase, TransactionTestCase, Client
import unittest
from django.test import Client, SimpleTestCase, TestCase, TransactionTestCase
class ImportTest(TestCase):
def test_import_imports(self):
# Need to go through all modules and copy all imports here
ed to go through all modules and copy all imports here
from io import StringIO
from cuy.club.models import (Article, Event, Member, Webpage,
WebpageCategory)
from cuy.website.views.generic import PUBLIC_LOGIN
from django.conf import settings
from django.contrib.auth.decorators import login_required
from django.contrib.auth.models import User
from django.core import management
from django.db import connection, connections
from django.http import HttpResponse
from django.db.utils import IntegrityError
from django.http import HttpResponse, HttpResponseRedirect
from django.shortcuts import get_object_or_404, render
from django.template.defaultfilters import slugify
from django.utils.timezone import get_current_timezone, make_aware
from io import StringIO
from cuy.club.models import Member, Article, Event, WebpageCategory, Webpage
from cuy.website.views.generic import PUBLIC_LOGIN
from cuy.club.models import Member
from django.db.utils import IntegrityError
class SimpleTest(SimpleTestCase):
@ -110,9 +112,9 @@ class DataTests(TestCase ):
self.assertIsNotNone(None, "Failed to enforce 'UNIQUE constraint' on saving two Member objects with same user_id")
def test_article_invalid_date(self):
from cuy.club.models import Member, Article
from django.db.utils import IntegrityError
from cuy.club.models import Article, Member
from django.core.exceptions import ValidationError
from django.db.utils import IntegrityError
a = Article()
m = self.member
@ -126,9 +128,9 @@ class DataTests(TestCase ):
self.assertIsNotNone(t, "Exception is not the expected 'invalid format'")
def test_article_and_author_not_null(self):
from cuy.club.models import Member, Article
from django.db.utils import IntegrityError
from cuy.club.models import Article, Member
from django.core.exceptions import ValidationError
from django.db.utils import IntegrityError
a2 = Article()
a2.publish ="2021-02-17 17:25"
@ -143,9 +145,9 @@ class DataTests(TestCase ):
self.assertIsNotNone(None, "Exception is not the expected 'NOT NULL constraint failed' IntegrityError")
def test_article_and_author_ok(self):
from cuy.club.models import Member, Article
from django.db.utils import IntegrityError
from cuy.club.models import Article, Member
from django.core.exceptions import ValidationError
from django.db.utils import IntegrityError
m = self.member
a3 = Article()
@ -201,8 +203,8 @@ class FixturePageTests(TestCase):
def test_fix_admin_login_fail(self):
c = self.client
from django.contrib.auth.models import User
from cuy.club.models import Member
from django.contrib.auth.models import User
m = Member.objects.get(pk=9002)
u = User.objects.get(username='bingo')
@ -223,7 +225,7 @@ class ComplexLoginTests(TestCase):
'''These test the login and capabilities of logged-in users'''
def setUp(self):
'''setUp runs once for each test in this class'''
from cuy.club.models import Member, MEMBER_TYPES, AFFILIATION
from cuy.club.models import AFFILIATION, MEMBER_TYPES, Member
from django.contrib.auth.models import User
m = Member()
m.pk=8000
@ -344,6 +346,7 @@ class ComplexLoginTests(TestCase):
def test_committee_login(self):
from django.contrib.auth.models import User
# User must be associated with a Member for whom is_committee() is True
c = self.client # inherited from TestCase
u = self.user
@ -407,7 +410,7 @@ class DynamicPageTests(TestCase):
def test_full_yachts(self):
'''Creating a WebpageCategory and an index webpage creates a valid url
'''
from cuy.club.models import WebpageCategory, Webpage
from cuy.club.models import Webpage, WebpageCategory
wc = WebpageCategory()
wc.pk = 8000
wc.id = 8000

View File

@ -25,10 +25,11 @@ todo = '''ADD TESTS when we are redirecting /expofiles/ to a remote file-deliver
- Add test for running cavern to produce a .3d file
'''
import unittest
import re
import unittest
from http import HTTPStatus
from django.test import TestCase, SimpleTestCase, Client
from django.test import Client, SimpleTestCase, TestCase
#class SimplePageTest(unittest.TestCase):

View File

@ -2,11 +2,14 @@
Modified for Expo April 2021.
"""
import unittest
import re
from django.test import TestCase, SimpleTestCase, Client
import unittest
from django.test import Client, SimpleTestCase, TestCase
from troggle.core.models.caves import Area, Cave
from troggle.core.models.troggle import Expedition, Person, PersonExpedition
from troggle.core.models.caves import Cave, Area
class FixtureTests(TestCase):
'''These just hit the database.

View File

@ -5,17 +5,18 @@ Philip Sargent (Feb.2021)
Modified for Expo April 2021.
"""
import unittest
import re
import pathlib
import re
import subprocess
import unittest
from http import HTTPStatus
from django.test import TestCase, SimpleTestCase, TransactionTestCase, Client
from django.test import Client, SimpleTestCase, TestCase, TransactionTestCase
import troggle.settings as settings
from troggle.core.models.survex import Wallet
from troggle.core.models.troggle import Expedition
import troggle.settings as settings
class DataTests(TestCase ):
'''These check that the NULL and NON-UNIQUE constraints are working in the database '''

View File

@ -1,14 +1,18 @@
import django.forms as forms
from django.contrib import admin
from django.core import serializers
from django.forms import ModelForm
from django.http import HttpResponse
from django.core import serializers
from troggle.core.models.caves import (QM, Area, Cave, CaveAndEntrance,
Entrance, LogbookEntry, PersonTrip)
from troggle.core.models.survex import (DrawingFile, SingleScan, SurvexBlock,
SurvexDirectory, SurvexFile,
SurvexPersonRole, SurvexStation,
Wallet)
from troggle.core.models.troggle import (DataIssue, Expedition, Person,
PersonExpedition)
from troggle.core.views.other import exportlogbook
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, SurvexFile, SurvexPersonRole, SurvexStation, SurvexDirectory
from troggle.core.models.survex import Wallet, SingleScan, DrawingFile
'''This code significantly adds to the capabilities of the Django Management control panel for Troggle data.
In particular, it enables JSON export of any data with 'export_as_json'

View File

@ -1,4 +1,5 @@
from django.conf import settings
from troggle.core.models.troggle import Expedition
'''This is the only troggle-specific 'context processor' that troggle uses

View File

@ -2,16 +2,18 @@ import string
from datetime import date
import django.forms as forms
from django.contrib.admin.widgets import AdminDateWidget
from django.forms import ModelForm
from django.forms.models import modelformset_factory
from django.contrib.admin.widgets import AdminDateWidget
from troggle.core.models.caves import (QM, Cave, CaveAndEntrance, Entrance,
LogbookEntry)
from troggle.core.models.troggle import Expedition, Person, PersonExpedition
from troggle.core.views.editor_helpers import HTMLarea
#from tinymce.widgets import TinyMCE
from troggle.core.models.troggle import Person, PersonExpedition, Expedition
from troggle.core.models.caves import Cave, LogbookEntry, QM, Entrance, CaveAndEntrance
from troggle.core.views.editor_helpers import HTMLarea
'''These are all the class-based Forms used by troggle.
There are other, simpler, upload forms in view/uploads.py

View File

@ -1,10 +1,10 @@
import os
from optparse import make_option
from django.db import connection
from django.contrib.auth.models import User
from django.core import management
from django.core.management.base import BaseCommand, CommandError
from django.contrib.auth.models import User
from django.db import connection
import settings

View File

@ -1,6 +1,7 @@
from django.conf import settings
from django import http
from django.urls import reverse, resolve,Resolver404
from django.conf import settings
from django.urls import Resolver404, resolve, reverse
"""Non-standard django middleware is loaded from this file.
"""

View File

@ -1,33 +1,30 @@
import string
import os
import datetime
import re
import json
import subprocess
import operator
from datetime import datetime, timezone
import os
import re
import string
import subprocess
from collections import defaultdict
from datetime import datetime, timezone
from pathlib import Path
from urllib.parse import urljoin
import settings
from django.db import models
from django.core.files.storage import FileSystemStorage
from django.conf import settings
from django.contrib.auth.models import User
from django.contrib.contenttypes.models import ContentType
from django.db.models import Min, Max
from django.conf import settings
from django.urls import reverse
from django.template import Context, loader
from django.core.files.storage import FileSystemStorage
from django.db import models
from django.db.models import Max, Min
from django.shortcuts import render
from django.template import Context, loader
from django.urls import reverse
from troggle.core.models.troggle import TroggleModel, Person, Expedition, DataIssue
import settings
from troggle.core.models.survex import SurvexStation
from troggle.core.utils import writetrogglefile
from troggle.core.utils import TROG
from troggle.core.models.troggle import (DataIssue, Expedition, Person,
TroggleModel)
from troggle.core.utils import TROG, writetrogglefile
# Use the TROG global object to cache the cave lookup list. No good for multi-user..
Gcavelookup = TROG['caves']['gcavelookup']

View File

@ -1,14 +1,14 @@
import os
import re
import datetime
import json
import operator
import datetime
from urllib.parse import urljoin
from pathlib import Path
import os
import re
from functools import reduce
from pathlib import Path
from urllib.parse import urljoin
from django.db import models
from django.conf import settings
from django.db import models
from django.urls import reverse
# from troggle.core.models.troggle import DataIssue # circular import. Hmm
@ -215,7 +215,8 @@ class Wallet(models.Model):
waldata["date"] = thisdate.isoformat()
except:
message = f"! {str(self.walletname)} Date formatting failure {thisdate}. Failed to load from {jsonfile} JSON file"
from troggle.core.models.troggle import DataIssue
from troggle.core.models.troggle import \
DataIssue
DataIssue.objects.update_or_create(parser='scans', message=message, url=wurl)
except:
message = f"! {str(self.walletname)} Date format not ISO {datestr}. Failed to load from {jsonfile} JSON file"

View File

@ -1,26 +1,24 @@
import string
import os
import datetime
import os
import re
import resource
from subprocess import call
from urllib.parse import urljoin
import string
from decimal import Decimal, getcontext
from subprocess import call
from urllib.parse import urljoin
getcontext().prec=2 #use 2 significant figures for decimal calculations
import settings
from django.db import models
from django.conf import settings
from django.contrib import admin
from django.contrib.auth.models import User
from django.contrib.contenttypes.models import ContentType
from django.conf import settings
from django.urls import reverse
from django.template import Context, loader
from django.core.files.storage import FileSystemStorage
from django.db import models
from django.template import Context, loader
from django.urls import reverse
import settings
import troggle.core.models.survex
from troggle.core.utils import get_process_memory

View File

@ -1,27 +1,26 @@
import string
import os
import datetime
import logging
import os
import random
import re
import resource
import random
import logging
import string
import subprocess
from pathlib import Path
from urllib.parse import urljoin
from decimal import Decimal, getcontext
from pathlib import Path
from urllib.parse import urljoin
getcontext().prec=2 #use 2 significant figures for decimal calculations
import settings
from django.db import models
from django.conf import settings
from django.contrib import admin
from django.contrib.auth.models import User
from django.contrib.contenttypes.models import ContentType
from django.conf import settings
from django.urls import reverse
from django.db import models
from django.template import Context, loader
from django.urls import reverse
import settings
'''This file declares TROG a globally visible object for caches.

View File

@ -1,10 +1,11 @@
from builtins import str
from django.conf import settings
from django.shortcuts import render, redirect
from django.contrib.auth import authenticate, login, logout
from django.contrib.auth import authenticate
from django.contrib.auth import forms as auth_forms
from django.contrib.auth import login, logout
from django.contrib.auth.decorators import login_required
from django.shortcuts import redirect, render
from django.utils.http import is_safe_url
"""This enforces the login requirement for non-public pages using

View File

@ -1,25 +1,29 @@
import os
import string
import re
import settings
import urllib.parse
import string
import subprocess
import urllib.parse
from pathlib import Path
from django import forms
from django.conf import settings
from django.urls import reverse
from django.http import HttpResponse, HttpResponseRedirect, HttpResponseNotFound
from django.core.exceptions import MultipleObjectsReturned, ObjectDoesNotExist
from django.http import (HttpResponse, HttpResponseNotFound,
HttpResponseRedirect)
from django.shortcuts import get_object_or_404, render
from django.core.exceptions import ObjectDoesNotExist, MultipleObjectsReturned
from django.urls import NoReverseMatch
from django.urls import NoReverseMatch, reverse
import settings
import troggle.settings as settings
from troggle.core.forms import (CaveAndEntranceFormSet, CaveForm, EntranceForm,
EntranceLetterForm)
from troggle.core.models.caves import (QM, Area, Cave, CaveAndEntrance,
CaveSlug, Entrance, EntranceSlug,
GetCaveLookup, SurvexStation)
from troggle.core.models.troggle import DataIssue, Expedition
from troggle.core.utils import write_and_commit, writetrogglefile
from troggle.core.views import expo
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, EntranceForm, EntranceLetterForm
from troggle.core.utils import writetrogglefile, write_and_commit
from .auth import login_required_if_public
'''Manages the complex procedures to assemble a cave description out of the compnoents

View File

@ -1,14 +1,17 @@
import os, stat
import os
import re
import stat
from pathlib import Path
from urllib.parse import urljoin, unquote as urlunquote
from urllib.parse import unquote as urlunquote
from urllib.parse import urljoin
from django.conf import settings
from django.shortcuts import render
from django.http import HttpResponse
from django.shortcuts import render
from troggle.core.models.survex import DrawingFile
from troggle.core.views.expo import getmimetype
#import parsers.surveys
'''Some of these views serve files as binary blobs, and simply set the mime type based on the file extension,

View File

@ -1,18 +1,20 @@
from django.shortcuts import render, redirect
from django.http import HttpResponse, HttpResponseRedirect, Http404, JsonResponse
from django.urls import reverse, resolve
from django.template import Context, loader
import re, io
from PIL import Image
import io
import re
from pathlib import Path
import django.forms as forms
import troggle.settings as settings
from django.http import (Http404, HttpResponse, HttpResponseRedirect,
JsonResponse)
from django.shortcuts import redirect, render
from django.template import Context, loader
from django.urls import resolve, reverse
from django.views.decorators.csrf import ensure_csrf_cookie
from .auth import login_required_if_public
from PIL import Image
from troggle.core.utils import write_and_commit, WriteAndCommitError
import troggle.settings as settings
from troggle.core.utils import WriteAndCommitError, write_and_commit
from .auth import login_required_if_public
MAX_IMAGE_WIDTH = 1000
MAX_IMAGE_HEIGHT = 800

View File

@ -1,28 +1,26 @@
import os
import re
from sys import getfilesystemencoding as sys_getfilesystemencoding
from pathlib import Path
from urllib.parse import urljoin, unquote as urlunquote
from sys import getfilesystemencoding as sys_getfilesystemencoding
from urllib.parse import unquote as urlunquote
from urllib.parse import urljoin
from urllib.request import urlopen
from django.shortcuts import render, redirect
from django.http import HttpResponse, HttpResponseRedirect, Http404
from django.urls import reverse, resolve
from django.template import Context, loader
from django.views.decorators.csrf import ensure_csrf_cookie
from django.contrib import admin
import django.forms as forms
from django.contrib import admin
from django.http import Http404, HttpResponse, HttpResponseRedirect
from django.shortcuts import redirect, render
from django.template import Context, loader
from django.urls import resolve, reverse
from django.views.decorators.csrf import ensure_csrf_cookie
import troggle.core.views.caves
import troggle.settings as settings
from .auth import login_required_if_public
from troggle.core.models.caves import Cave
from troggle.core.utils import write_and_commit, WriteAndCommitError
from troggle.core.utils import WriteAndCommitError, write_and_commit
from troggle.core.views.editor_helpers import HTMLarea
from .auth import login_required_if_public
'''Formerly a separate package called 'flatpages' written by Martin Green 2011.
This was NOT django.contrib.flatpages which stores HTML in the database, so the name was changed to expopages.

View File

@ -1,27 +1,27 @@
import datetime
import time
import os.path
import re
import time
import django.db.models
from django.db.models import Min, Max
from django.urls import reverse
from django.db.models import Max, Min
from django.http import HttpResponse, HttpResponseRedirect
from django.shortcuts import render
from django.template import Context, loader
from django.template.defaultfilters import slugify
from django.urls import reverse
from django.utils import timezone
from django.views.generic.list import ListView
from troggle.core.models.troggle import Expedition, Person, PersonExpedition
from troggle.core.utils import TROG
import troggle.settings as settings
from troggle.core.models.caves import LogbookEntry, PersonTrip
from troggle.core.models.survex import SurvexBlock, Wallet
from .auth import login_required_if_public
from troggle.core.models.troggle import Expedition, Person, PersonExpedition
from troggle.core.utils import TROG
from troggle.parsers.logbooks import LoadLogbookForExpedition
from troggle.parsers.people import GetPersonExpeditionNameLookup
import troggle.settings as settings
from .auth import login_required_if_public
'''These views are for logbook items when they appear in an 'expedition' page
and for persons: their individual pages and their perseonexpedition pages.

View File

@ -1,23 +1,26 @@
import re, os
import os
import re
import subprocess
from pathlib import Path
from django import forms
from django.conf import settings
from django.urls import reverse
from django.core.files.storage import FileSystemStorage, default_storage
from django.db.models import Q
from django.http import HttpResponse, HttpResponseRedirect
from django.shortcuts import render
from django.template import Context, loader
from django.core.files.storage import FileSystemStorage, default_storage
from django.urls import reverse
from troggle.parsers.imports import import_caves, import_people, import_surveyscans
from troggle.parsers.imports import import_logbooks, import_QMs, import_drawingsfiles, import_survex
from troggle.core.models.caves import QM, Cave, LogbookEntry, PersonTrip
from troggle.core.models.survex import DrawingFile
# from databaseReset import reinit_db # don't do this. databaseRest runs code *at import time*
from troggle.core.models.troggle import Expedition, Person, PersonExpedition
from troggle.core.models.caves import LogbookEntry, QM, Cave, PersonTrip
from troggle.core.models.survex import DrawingFile
from troggle.parsers.imports import (import_caves, import_drawingsfiles,
import_logbooks, import_people,
import_QMs, import_survex,
import_surveyscans)
from .auth import login_required_if_public
'''Utility functions and code to serve the control panel and individual user's
@ -37,18 +40,18 @@ def todos(request, module):
'''produces todo text from module
We could automate this to find all those strings automatically
'''
from troggle.core.forms import todo as forms
from troggle.core.middleware import todo as middleware
from troggle.core.models.caves import todo as modelcaves
from troggle.core.TESTS.tests import todo as tests
from troggle.core.views.logbooks import todo as viewlogbooks
from troggle.core.views.survex import todo as viewsurvex
from troggle.core.views.caves import todo as viewcaves
from troggle.core.views.drawings import todo as viewdrawings
from troggle.core.views.logbooks import todo as viewlogbooks
from troggle.core.views.survex import todo as viewsurvex
from troggle.parsers.caves import todo as parserscaves
from troggle.parsers.logbooks import todo as parserslogbooks
from troggle.parsers.drawings import todo as parsersdrawings
from troggle.parsers.logbooks import todo as parserslogbooks
from troggle.parsers.survex import todo as parserssurvex
from troggle.core.models.caves import todo as modelcaves
from troggle.core.middleware import todo as middleware
from troggle.core.forms import todo as forms
tododict = {'views/other': todo,
'tests': tests,
'views/logbooks': viewlogbooks,

View File

@ -1,18 +1,21 @@
import os
import string
import re
import string
import urllib.parse
# from pathlib import Path
from django.http import HttpResponse
from django.shortcuts import render
# from django.core.exceptions import ObjectDoesNotExist, MultipleObjectsReturned
import troggle.settings as settings
from troggle.core.models.caves import Entrance, Area, SurvexStation, Cave
from troggle.core.models.caves import Area, Cave, Entrance, SurvexStation
from troggle.core.views.caves import caveKey
from troggle.parsers.survex import MapLocations
# from pathlib import Path
# from django.core.exceptions import ObjectDoesNotExist, MultipleObjectsReturned
''' Generates the prospecting guide document.
Also produces the overlay of points on top of a prospecting_image map - to be deleted.

View File

@ -1,20 +1,22 @@
import os, stat
import re
import datetime
import os
import re
import stat
from pathlib import Path
from urllib.parse import urljoin, unquote as urlunquote
from urllib.parse import unquote as urlunquote
from urllib.parse import urljoin
from urllib.request import urlopen
from django.conf import settings
from django.shortcuts import render
from django.http import HttpResponse
from django.db import transaction
from django.http import HttpResponse
from django.shortcuts import render
from troggle.core.models.survex import Wallet, SingleScan, SurvexBlock
from troggle.core.models.troggle import Person, Expedition
from troggle.core.models.troggle import DataIssue
from troggle.core.models.caves import GetCaveLookup
from troggle.core.models.survex import SingleScan, SurvexBlock, Wallet
from troggle.core.models.troggle import DataIssue, Expedition, Person
from troggle.core.views.expo import getmimetype
#from troggle.parsers.people import GetPersonExpeditionNameLookup
#import parsers.surveys

View File

@ -1,23 +1,27 @@
import datetime
import operator
import os.path
import re
import operator
from collections import OrderedDict
import django.db.models
from django.db.models import Min, Max
from django.db.models import Max, Min
from django.shortcuts import render
from django.template import Context, loader
from django.template.defaultfilters import slugify
from django.utils import timezone
#from django.views.generic.list import ListView
from troggle.core.models.troggle import Expedition, Person, PersonExpedition, DataIssue
from troggle.core.models.caves import Cave, LogbookEntry, Entrance
from troggle.core.models.survex import SurvexBlock, SurvexStation
from troggle.parsers.people import GetPersonExpeditionNameLookup, foreign_friends
import troggle.settings as settings
from troggle.core.models.caves import Cave, Entrance, LogbookEntry
from troggle.core.models.survex import SurvexBlock, SurvexStation
from troggle.core.models.troggle import (DataIssue, Expedition, Person,
PersonExpedition)
from troggle.parsers.people import (GetPersonExpeditionNameLookup,
foreign_friends)
#from django.views.generic.list import ListView
'''Very simple report pages summarizing data about the whole set of expeditions and of
the status of data inconsistencies

View File

@ -1,25 +1,25 @@
import re
import os
import datetime
import difflib
from pathlib import Path
import os
import re
import socket
from pathlib import Path
from django import forms
from django.http import HttpResponseRedirect, HttpResponse, Http404
from django.core.exceptions import MultipleObjectsReturned, ObjectDoesNotExist
from django.http import Http404, HttpResponse, HttpResponseRedirect
from django.shortcuts import render
from django.template.context_processors import csrf
from django.views.decorators.csrf import ensure_csrf_cookie
from django.core.exceptions import ObjectDoesNotExist, MultipleObjectsReturned
import troggle.settings as settings
import parsers.survex
import troggle.settings as settings
from troggle.core.models.caves import Cave, LogbookEntry, PersonTrip
from troggle.core.models.survex import (SurvexBlock, SurvexDirectory,
SurvexFile, SurvexPersonRole)
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.core.utils import WriteAndCommitError, only_commit
from troggle.parsers.people import GetPersonExpeditionNameLookup
from troggle.core.utils import only_commit, WriteAndCommitError
'''Everything that views survexfiles
but also displays data on a cave or caves when there is ambiguity

View File

@ -1,41 +1,43 @@
import re, os, socket
import subprocess
import json
import settings
import urllib
import operator
import datetime
from pathlib import Path
import json
import operator
import os
import re
import socket
import subprocess
import urllib
from functools import reduce
from pathlib import Path
from urllib.parse import unquote
from django import forms
from django.conf import settings
from django.urls import reverse
from django.core.exceptions import MultipleObjectsReturned, ObjectDoesNotExist
from django.core.files.storage import FileSystemStorage, default_storage
from django.db.models import Q
from django.http import HttpResponse, HttpResponseRedirect
from django.shortcuts import render
from django.template import Context, loader
from django.core.files.storage import FileSystemStorage, default_storage
from django.core.exceptions import ObjectDoesNotExist, MultipleObjectsReturned
from django.urls import reverse
#from troggle import settings
from troggle.parsers.imports import import_caves, import_people, import_surveyscans
from troggle.parsers.imports import import_logbooks, import_QMs, import_drawingsfiles, import_survex
from troggle.parsers.scans import contentsjson
import settings
from troggle.core.models.caves import QM, Cave, LogbookEntry, PersonTrip
from troggle.core.models.survex import (DrawingFile, SurvexBlock, SurvexFile,
SurvexPersonRole, Wallet)
# from databaseReset import reinit_db # don't do this. databaseRest runs code *at import time*
from troggle.core.models.troggle import DataIssue
from troggle.core.models.troggle import Expedition, Person, PersonExpedition
from troggle.core.models.caves import LogbookEntry, QM, Cave, PersonTrip
from troggle.core.models.survex import DrawingFile, Wallet, SurvexBlock, SurvexFile, SurvexPersonRole
from troggle.core.views.scans import oldwallet, caveifywallet
from troggle.core.models.troggle import (DataIssue, Expedition, Person,
PersonExpedition)
from troggle.core.views.caves import getCave
from troggle.core.views.scans import caveifywallet, oldwallet
#from troggle import settings
from troggle.parsers.imports import (import_caves, import_drawingsfiles,
import_logbooks, import_people,
import_QMs, import_survex,
import_surveyscans)
from troggle.parsers.scans import contentsjson
from .auth import login_required_if_public
#from django.views.decorators.csrf import ensure_csrf_cookie, csrf_exempt
'''File upload 'views'