2
0
mirror of https://expo.survex.com/repositories/troggle/.git synced 2024-11-21 23:01:52 +00:00

removed jgtfileupload

This commit is contained in:
Philip Sargent 2020-06-16 16:48:19 +01:00
parent 9f5e779b5e
commit 8fc0ba136f
5 changed files with 14 additions and 227 deletions

View File

@ -8,33 +8,6 @@ from troggle.core.models_survex import SurvexScansFolder, SurvexScanSingle, Surv
import parsers.surveys
import urllib.request, urllib.parse, urllib.error
# inlined use of fileabstraction into here
# def fa_listdir(*path):
# try:
# strippedpath = [p for p in path if p]
# root = os.path.join(settings.FILES, *strippedpath )
# l = ""
# #l = root + "\n"
# isdir = os.path.isdir(root) #This seems to be required for os.path.isdir to work...
# #l += str(isdir) + "\n"
# for p in os.listdir(root):
# if os.path.isdir(os.path.join(root, p)):
# l += p + "/\n"
# elif os.path.isfile(os.path.join(root, p)):
# l += p + "\n"
# #Ignore non-files and non-directories
# return l
# except:
# if strippedpath:
# c = reduce(urljoin, strippedpath)
# else:
# c = ""
# c = c.replace("#", "%23")
# print(("FILE: ", settings.FILES + "listdir/" + c))
# return urllib.request.urlopen(settings.FILES + "listdir/" + c).read()
def fa_readFile(*path):
try:
f = open(os.path.join(settings.FILES, *path))
@ -51,13 +24,6 @@ def getMimeType(extension):
print("unknown file type")
return "text/plain"
# def listdir(request, path):
# #try:
# return HttpResponse(fa_listdir(path), content_type="text/plain")
# #except:
# # raise Http404
def upload(request, path):
pass
@ -68,68 +34,6 @@ def download(request, path):
#except:
# raise Http404
#
# julian's quick hack for something that works
# could signal directories by ending with /, and forward cases where it's missing
#
extmimetypes = {".txt": "text/plain",
".html": "text/html",
".png": "image/png",
".jpg": "image/jpeg",
".jpeg": "image/jpeg",
}
# dead
def jgtfile(request, f):
fp = os.path.join(settings.SURVEYS, f)
# could also surf through SURVEX_DATA
# directory listing
if os.path.isdir(fp):
listdirfiles = [ ]
listdirdirs = [ ]
for lf in sorted(os.listdir(fp)):
hpath = os.path.join(f, lf) # not absolute path
if lf[0] == "." or lf[-1] == "~":
continue
hpath = hpath.replace("\\", "/") # for windows users
href = hpath.replace("#", "%23") # '#' in file name annoyance
flf = os.path.join(fp, lf)
if os.path.isdir(flf):
nfiles = len([sf for sf in os.listdir(flf) if sf[0] != "."])
listdirdirs.append((href, hpath + "/", nfiles))
else:
listdirfiles.append((href, hpath, os.path.getsize(flf)))
upperdirs = [ ]
lf = f
while lf:
hpath = lf.replace("\\", "/") # for windows users
if hpath[-1] != "/":
hpath += "/"
href = hpath.replace("#", "%23")
lf = os.path.split(lf)[0]
upperdirs.append((href, hpath))
upperdirs.append(("", "/"))
return render_to_response('listdir.html', {'file':f, 'listdirfiles':listdirfiles, 'listdirdirs':listdirdirs, 'upperdirs':upperdirs, 'settings': settings})
# flat output of file when loaded
if os.path.isfile(fp):
ext = os.path.splitext(fp)[1].lower()
mimetype = extmimetypes.get(ext, "text/plain")
fin = open(fp)
ftext = fin.read()
fin.close()
return HttpResponse(ftext, content_type=mimetype)
return HttpResponse("unknown file::%s::" % f, content_type = "text/plain")
def UniqueFile(fname):
while True:
if not os.path.exists(fname):
@ -170,31 +74,6 @@ def SaveImageInDir(name, imgdir, project, fdata, bbinary):
res = os.path.join(imgdir, name)
return res.replace("\\", "/")
# do we want to consider saving project/field rather than field/project
def jgtuploadfile(request):
filesuploaded = [ ]
project, user, password, tunnelversion = request.POST["tunnelproject"], request.POST["tunneluser"], request.POST["tunnelpassword"], request.POST["tunnelversion"]
print((project, user, tunnelversion))
for uploadedfile in list(request.FILES.values()):
if uploadedfile.field_name in ["tileimage", "backgroundimage"] and \
uploadedfile.content_type in ["image/png", "image/jpeg"]:
fname = user + "_" + re.sub("[\\\\/]", "-", uploadedfile.name) # very escaped \
print(fname)
fileuploaded = SaveImageInDir(fname, uploadedfile.field_name, project, uploadedfile, True)
filesuploaded.append(settings.URL_ROOT + "/jgtfile/" + fileuploaded)
if uploadedfile.field_name in ["sketch"] and \
uploadedfile.content_type in ["text/plain"]:
fname = user + "_" + re.sub("[\\\\/]", "-", uploadedfile.name) # very escaped \
print(fname)
fileuploaded = SaveImageInDir(fname, uploadedfile.field_name, project, uploadedfile, False)
filesuploaded.append(settings.URL_ROOT + "/jgtfile/" + fileuploaded)
#print "FF", request.FILES
#print ("FFF", request.FILES.values())
message = ""
print("gothere")
return render_to_response('fileupload.html', {'message':message, 'filesuploaded':filesuploaded, 'settings': settings})
def surveyscansfolder(request, path):
#print [ s.walletname for s in SurvexScansFolder.objects.all() ]
survexscansfolder = SurvexScansFolder.objects.get(walletname=urllib.parse.unquote(path))

View File

@ -20,7 +20,6 @@ print(" - settings on loading databaseReset.py")
from troggle.core.models_caves import Cave, Entrance
import troggle.flatpages.models
import troggle.logbooksdump
#import troggle.parsers.imports
from troggle.parsers.imports import import_caves, import_people, import_surveyscans, \
import_logbooks, import_QMs, import_survex, import_survexpos, import_tunnelfiles
@ -417,8 +416,6 @@ if __name__ == "__main__":
else:
runlabel=None
jq = JobQueue(runlabel)
if len(sys.argv)==1:

View File

@ -1,59 +0,0 @@
{% extends "base.html" %}
{% load wiki_markup %}
{% block title %}Cambridge Expeditions to Austria{% endblock %}
{% block content %}
<h2>The unfinished front page</h2>
<ul>
<li><b>About {{totallogbookentries}} logbook entries have been loaded</b></li>
<li><b><a href="{% url "personindex" %}">List of People</a></b></li>
<li><b><a href="{% url "caveindex" %}">List of Caves</a></b></li>
<li><a href="{% url "jgtfile" aaaa %}">JGT list of files</a> (temporary simple file list and tunnel use)</li>
<li><a href="{% url "survey" %}">Survey files</a></li>
<li><a href="{% url "svx" all %}">Survex directory</a></li>
<li><a href="{% url "expedition" 2008 %}">Expedition 2008</a></li>
<li><a href="{% url "expedition" 2007 %}">Expedition 2007</a></li>
<li><a href="{% url "expedition" 1992 %}">Expedition 1992</a> (earliest parsed)</li>
</ul>
<h2>Further work</h2>
<p>Julian's work:
<p>parse 1976-1991 logbooks; (esp top 161)</p>
<p>detect T/U on log entries; </p>
<p>name matching and spelling in survex files; </p>
<p>Improve logbook wikihtml text</p>
<p>Other work:</p>
<p>surf through the tunnel sketches and images</p>
<p>bugs with all.svx block (double dot)
<p>render bitmap view of every survex block as a thumbnail</p>
<p>upload tunnel images and tunnel sketches</p>
<p>where are the subcaves; </p>
<p>cave section entrance match for logbook entries</p>
<p>simplify the survex parsing code (if necessary); </p>
<p>wiki survex stop linegap between comment lins</p>
<p>links between logbooks and survex blocks to cave things; </p>
<p>mini-tree of survexblocks; </p>
<p>connect sketches to caves to survey blocks and render thumbnailwise; </p>
<p>all images to start appearing in pages; and so on</p>
<h3>{{message}}</h3>
<form action="" method="GET">
<input type="submit" name="reloadexpos" value="Reload Expos">
<input type="submit" name="reloadsurvex" value="Reload Survex">
</form>
<ul id="expeditionlist">
{% for expedition in expeditions %}
<li>
<a href="{% url "expedition" expedition.year %}">{{expedition.name}}</a>
- <b>{{expedition.logbookentry_set.count}}</b> logbook entries
</li>
{% endfor %}
</ul>
{% endblock %}

View File

@ -1,22 +0,0 @@
<h2>List file :{{file}}:</h2>
<h3>Files</h3>
<ul>
{% for lf in listdirfiles %}
<li><a href="{% url "jgtfile" lf.0 %}">{{lf.1}}</a> ({{lf.2}} bytes)</li>
{% endfor %}
</ul>
<h3>Upperdirectories</h3>
<ul>
{% for lf in upperdirs %}
<li><a href="{% url "jgtfile" lf.0 %}">{{lf.1}}</a></li>
{% endfor %}
</ul>
<h3>Subdirectories</h3>
<ul>
{% for lf in listdirdirs %}
<li><a href="{% url "jgtfile" lf.0 %}">{{lf.1}}</a> ({{lf.2}} files)</li>
{% endfor %}
</ul>

36
urls.py
View File

@ -22,9 +22,8 @@ admin.autodiscover()
actualurlpatterns = patterns('',
url(r'^troggle$', views_other.frontpage, name="frontpage"),
url(r'^caves$', views_caves.caveindex, name="caveindex"),
url(r'^troggle$', views_other.frontpage, name="frontpage"),
url(r'^caves$', views_caves.caveindex, name="caveindex"),
url(r'^people/?$', views_logbooks.personindex, name="personindex"),
url(r'^newqmnumber/?$', views_other.ajax_QM_number, ),
@ -50,26 +49,23 @@ actualurlpatterns = patterns('',
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<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"),
url(r'^caveslug/([^/]+)/?$', views_caves.caveSlug, name="caveSlug"),
url(r'^cave/entrance/([^/]+)/?$', views_caves.caveEntrance),
url(r'^cave/description/([^/]+)/?$', views_caves.caveDescription),
url(r'^cave/qms/([^/]+)/?$', views_caves.caveQMs), # blank page
url(r'^cave/logbook/([^/]+)/?$', views_caves.caveLogbook),
url(r'^cave/3d/(?P<cave_id>[^/]+).3d$', views_caves.cave3d, name="cave3d"),
url(r'^entrance/(?P<caveslug>[^/]+)/(?P<slug>[^/]+)/edit/', views_caves.editEntrance, name = "editentrance"),
url(r'^entrance/new/(?P<caveslug>[^/]+)/', views_caves.editEntrance, name = "newentrance"),
#url(r'^cavedescription/(?P<cavedescription_name>[^/]+)/?$', views_caves.cave_description, name="cavedescription"),
#url(r'^cavedescription/?$', object_list, {'queryset':CaveDescription.objects.all(),'template_name':'object_list.html'}, name="cavedescriptions"),
#url(r'^cavehref/(.+)$', views_caves.cave, name="cave"),url(r'cave'),
url(r'^cave/3d/(?P<cave_id>[^/]+).3d$', views_caves.cave3d, name="cave3d"),
url(r'^jgtfile/(.*)$', view_surveys.jgtfile, name="jgtfile"),
url(r'^jgtuploadfile$', view_surveys.jgtuploadfile, name="jgtuploadfile"),
url(r'^cave/(?P<cave_id>[^/]+)/?(?P<ent_letter>[^/])$', ent),
url(r'^cave/(?P<slug>[^/]+)/edit/$', views_caves.edit_cave, name="edit_cave"),
#(r'^cavesearch', caveSearch),
url(r'^cave/(?P<cave_id>[^/]+)/(?P<year>\d\d\d\d)-(?P<qm_id>\d*)(?P<grade>[ABCDX]?)?$', views_caves.qm, name="qm"),
url(r'^prospecting_guide/$', views_caves.prospecting),
@ -104,8 +100,11 @@ actualurlpatterns = patterns('',
{'document_root': settings.MEDIA_ROOT, 'show_indexes': True}),
#(r'^tinymce_media/(?P<path>.*)$', 'django.views.static.serve',
# {'document_root': settings.TINY_MCE_MEDIA_ROOT, 'show_indexes': True}),
#(r'^photos/(?P<path>.*)$', 'django.views.static.serve',
# {'document_root': settings.PHOTOS_ROOT, 'show_indexes':True}),
# (r'^gallery/(?P<path>.*)$', 'django.views.static.serve',
# {'document_root': settings.PHOTOS_ROOT, 'show_indexes':True}),
url(r'^survexblock/(.+)$', views_caves.survexblock, name="survexblock"),
url(r'^survexfile/(?P<survex_file>.*?)\.svx$', views_survex.svx, name="svx"),
url(r'^survexfile/(?P<survex_file>.*?)\.3d$', views_survex.threed, name="threed"),
@ -129,16 +128,9 @@ actualurlpatterns = patterns('',
url(r'^tunneldataraw/(?P<path>.+?\.xml)$', view_surveys.tunnelfile, name="tunnelfile"),
url(r'^tunneldataraw/(?P<path>.+?\.xml)/upload$',view_surveys.tunnelfileupload, name="tunnelfileupload"),
#url(r'^tunneldatainfo/(?P<path>.+?\.xml)$', view_surveys.tunnelfileinfo, name="tunnelfileinfo"),
#(r'^photos/(?P<path>.*)$', 'django.views.static.serve',
#{'document_root': settings.PHOTOS_ROOT, 'show_indexes':True}),
# url(r'^tunneldatainfo/(?P<path>.+?\.xml)$', view_surveys.tunnelfileinfo, name="tunnelfileinfo"),
url(r'^prospecting/(?P<name>[^.]+).png$', prospecting_image, name="prospecting_image"),
# (r'^gallery/(?P<path>.*)$', 'django.views.static.serve',
# {'document_root': settings.PHOTOS_ROOT, 'show_indexes':True}),
url(r'^(.*)_edit$', 'flatpages.views.editflatpage', name="editflatpage"),
url(r'^(.*)$', 'flatpages.views.flatpage', name="flatpage"),