forked from expo/troggle
rename flatpages as expopages to reduce confusion
This commit is contained in:
parent
0f024b27f0
commit
cacae6a9cd
@ -70,7 +70,7 @@ class SimpleTest(SimpleTestCase):
|
||||
def test_import_parses_mix(self):
|
||||
from troggle.parsers.logbooks import GetCaveLookup
|
||||
import troggle.settings
|
||||
#import troggle.flatpages.models
|
||||
#import troggle.expopages.models
|
||||
import troggle.logbooksdump
|
||||
import troggle.parsers.caves
|
||||
import troggle.parsers.people
|
||||
|
@ -8,7 +8,7 @@ from django.core.management.base import BaseCommand, CommandError
|
||||
from django.contrib.auth.models import User
|
||||
|
||||
from troggle.core.models import Cave, Entrance
|
||||
import troggle.flatpages.models
|
||||
import troggle.expopages.models
|
||||
|
||||
import settings
|
||||
|
||||
|
@ -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.flatpages import views as flatviews
|
||||
from troggle.expopages import views as flatviews
|
||||
import parsers.surveys
|
||||
|
||||
'''Some of these views serve files as binary blobs, and simply set the mime type based on the file extension,
|
||||
|
@ -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.flatpages.models
|
||||
import troggle.expopages.models
|
||||
import troggle.core.models
|
||||
import troggle.core.models_survex
|
||||
|
||||
@ -97,16 +97,16 @@ def reinit_db():
|
||||
if django.db.connections.databases['default']['ENGINE'] == 'django.db.backends.sqlite3':
|
||||
with transaction.atomic():
|
||||
management.call_command('makemigrations','core', interactive=False)
|
||||
management.call_command('makemigrations','flatpages', interactive=False)
|
||||
management.call_command('makemigrations','expopages', interactive=False)
|
||||
management.call_command('migrate', interactive=False)
|
||||
management.call_command('migrate','core', interactive=False)
|
||||
management.call_command('migrate','flatpages', interactive=False)
|
||||
management.call_command('migrate','expopages', interactive=False)
|
||||
else:
|
||||
management.call_command('makemigrations','core', interactive=False)
|
||||
management.call_command('makemigrations','flatpages', interactive=False)
|
||||
management.call_command('makemigrations','expopages', interactive=False)
|
||||
management.call_command('migrate', interactive=False)
|
||||
management.call_command('migrate','core', interactive=False)
|
||||
management.call_command('migrate','flatpages', interactive=False)
|
||||
management.call_command('migrate','expopages', interactive=False)
|
||||
|
||||
|
||||
print(" - done migration on: " + settings.DATABASES['default']['NAME'])
|
||||
|
@ -1,4 +1,4 @@
|
||||
#from troggle.flatpages.models import Redirect, EntranceRedirect
|
||||
#from troggle.expopages.models import Redirect, EntranceRedirect
|
||||
from django.contrib import admin
|
||||
|
||||
# admin.site.register(Redirect)
|
@ -56,15 +56,15 @@ def flatpage(request, path):
|
||||
|
||||
This is a horrible mess and some code is redundant and unreachable because of urls.py setup
|
||||
'''
|
||||
# print(" - FLATPAGES delivering the file: {} as MIME type: {}".format(path,getmimetype(path)),flush=True)
|
||||
# print(" - EXPOPAGES delivering the file: {} as MIME type: {}".format(path,getmimetype(path)),flush=True)
|
||||
|
||||
if path.startswith("noinfo") and settings.PUBLIC_SITE and not request.user.is_authenticated():
|
||||
# print((" - FLATPAGES redirect to logon: flat path noinfo", path))
|
||||
# print((" - EXPOPAGES redirect to logon: flat path noinfo", path))
|
||||
return HttpResponseRedirect(urljoin(reverse("auth_login"),'?next={}'.format(request.path)))
|
||||
|
||||
expowebpath = Path(settings.EXPOWEB)
|
||||
if path.endswith("/") or path == "":
|
||||
# print(" - FLATPAGES the file: {} ENDSWITH ...".format(path))
|
||||
# print(" - EXPOPAGES the file: {} ENDSWITH ...".format(path))
|
||||
|
||||
try:
|
||||
o = open(os.path.normpath(expowebpath / path / "index.html"), "rb")
|
||||
@ -76,7 +76,7 @@ def flatpage(request, path):
|
||||
except IOError:
|
||||
return render(request, 'pagenotfound.html', {'path': path})
|
||||
else:
|
||||
# print(" - FLATPAGES the file: '{}' ...".format(path))
|
||||
# print(" - EXPOPAGES the file: '{}' ...".format(path))
|
||||
if path.startswith('site_media'):
|
||||
# print(" - MEDIA_ROOT: {} ...{}".format(settings.MEDIA_ROOT, path))
|
||||
path = path.replace("site_media", settings.MEDIA_ROOT)
|
||||
@ -89,12 +89,12 @@ def flatpage(request, path):
|
||||
# print(" - NO _ROOT: {} ...".format(expowebpath))
|
||||
filetobeopened = os.path.normpath(expowebpath / path)
|
||||
|
||||
# print(" - FLATPAGES full path : {} ...".format(filetobeopened))
|
||||
# print(" - EXPOPAGES full path : {} ...".format(filetobeopened))
|
||||
try:
|
||||
o = open(filetobeopened, "rb")
|
||||
#print(" - FLATPAGES full path no error: {} ...".format(filetobeopened))
|
||||
#print(" - EXPOPAGES full path no error: {} ...".format(filetobeopened))
|
||||
except IOError:
|
||||
#print(" - FLATPAGES ERROR: {} ...".format(filetobeopened))
|
||||
#print(" - EXPOPAGES ERROR: {} ...".format(filetobeopened))
|
||||
#o.close()
|
||||
return render(request, 'pagenotfound.html', {'path': path})
|
||||
|
||||
@ -108,7 +108,7 @@ def flatpage(request, path):
|
||||
if m:
|
||||
preheader, headerattrs, head, postheader, bodyattrs, body, postbody = m.groups()
|
||||
else:
|
||||
return HttpResponse(html + "HTML Parsing failure: Page could not be split into header and body: failed in flatpages.views.py")
|
||||
return HttpResponse(html + "HTML Parsing failure: Page could not be split into header and body: failed in expopages.views.py")
|
||||
m = re.search(rb"<title>(.*)</title>", head, re.DOTALL + re.IGNORECASE)
|
||||
if m:
|
||||
title, = m.groups()
|
||||
@ -134,7 +134,7 @@ def flatpage(request, path):
|
||||
return render(request, 'flatpage.html', {'editable': editable, 'path': path, 'title': title,
|
||||
'body': body, 'homepage': (path == "index.htm"), 'has_menu': has_menu})
|
||||
else:
|
||||
# print(" - FLATPAGES delivering the file: {} as MIME type: {}".format(path,getmimetype(path)))
|
||||
# print(" - EXPOPAGES delivering the file: {} as MIME type: {}".format(path,getmimetype(path)))
|
||||
return HttpResponse(content=open(filetobeopened, "rb"), content_type=getmimetype(path))
|
||||
#return HttpResponse(content=open(singlescan.ffile,"rb"), content_type=getmimetype(path))
|
||||
|
@ -19,7 +19,7 @@ from django.http import HttpResponse
|
||||
from django.urls import reverse
|
||||
|
||||
from troggle.core.models_caves import Cave, Entrance
|
||||
import troggle.flatpages.models
|
||||
import troggle.expopages.models
|
||||
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
def import_auto_logbooks():
|
||||
|
@ -120,10 +120,10 @@ INSTALLED_APPS = (
|
||||
'django.contrib.sessions',
|
||||
'django.contrib.messages',
|
||||
'django.contrib.admindocs',
|
||||
# 'django.contrib.staticfiles', # Using workarounds with flatpages
|
||||
# 'django.contrib.staticfiles', # Using workarounds with expopages
|
||||
'registration', # only for expo user. REPLACE using django.contrib.auth
|
||||
'troggle.core',
|
||||
'troggle.flatpages', # Written by Martin Green 2011. This is NOT django.contrib.flatpages which stores HTML in the database
|
||||
'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/
|
||||
|
4
urls.py
4
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 flatpages import views as flatviews
|
||||
from expopages import views as flatviews
|
||||
"""This sets the actualurlpatterns[] and urlpatterns[] lists which django uses
|
||||
to resolve urls - in both directions as these are declarative.
|
||||
|
||||
@ -83,7 +83,7 @@ actualurlpatterns = [
|
||||
|
||||
url(r'^cave/new/$', views_caves.edit_cave, name="newcave"),
|
||||
url(r'^cave/(?P<cave_id>[^/]+)/?$', views_caves.cave, name="cave"),
|
||||
url(r'^cave/(?P<cave_id>[^/]+)/?(?P<ent_letter>[^/])$', ent), # how can this work?
|
||||
url(r'^cave/(?P<cave_id>[^/]+)/?(?P<ent_letter>[^/])$', ent), # view_caves.ent
|
||||
url(r'^cave/(?P<slug>[^/]+)/edit/$', views_caves.edit_cave, name="edit_cave"),
|
||||
url(r'^cave/(?P<cave_id>[^/]+)/(?P<year>\d\d\d\d)-(?P<qm_id>\d*)(?P<grade>[ABCDX]?)?$', views_caves.qm, name="qm"),
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user