diff --git a/core/TESTS/tests.py b/core/TESTS/tests.py index f5645be..610149e 100644 --- a/core/TESTS/tests.py +++ b/core/TESTS/tests.py @@ -61,16 +61,16 @@ class SimpleTest(SimpleTestCase): 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_caves import CaveSlug, Cave, CaveAndEntrance, QM, EntranceSlug, Entrance, Area, SurvexStation from troggle.core.forms import CaveForm, CaveAndEntranceFormSet, VersionControlCommentForm, EntranceForm, EntranceLetterForm from troggle.helper import login_required_if_public from django.contrib.auth.decorators import login_required from django.conf import settings - def test_import_parses_mix(self): + def test_import_parsers_mix(self): from troggle.parsers.logbooks import GetCaveLookup import troggle.settings - #import troggle.expopages.models import troggle.logbooksdump import troggle.parsers.caves import troggle.parsers.people diff --git a/core/management/commands/reset_db.py b/core/management/commands/reset_db.py index c7cfd7a..83cc97b 100644 --- a/core/management/commands/reset_db.py +++ b/core/management/commands/reset_db.py @@ -8,7 +8,6 @@ from django.core.management.base import BaseCommand, CommandError from django.contrib.auth.models import User from troggle.core.models import Cave, Entrance -import troggle.expopages.models import settings diff --git a/core/view_surveys.py b/core/view_surveys.py index dcec1c2..2742229 100644 --- a/core/view_surveys.py +++ b/core/view_surveys.py @@ -9,7 +9,7 @@ from django.shortcuts import render from django.http import HttpResponse, Http404 from troggle.core.models_survex import ScansFolder, SingleScan, SurvexBlock, TunnelFile -from troggle.expopages import views as flatviews +from .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, @@ -30,8 +30,8 @@ def surveyscansingle(request, path, file): ''' scansfolder = ScansFolder.objects.get(walletname=urlunquote(path)) # need to check if inavlid query string and produce friendly error singlescan = SingleScan.objects.get(scansfolder=scansfolder, name=file) - # print(" - surveyscansingle {}:{}:{}:".format(path, file, flatviews.getmimetype(file))) - return HttpResponse(content=open(singlescan.ffile,"rb"), content_type=flatviews.getmimetype(file)) # any type of image + # print(" - surveyscansingle {}:{}:{}:".format(path, file, getmimetype(file))) + return HttpResponse(content=open(singlescan.ffile,"rb"), content_type=getmimetype(file)) # any type of image def surveyscansfolders(request): diff --git a/expopages/views.py b/core/views_expo.py similarity index 97% rename from expopages/views.py rename to core/views_expo.py index 0567229..d43cf19 100644 --- a/expopages/views.py +++ b/core/views_expo.py @@ -17,6 +17,11 @@ from troggle.core.models_caves import Cave import troggle.core.views_caves import troggle.settings as settings +'''Formerly a separate package 'flatpages' written by Martin Green 2011. +This was NOT django.contrib.flatpages which stores HTML in the database, so the name was chnaged to expopages. +Then it was incorporated into troggle directly, rather than being an unnecessary external package. +''' + def expofiles_redirect(request, path): '''This is used only when running as a test system without a local copy of /expofiles/ ''' diff --git a/databaseReset.py b/databaseReset.py index 34529a5..7b3b1be 100644 --- a/databaseReset.py +++ b/databaseReset.py @@ -33,7 +33,6 @@ except: raise print(" - Memory footprint after loading Django: {:.3f} MB".format(resource.getrusage(resource.RUSAGE_SELF)[2]/1024.0)) -import troggle.expopages.models import troggle.core.models import troggle.core.models_survex diff --git a/expopages/__init__.py b/expopages/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/expopages/admin.py b/expopages/admin.py deleted file mode 100644 index 91caa9c..0000000 --- a/expopages/admin.py +++ /dev/null @@ -1,5 +0,0 @@ -#from troggle.expopages.models import Redirect, EntranceRedirect -from django.contrib import admin - -# admin.site.register(Redirect) -# admin.site.register(EntranceRedirect) diff --git a/expopages/migrations/__init__.py b/expopages/migrations/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/expopages/models.py b/expopages/models.py deleted file mode 100644 index 08d769a..0000000 --- a/expopages/models.py +++ /dev/null @@ -1,12 +0,0 @@ -from django.db import models -from troggle.core.models_caves import Cave, Entrance - -# class Redirect(models.Model): - # originalURL = models.CharField(max_length=200, unique=True) - # newURL = models.CharField(max_length=200) - -# class EntranceRedirect(models.Model): - # originalURL = models.CharField(max_length=200) - # entrance = models.ForeignKey(Entrance,on_delete=models.CASCADE) - # def __str__(self): - # return self.entrance.slug diff --git a/logbooksdump.py b/logbooksdump.py index bdd1cb1..85edeca 100644 --- a/logbooksdump.py +++ b/logbooksdump.py @@ -19,7 +19,6 @@ from django.http import HttpResponse from django.urls import reverse from troggle.core.models_caves import Cave, Entrance -import troggle.expopages.models # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - def import_auto_logbooks(): diff --git a/settings.py b/settings.py index 5c8a8fb..8203147 100644 --- a/settings.py +++ b/settings.py @@ -123,7 +123,6 @@ INSTALLED_APPS = ( # 'django.contrib.staticfiles', # Using workarounds with expopages 'registration', # only for expo user. REPLACE using django.contrib.auth 'troggle.core', - 'troggle.expopages', # Written by Martin Green 2011. This is NOT django.contrib.flatpages which stores HTML in the database ) # See the recommended order of these in https://docs.djangoproject.com/en/2.2/ref/middleware/ diff --git a/urls.py b/urls.py index 85f5ad9..2297535 100644 --- a/urls.py +++ b/urls.py @@ -10,7 +10,7 @@ from troggle.core import views_other, views_caves, views_logbooks, views_statist from troggle.core.views_other import troggle404 from troggle.core.views_caves import ent, prospecting_image from troggle.core.views_statistics import pathsreport, stats -from expopages import views as flatviews +from troggle.core.views_expo import expofiles_redirect, expofilessingle, flatpage, editflatpage """This sets the actualurlpatterns[] and urlpatterns[] lists which django uses to resolve urls - in both directions as these are declarative. @@ -33,11 +33,11 @@ The API urls return TSV or JSON and are new in July 2020. if settings.EXPOFILESREMOTE: expofilesurls = [ - url(r'^/*(?P.*)$', flatviews.expofiles_redirect, name="expofiles_redirect"), # to expo.survex.com/expofiles + url(r'^/*(?P.*)$', expofiles_redirect, name="expofiles_redirect"), # to expo.survex.com/expofiles ] else: expofilesurls = [ - url(r'^/*(?P.*)$',flatviews.expofilessingle, name="single"), # local copy of EXPOFILES + url(r'^/*(?P.*)$', expofilessingle, name="single"), # local copy of EXPOFILES ] @@ -142,13 +142,13 @@ actualurlpatterns = [ # {'document_root': settings.PHOTOS_ROOT, 'show_indexes':True}), # url(r'^site_media/(?P.*)$', view_surveys.expofilessingle, name="single"), # MEDIA_ROOT: CSS and JS - url(r'^(site_media/.*)$', flatviews.flatpage, name="flatpage"), # MEDIA_ROOT: CSS and JS + url(r'^(site_media/.*)$', flatpage, name="flatpage"), # MEDIA_ROOT: CSS and JS # url(r'^static/(?P.*)$', view_surveys.expofilessingle, name="single"), # MEDIA_ROOT: CSS and JS - url(r'^(static/.*)$', flatviews.flatpage, name="flatpage"), # STATIC: CSS and JS + url(r'^(static/.*)$', flatpage, name="flatpage"), # STATIC: CSS and JS - url(r'^(.*)_edit$', flatviews.editflatpage, name="editflatpage"), - url(r'^(.*)$', flatviews.flatpage, name="flatpage"), # CATCHALL assumed relative to EXPOWEB, some expofiles getting here.. + url(r'^(.*)_edit$', editflatpage, name="editflatpage"), + url(r'^(.*)$', flatpage, name="flatpage"), # CATCHALL assumed relative to EXPOWEB, some expofiles getting here.. ] #Allow DIR_ROOT prefix to all urls