mirror of
https://expo.survex.com/repositories/troggle/.git
synced 2024-11-21 14:51:51 +00:00
rename scansfolder to wallet
This commit is contained in:
parent
7f64670f36
commit
49b9225b6e
@ -114,7 +114,7 @@ class SurvexBlock(models.Model):
|
||||
survexfile = models.ForeignKey("SurvexFile", blank=True, null=True,on_delete=models.SET_NULL)
|
||||
survexpath = models.CharField(max_length=200) # the path for the survex stations
|
||||
|
||||
scansfolder = models.ForeignKey("Wallet", null=True,on_delete=models.SET_NULL)
|
||||
scanswallet = models.ForeignKey("Wallet", null=True,on_delete=models.SET_NULL)
|
||||
|
||||
legsall = models.IntegerField(null=True) # summary data for this block
|
||||
legslength = models.FloatField(null=True)
|
||||
@ -180,24 +180,24 @@ class Wallet(models.Model):
|
||||
ordering = ('walletname',)
|
||||
|
||||
def get_absolute_url(self):
|
||||
return urljoin(settings.URL_ROOT, reverse('scanswallet', kwargs={"path":re.sub("#", "%23", self.walletname)}))
|
||||
return urljoin(settings.URL_ROOT, reverse('singlewallet', kwargs={"path":re.sub("#", "%23", self.walletname)}))
|
||||
|
||||
def __str__(self):
|
||||
return str(self.walletname) + " (Survey Scans Folder)"
|
||||
|
||||
class SingleScan(models.Model):
|
||||
ffile = models.CharField(max_length=200)
|
||||
name = models.CharField(max_length=200)
|
||||
scansfolder = models.ForeignKey("Wallet", null=True,on_delete=models.SET_NULL)
|
||||
ffile = models.CharField(max_length=200)
|
||||
name = models.CharField(max_length=200)
|
||||
wallet = models.ForeignKey("Wallet", null=True,on_delete=models.SET_NULL)
|
||||
|
||||
class Meta:
|
||||
ordering = ('name',)
|
||||
|
||||
def get_absolute_url(self):
|
||||
return urljoin(settings.URL_ROOT, reverse('scansingle', kwargs={"path":re.sub("#", "%23", self.scansfolder.walletname), "file":self.name}))
|
||||
return urljoin(settings.URL_ROOT, reverse('scansingle', kwargs={"path":re.sub("#", "%23", self.wallet.walletname), "file":self.name}))
|
||||
|
||||
def __str__(self):
|
||||
return "Survey Scan Image: " + str(self.name) + " in " + str(self.scansfolder)
|
||||
return "Survey Scan Image: " + str(self.name) + " in " + str(self.wallet)
|
||||
|
||||
class DrawingFile(models.Model):
|
||||
dwgpath = models.CharField(max_length=200)
|
||||
|
@ -20,11 +20,11 @@ need to check if inavlid query string is invalid, or produces multiple replies
|
||||
and render a user-friendly error page.
|
||||
'''
|
||||
|
||||
def scanswallet(request, path):
|
||||
def singlewallet(request, path):
|
||||
#print [ s.walletname for s in Wallet.objects.all() ]
|
||||
try:
|
||||
scansfolder = Wallet.objects.get(walletname=urlunquote(path))
|
||||
return render(request, 'scansfolder.html', { 'scansfolder':scansfolder, 'settings': settings })
|
||||
wallet = Wallet.objects.get(walletname=urlunquote(path))
|
||||
return render(request, 'wallet.html', { 'wallet':wallet, 'settings': settings })
|
||||
except:
|
||||
message = f'Scan folder error or not found \'{path}\' .'
|
||||
return render(request, 'errors/generic.html', {'message': message})
|
||||
@ -33,8 +33,8 @@ def scansingle(request, path, file):
|
||||
'''sends a single binary file to the user for display - browser decides how using mimetype
|
||||
'''
|
||||
try:
|
||||
scansfolder = Wallet.objects.get(walletname=urlunquote(path))
|
||||
singlescan = SingleScan.objects.get(scansfolder=scansfolder, name=file)
|
||||
wallet = Wallet.objects.get(walletname=urlunquote(path))
|
||||
singlescan = SingleScan.objects.get(wallet=wallet, name=file)
|
||||
# print(" - scansingle {}:{}:{}:".format(path, file, getmimetype(file)))
|
||||
return HttpResponse(content=open(singlescan.ffile,"rb"), content_type=getmimetype(file)) # any type of image
|
||||
except:
|
||||
@ -42,7 +42,7 @@ def scansingle(request, path, file):
|
||||
return render(request, 'errors/generic.html', {'message': message})
|
||||
|
||||
|
||||
def scanswallets(request):
|
||||
def allwallets(request):
|
||||
manywallets = Wallet.objects.all()
|
||||
return render(request, 'manywallets.html', { 'manywallets':manywallets, 'settings': settings })
|
||||
|
||||
|
@ -86,7 +86,7 @@ class LoadingSurvex():
|
||||
"""A 'survex block' is a *begin...*end set of cave data.
|
||||
A survex file can contain many begin-end blocks, which can be nested, and which can *include
|
||||
other survex files.
|
||||
A 'scansfolder' is what we today call a "survey scans folder" or a "wallet".
|
||||
A 'scanswallet' is what we today call a "survey scans folder" or a "wallet".
|
||||
"""
|
||||
rx_begin = re.compile(r'(?i)begin')
|
||||
rx_end = re.compile(r'(?i)end$')
|
||||
@ -475,7 +475,7 @@ class LoadingSurvex():
|
||||
DataIssue.objects.create(parser='survex', message=message)
|
||||
manywallets = Wallet.objects.filter(walletname=refscan)
|
||||
if manywallets:
|
||||
survexblock.scansfolder = manywallets[0] # this is a ForeignKey field
|
||||
survexblock.scanswallet = manywallets[0] # this is a ForeignKey field
|
||||
print(manywallets[0])
|
||||
survexblock.save()
|
||||
if len(manywallets) > 1:
|
||||
|
@ -58,10 +58,10 @@ def GetListDir(sdir):
|
||||
return res
|
||||
|
||||
|
||||
def LoadListScansFile(scansfolder):
|
||||
def LoadListScansFile(wallet):
|
||||
gld = [ ]
|
||||
# flatten out any directories in these wallet folders - should not be any
|
||||
for (fyf, ffyf, fisdiryf) in GetListDir(scansfolder.fpath):
|
||||
for (fyf, ffyf, fisdiryf) in GetListDir(wallet.fpath):
|
||||
if fisdiryf:
|
||||
gld.extend(GetListDir(ffyf))
|
||||
else:
|
||||
@ -70,7 +70,7 @@ def LoadListScansFile(scansfolder):
|
||||
c=0
|
||||
for (fyf, ffyf, fisdiryf) in gld:
|
||||
if re.search(r"\.(?:png|jpg|jpeg|pdf|svg|gif)(?i)$", fyf):
|
||||
singlescan = SingleScan(ffile=ffyf, name=fyf, scansfolder=scansfolder)
|
||||
singlescan = SingleScan(ffile=ffyf, name=fyf, wallet=wallet)
|
||||
singlescan.save()
|
||||
c+=1
|
||||
if c>=10:
|
||||
@ -107,35 +107,35 @@ def LoadListScans():
|
||||
print("%s" % f, end=' ')
|
||||
for fy, ffy, fisdiry in GetListDir(ff):
|
||||
if fisdiry:
|
||||
scansfolder = Wallet(fpath=ffy, walletname=fy)
|
||||
scansfolder.save()
|
||||
LoadListScansFile(scansfolder)
|
||||
wallet = Wallet(fpath=ffy, walletname=fy)
|
||||
wallet.save()
|
||||
LoadListScansFile(wallet)
|
||||
|
||||
# do the
|
||||
elif f != "thumbs":
|
||||
scansfolder = Wallet(fpath=ff, walletname=f)
|
||||
scansfolder.save()
|
||||
LoadListScansFile(scansfolder)
|
||||
wallet = Wallet(fpath=ff, walletname=f)
|
||||
wallet.save()
|
||||
LoadListScansFile(wallet)
|
||||
|
||||
|
||||
def find_tunnel_scan(dwgfile, path):
|
||||
'''Is given a line of text 'path' which may or may not contain a recognisable name of a scanned file
|
||||
which we have already seen when we imported all the files we could find in the surveyscans direstories
|
||||
'''
|
||||
scansfolder, scansfile = None, None
|
||||
wallet, scansfile = None, None
|
||||
mscansdir = re.search(r"(\d\d\d\d#X?\d+\w?|1995-96kh|92-94Surveybookkh|1991surveybook|smkhs)/(.*?(?:png|jpg|pdf|jpeg))$", path)
|
||||
if mscansdir:
|
||||
scansfolderl = Wallet.objects.filter(walletname=mscansdir.group(1))
|
||||
scanswalletl = Wallet.objects.filter(walletname=mscansdir.group(1))
|
||||
# This should properly detect if a list of folders is returned and do something sensible, not just pick the first.
|
||||
if len(scansfolderl):
|
||||
scansfolder = scansfolderl[0]
|
||||
if len(scansfolderl) > 1:
|
||||
if len(scanswalletl):
|
||||
wallet = scanswalletl[0]
|
||||
if len(scanswalletl) > 1:
|
||||
message = "! More than one scan FOLDER matches filter query. [{}]: {} {} {} {}".format(scansfilel[0], mscansdir.group(1), mscansdir.group(2), dwgfile.dwgpath, path)
|
||||
print(message)
|
||||
DataIssue.objects.create(parser='Tunnel', message=message)
|
||||
|
||||
if scansfolder:
|
||||
scansfilel = scansfolder.singlescan_set.filter(name=mscansdir.group(2))
|
||||
if wallet:
|
||||
scansfilel = wallet.singlescan_set.filter(name=mscansdir.group(2))
|
||||
if len(scansfilel):
|
||||
if len(scansfilel) > 1:
|
||||
message = "! More than one image FILENAME matches filter query. [{}]: {} {} {} {}".format(scansfilel[0], mscansdir.group(1), mscansdir.group(2), dwgfile.dwgpath, path)
|
||||
@ -143,8 +143,8 @@ def find_tunnel_scan(dwgfile, path):
|
||||
DataIssue.objects.create(parser='Tunnel', message=message)
|
||||
scansfile = scansfilel[0]
|
||||
|
||||
if scansfolder:
|
||||
dwgfile.manywallets.add(scansfolder)
|
||||
if wallet:
|
||||
dwgfile.manywallets.add(wallet)
|
||||
if scansfile:
|
||||
dwgfile.scans.add(scansfile)
|
||||
|
||||
|
@ -1,8 +1,10 @@
|
||||
asgiref==3.3.4
|
||||
confusable-homoglyphs==3.2.0
|
||||
Django==2.2.19
|
||||
Django==2.2.20
|
||||
docutils==0.14
|
||||
gunicorn==20.1.0
|
||||
Pillow==5.4.1
|
||||
pytz==2019.1
|
||||
sqlparse==0.2.4
|
||||
typing-extensions==3.7.4.3
|
||||
Unidecode==1.0.23
|
||||
|
10
requirements3.2.txt
Normal file
10
requirements3.2.txt
Normal file
@ -0,0 +1,10 @@
|
||||
asgiref==3.3.4
|
||||
confusable-homoglyphs==3.2.0
|
||||
Django==3.2
|
||||
docutils==0.14
|
||||
gunicorn==20.1.0
|
||||
Pillow==5.4.1
|
||||
pytz==2019.1
|
||||
sqlparse==0.2.4
|
||||
typing-extensions==3.7.4.3
|
||||
Unidecode==1.0.23
|
@ -31,7 +31,7 @@
|
||||
<a href="{% url "survexcavessingle" "204" %}">Survex-204</a> |
|
||||
<a href="/survexfile/">Survex</a> |
|
||||
<a href="{% url "survexcaveslist" %}">All Survex</a> |
|
||||
<a href="{% url "scanswallets" %}">Scans</a> |
|
||||
<a href="{% url "allwallets" %}">Scans</a> |
|
||||
<a href="{% url "dwgdata" %}">Drawings</a> |
|
||||
<a href="/1623/290/290.html">290 (FGH)</a> |
|
||||
<a href="/1623/291/291">291 (GSH)</a> |
|
||||
|
@ -17,8 +17,8 @@
|
||||
<td align="right" style="padding:2px">{{dwgfile.npaths}}</td>
|
||||
|
||||
<td style="padding:2px">
|
||||
{% for scansfolder in dwgfile.manywallets.all %}
|
||||
<a href="{{scansfolder.get_absolute_url}}">{{scansfolder.walletname}}</a>
|
||||
{% for scanswallet in dwgfile.manywallets.all %}
|
||||
<a href="{{scanswallet.get_absolute_url}}">{{scanswallet.walletname}}</a>
|
||||
{% endfor %}
|
||||
</td>
|
||||
|
||||
|
@ -17,7 +17,7 @@
|
||||
{% if cavepage %}
|
||||
<ul>
|
||||
<li><a href="{% url "survexcaveslist" %}">All Survex</a></li>
|
||||
<li><a href="{% url "scanswallets" %}">Scans</a></li>
|
||||
<li><a href="{% url "allwallets" %}">Scans</a></li>
|
||||
<li><a href="{% url "dwgdata" %}">Drawings</a></li>
|
||||
<li><a href="{% url "survexcavessingle" "caves-1623/290/290.svx" %}">290</a></li>
|
||||
<li><a href="{% url "survexcavessingle" "caves-1623/291/291.svx" %}">291</a></li>
|
||||
|
@ -13,12 +13,12 @@ hand-drawn passage sections are drawn. These hand-drawn passages will eventually
|
||||
traced to produce Tunnel or Therion drawings and eventually the final complete cave survey.
|
||||
<table width=95%>
|
||||
<tr><th>Scans folder</th><th>Files</th><th>Survex blocks</th></tr>
|
||||
{% for scansfolder in manywallets %}
|
||||
{% for scanswallet in manywallets %}
|
||||
<tr>
|
||||
<td style="padding:2px"><a href="{{scansfolder.get_absolute_url}}">{{scansfolder.walletname}}</a></td>
|
||||
<td align="right" style="padding:2px">{{scansfolder.singlescan_set.all|length}}</td>
|
||||
<td style="padding:2px"><a href="{{scanswallet.get_absolute_url}}">{{scanswallet.walletname}}</a></td>
|
||||
<td align="right" style="padding:2px">{{scanswallet.singlescan_set.all|length}}</td>
|
||||
<td style="padding:2px">
|
||||
{% for survexblock in scansfolder.survexblock_set.all %}
|
||||
{% for survexblock in scanswallet.survexblock_set.all %}
|
||||
<a href="{% url "svx" survexblock.survexfile.path %}">{{survexblock}}</a>
|
||||
{% endfor %}
|
||||
</td>
|
||||
|
@ -89,8 +89,8 @@
|
||||
</td>
|
||||
<!-- Scans -->
|
||||
<td>
|
||||
{% if survexblock.scansfolder %}
|
||||
<b><a href="{{survexblock.scansfolder.get_absolute_url}}">{{survexblock.scansfolder.walletname}}</a></b>
|
||||
{% if survexblock.scanswallet %}
|
||||
<b><a href="{{survexblock.scanswallet.get_absolute_url}}">{{survexblock.scanswallet.walletname}}</a></b>
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
|
@ -89,8 +89,8 @@ to go to a form to correct the online data.
|
||||
</td>
|
||||
<!-- Scans -->
|
||||
<td>
|
||||
{% if survexblock.scansfolder %}
|
||||
<b><a href="{{survexblock.scansfolder.get_absolute_url}}">{{survexblock.scansfolder.walletname}}</a></b>
|
||||
{% if survexblock.scanswallet %}
|
||||
<b><a href="{{survexblock.scanswallet.get_absolute_url}}">{{survexblock.scanswallet.walletname}}</a></b>
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
|
@ -6,9 +6,9 @@
|
||||
|
||||
{% block content %}
|
||||
|
||||
<h3>Survey Scans in: {{scansfolder.walletname}}</h3>
|
||||
<h3>Survey Scans in: {{wallet.walletname}}</h3>
|
||||
<table>
|
||||
{% for singlescan in scansfolder.singlescan_set.all %}
|
||||
{% for singlescan in wallet.singlescan_set.all %}
|
||||
<tr>
|
||||
<td class="singlescan"><a href="{{singlescan.get_absolute_url}}">{{singlescan.name}}</a></td>
|
||||
<td>
|
||||
@ -23,7 +23,7 @@
|
||||
<h3>Survex surveys referring to this wallet</h3>
|
||||
|
||||
<table>
|
||||
{% for survexblock in scansfolder.survexblock_set.all %}
|
||||
{% for survexblock in wallet.survexblock_set.all %}
|
||||
<tr>
|
||||
<td><a href="{% url "svx" survexblock.survexfile.path %}">{{survexblock}}</a></td>
|
||||
</tr>
|
6
urls.py
6
urls.py
@ -9,7 +9,7 @@ from django.contrib import auth
|
||||
from django.urls import reverse, resolve
|
||||
|
||||
from troggle.core.views import caves, statistics, survex
|
||||
from troggle.core.views.surveys import scansingle, scanswallet, scanswallets, dwgdata, dwgfilesingle, dwgfileupload
|
||||
from troggle.core.views.surveys import scansingle, singlewallet, allwallets, dwgdata, dwgfilesingle, dwgfileupload
|
||||
from troggle.core.views.other import troggle404, frontpage, todos, controlpanel, frontpage, scanupload
|
||||
from troggle.core.views.other import downloadlogbook, ajax_QM_number, downloadQMs
|
||||
from troggle.core.views.caves import ent, cavepage
|
||||
@ -141,8 +141,8 @@ trogglepatterns = [
|
||||
re_path(r'^survexfile/caves$', survex.survexcaveslist, name="survexcaveslist"), # auto slash not working
|
||||
re_path(r'^survexfile/(?P<survex_cave>.*)$', survex.survexcavesingle, name="survexcavessingle"),
|
||||
|
||||
re_path(r'^survey_scans/$', scanswallets, name="scanswallets"),
|
||||
re_path(r'^survey_scans/(?P<path>[^/]+)/$', scanswallet, name="scanswallet"),
|
||||
re_path(r'^survey_scans/$', allwallets, name="allwallets"),
|
||||
re_path(r'^survey_scans/(?P<path>[^/]+)/$', singlewallet, name="singlewallet"),
|
||||
re_path(r'^survey_scans/(?P<path>[^/]+)/(?P<file>[^/]+)$',
|
||||
scansingle, name="scansingle"),
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user