From 9cd70b31acf70c0df6207211efc629b95a8860d2 Mon Sep 17 00:00:00 2001 From: Philip Sargent Date: Tue, 23 Jun 2020 23:46:33 +0100 Subject: [PATCH] simple rename survexscansfolder to scansfolder --- core/migrations/0001_initial.py | 4 ++-- core/models_survex.py | 8 ++++---- core/view_surveys.py | 10 +++++----- parsers/survex.py | 8 ++++---- parsers/surveys.py | 18 +++++++++--------- templates/survexscansfolder.html | 6 +++--- templates/survexscansfolders.html | 8 ++++---- templates/svxcavesingle.html | 4 ++-- templates/tunnelfiles.html | 4 ++-- troggle-inspectdb.py | 12 ++++++------ 10 files changed, 41 insertions(+), 41 deletions(-) diff --git a/core/migrations/0001_initial.py b/core/migrations/0001_initial.py index 5e14a6c..6a8a847 100644 --- a/core/migrations/0001_initial.py +++ b/core/migrations/0001_initial.py @@ -376,7 +376,7 @@ class Migration(migrations.Migration): ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('ffile', models.CharField(max_length=200)), ('name', models.CharField(max_length=200)), - ('survexscansfolder', models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to='core.ScansFolder')), + ('scansfolder', models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to='core.ScansFolder')), ], options={ 'ordering': ('name',), @@ -434,7 +434,7 @@ class Migration(migrations.Migration): ), migrations.AddField( model_name='survexblock', - name='survexscansfolder', + name='scansfolder', field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to='core.ScansFolder'), ), migrations.AddField( diff --git a/core/models_survex.py b/core/models_survex.py index 75cdec8..2b99ddc 100644 --- a/core/models_survex.py +++ b/core/models_survex.py @@ -123,7 +123,7 @@ class SurvexBlock(models.Model): # begin_char = models.IntegerField() # code for where in the survex data files this block sits survexpath = models.CharField(max_length=200) # the path for the survex stations - survexscansfolder = models.ForeignKey("ScansFolder", null=True,on_delete=models.CASCADE) + scansfolder = models.ForeignKey("ScansFolder", null=True,on_delete=models.CASCADE) #refscandir = models.CharField(max_length=100) legsall = models.IntegerField(null=True) # summary data for this block @@ -211,16 +211,16 @@ class ScansFolder(models.Model): class SurvexScanSingle(models.Model): ffile = models.CharField(max_length=200) name = models.CharField(max_length=200) - survexscansfolder = models.ForeignKey("ScansFolder", null=True,on_delete=models.CASCADE) + scansfolder = models.ForeignKey("ScansFolder", null=True,on_delete=models.CASCADE) class Meta: ordering = ('name',) def get_absolute_url(self): - return urljoin(settings.URL_ROOT, reverse('surveyscansingle', kwargs={"path":re.sub("#", "%23", self.survexscansfolder.walletname), "file":self.name})) + return urljoin(settings.URL_ROOT, reverse('surveyscansingle', kwargs={"path":re.sub("#", "%23", self.scansfolder.walletname), "file":self.name})) def __str__(self): - return "Survey Scan Image: " + str(self.name) + " in " + str(self.survexscansfolder) + return "Survey Scan Image: " + str(self.name) + " in " + str(self.scansfolder) class TunnelFile(models.Model): tunnelpath = models.CharField(max_length=200) diff --git a/core/view_surveys.py b/core/view_surveys.py index fbe5c6f..73c5790 100644 --- a/core/view_surveys.py +++ b/core/view_surveys.py @@ -70,15 +70,15 @@ def SaveImageInDir(name, imgdir, project, fdata, bbinary): def surveyscansfolder(request, path): #print [ s.walletname for s in ScansFolder.objects.all() ] - survexscansfolder = ScansFolder.objects.get(walletname=urllib.parse.unquote(path)) - return render_to_response('survexscansfolder.html', { 'survexscansfolder':survexscansfolder, 'settings': settings }) + scansfolder = ScansFolder.objects.get(walletname=urllib.parse.unquote(path)) + return render_to_response('scansfolder.html', { 'scansfolder':scansfolder, 'settings': settings }) def surveyscansingle(request, path, file): - survexscansfolder = ScansFolder.objects.get(walletname=urllib.parse.unquote(path)) - survexscansingle = SurvexScanSingle.objects.get(survexscansfolder=survexscansfolder, name=file) + scansfolder = ScansFolder.objects.get(walletname=urllib.parse.unquote(path)) + survexscansingle = SurvexScanSingle.objects.get(scansfolder=scansfolder, name=file) print("SSS {} {} :{}:".format(path, file, flatviews.getmimetype(file))) return HttpResponse(content=open(survexscansingle.ffile,"rb"), content_type=flatviews.getmimetype(file)) - #return render_to_response('survexscansfolder.html', { 'survexscansfolder':survexscansfolder, 'settings': settings }) + #return render_to_response('scansfolder.html', { 'scansfolder':scansfolder, 'settings': settings }) def expofilessingle(request, filepath): # defaults to content_type="text/pain" needs fixing for PDFs diff --git a/parsers/survex.py b/parsers/survex.py index a290a83..b5542cf 100644 --- a/parsers/survex.py +++ b/parsers/survex.py @@ -19,7 +19,7 @@ from troggle.core.views_caves import MapLocations """A 'survex block' is a *begin...*end set of cave data. -A 'survexscansfolder' is what we today call a "survey scans folder" or a "wallet". +A 'scansfolder' is what we today call a "survey scans folder" or a "wallet". """ rx_braskets= re.compile(r"[()]") @@ -150,7 +150,7 @@ insp = "" callcount = 0 def RecursiveLoad(survexblock, survexfile, fin): """Follows the *include links in all the survex files from the root file 1623.svx - and reads in the survex blocks, other data and the wallet references (survexscansfolder) as it + and reads in the survex blocks, other data and the wallet references (scansfolder) as it goes. This part of the data import process is where the maximum memory is used and where it crashes on memory-constrained machines. """ @@ -198,7 +198,7 @@ def RecursiveLoad(survexblock, survexfile, fin): refscan = "%s#%s%s" % (yr, letterx, wallet ) manyscansfolders = models_survex.ScansFolder.objects.filter(walletname=refscan) if manyscansfolders: - survexblock.survexscansfolder = manyscansfolders[0] + survexblock.scansfolder = manyscansfolders[0] survexblock.save() else: message = ' ! Wallet ; ref {} - NOT found in manyscansfolders {}'.format(refscan, survexblock.survexfile.path) @@ -264,7 +264,7 @@ def RecursiveLoad(survexblock, survexfile, fin): refscan = "%s#%s%s" % (yr, letterx, wallet) manyscansfolders = models_survex.ScansFolder.objects.filter(walletname=refscan) if manyscansfolders: - survexblock.survexscansfolder = manyscansfolders[0] + survexblock.scansfolder = manyscansfolders[0] survexblock.save() else: message = ' ! Wallet *REF {} - NOT found in manyscansfolders {}'.format(refscan, survexblock.survexfile.path) diff --git a/parsers/surveys.py b/parsers/surveys.py index f3edebe..56db0fa 100644 --- a/parsers/surveys.py +++ b/parsers/surveys.py @@ -52,10 +52,10 @@ def GetListDir(sdir): return res -def LoadListScansFile(survexscansfolder): +def LoadListScansFile(scansfolder): gld = [ ] # flatten out any directories in these wallet folders - should not be any - for (fyf, ffyf, fisdiryf) in GetListDir(survexscansfolder.fpath): + for (fyf, ffyf, fisdiryf) in GetListDir(scansfolder.fpath): if fisdiryf: gld.extend(GetListDir(ffyf)) else: @@ -65,7 +65,7 @@ def LoadListScansFile(survexscansfolder): for (fyf, ffyf, fisdiryf) in gld: #assert not fisdiryf, ffyf if re.search(r"\.(?:png|jpg|jpeg|pdf|svg|gif)(?i)$", fyf): - survexscansingle = SurvexScanSingle(ffile=ffyf, name=fyf, survexscansfolder=survexscansfolder) + survexscansingle = SurvexScanSingle(ffile=ffyf, name=fyf, scansfolder=scansfolder) survexscansingle.save() c+=1 if c>=10: @@ -103,15 +103,15 @@ def LoadListScans(): for fy, ffy, fisdiry in GetListDir(ff): if fisdiry: assert fisdiry, ffy - survexscansfolder = ScansFolder(fpath=ffy, walletname=fy) - survexscansfolder.save() - LoadListScansFile(survexscansfolder) + scansfolder = ScansFolder(fpath=ffy, walletname=fy) + scansfolder.save() + LoadListScansFile(scansfolder) # do the elif f != "thumbs": - survexscansfolder = ScansFolder(fpath=ff, walletname=f) - survexscansfolder.save() - LoadListScansFile(survexscansfolder) + scansfolder = ScansFolder(fpath=ff, walletname=f) + scansfolder.save() + LoadListScansFile(scansfolder) def FindTunnelScan(tunnelfile, path): diff --git a/templates/survexscansfolder.html b/templates/survexscansfolder.html index f31044f..e82b1f6 100644 --- a/templates/survexscansfolder.html +++ b/templates/survexscansfolder.html @@ -6,9 +6,9 @@ {% block content %} -

Survey Scans in: {{survexscansfolder.walletname}}

+

Survey Scans in: {{scansfolder.walletname}}

-{% for survexscansingle in survexscansfolder.survexscansingle_set.all %} +{% for survexscansingle in scansfolder.survexscansingle_set.all %}
{{survexscansingle.name}} @@ -23,7 +23,7 @@

Survex surveys referring to this wallet

-{% for survexblock in survexscansfolder.survexblock_set.all %} +{% for survexblock in scansfolder.survexblock_set.all %} diff --git a/templates/survexscansfolders.html b/templates/survexscansfolders.html index 6049750..d1c16b7 100644 --- a/templates/survexscansfolders.html +++ b/templates/survexscansfolders.html @@ -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.
{{survexblock}}
-{% for survexscansfolder in manyscansfolders %} +{% for scansfolder in manyscansfolders %} - - + + diff --git a/templates/svxcavesingle.html b/templates/svxcavesingle.html index 54a4250..64c867e 100644 --- a/templates/svxcavesingle.html +++ b/templates/svxcavesingle.html @@ -66,8 +66,8 @@ diff --git a/templates/tunnelfiles.html b/templates/tunnelfiles.html index 83db4b0..0d73794 100644 --- a/templates/tunnelfiles.html +++ b/templates/tunnelfiles.html @@ -17,8 +17,8 @@ diff --git a/troggle-inspectdb.py b/troggle-inspectdb.py index 99f4ca7..a605324 100644 --- a/troggle-inspectdb.py +++ b/troggle-inspectdb.py @@ -390,7 +390,7 @@ class CoreSurvexblock(models.Model): expedition = models.ForeignKey(CoreExpedition, models.DO_NOTHING, blank=True, null=True) expeditionday = models.ForeignKey(CoreExpeditionday, models.DO_NOTHING, blank=True, null=True) survexfile = models.ForeignKey('CoreSurvexfile', models.DO_NOTHING, blank=True, null=True) - survexscansfolder = models.ForeignKey('CoreSurvexscansfolder', models.DO_NOTHING, blank=True, null=True) + scansfolder = models.ForeignKey('CoreSurvexscansfolder', models.DO_NOTHING, blank=True, null=True) parent = models.ForeignKey('self', models.DO_NOTHING, blank=True, null=True) class Meta: @@ -429,14 +429,14 @@ class CoreSurvexscansfolder(models.Model): class Meta: managed = False - db_table = 'core_survexscansfolder' + db_table = 'core_scansfolder' class CoreSurvexscansingle(models.Model): id = models.IntegerField(primary_key=True) # AutoField? ffile = models.CharField(max_length=200) name = models.CharField(max_length=200) - survexscansfolder = models.ForeignKey(CoreSurvexscansfolder, models.DO_NOTHING, blank=True, null=True) + scansfolder = models.ForeignKey(CoreSurvexscansfolder, models.DO_NOTHING, blank=True, null=True) class Meta: managed = False @@ -476,12 +476,12 @@ class CoreTunnelfileSurvexscans(models.Model): class CoreTunnelfileSurvexscansfolders(models.Model): id = models.IntegerField(primary_key=True) # AutoField? tunnelfile = models.ForeignKey(CoreTunnelfile, models.DO_NOTHING) - survexscansfolder = models.ForeignKey(CoreSurvexscansfolder, models.DO_NOTHING) + scansfolder = models.ForeignKey(CoreSurvexscansfolder, models.DO_NOTHING) class Meta: managed = False - db_table = 'core_tunnelfile_survexscansfolders' - unique_together = (('tunnelfile', 'survexscansfolder'),) + db_table = 'core_tunnelfile_scansfolders' + unique_together = (('tunnelfile', 'scansfolder'),) class CoreTunnelfileSurvextitles(models.Model):
Scans folderFilesSurvex blocks
{{survexscansfolder.walletname}}{{survexscansfolder.survexscansingle_set.all|length}}{{scansfolder.walletname}}{{scansfolder.survexscansingle_set.all|length}} - {% for survexblock in survexscansfolder.survexblock_set.all %} + {% for survexblock in scansfolder.survexblock_set.all %} {{survexblock}} {% endfor %} - {% if survexblock.survexscansfolder %} - {{survexblock.survexscansfolder.walletname}} + {% if survexblock.scansfolder %} + {{survexblock.scansfolder.walletname}} {% endif %}
{{tunnelfile.npaths}} - {% for survexscansfolder in tunnelfile.manyscansfolders.all %} - {{survexscansfolder.walletname}} + {% for scansfolder in tunnelfile.manyscansfolders.all %} + {{scansfolder.walletname}} {% endfor %}