diff --git a/core/TESTS/tests.py b/core/TESTS/tests.py
index 9ec0c57..8cd1f03 100644
--- a/core/TESTS/tests.py
+++ b/core/TESTS/tests.py
@@ -95,6 +95,21 @@ class PageTests(TestCase):
self.assertEqual(response.status_code, 200)
h1 = re.search(r'
Troggle administration
', content)
+ def test_page_admindocs(self):
+ # Issue a GET request.
+ response = self.client.get('/admin/login/models/')
+ content = response.content.decode()
+ self.assertEqual(response.status_code, 200)
+ h1 = re.search(r'Model documentation
', content)
+
+ # database not loaded yet? Or logon-problem?
+ # def test_page_admindocs_exped(self):
+ # # Issue a GET request.
+ # response = self.client.get('/admin/doc/models/core.expedition/')
+ # content = response.content.decode()
+ # self.assertEqual(response.status_code, 200)
+ # h1 = re.search(r'logbookentry_set.all | ', content)
+
def test_page_folk(self):
# This page is separately generated, so it has the full data content
response = self.client.get('/folk/')
@@ -122,6 +137,7 @@ class PageTests(TestCase):
response = self.client.get('/survey_scans/')
self.assertEqual(response.status_code, 200)
+ # database not loaded yet:
#response = self.client.get('/survey_scans/1991surveybook/page0002.png')
#response = self.client.get('/survey_scans/1991surveybook/')
#content = response.content.decode()
diff --git a/core/admin.py b/core/admin.py
index 26377b5..3cb8d86 100644
--- a/core/admin.py
+++ b/core/admin.py
@@ -30,11 +30,6 @@ class SurvexBlockAdmin(TroggleModelAdmin):
inlines = (RoleInline,)
-# class OtherCaveInline(admin.TabularInline):
- # model = OtherCaveName
- # extra = 1
-
-
class SurveyAdmin(TroggleModelAdmin):
#inlines = (ScannedImageInline,)
search_fields = ('expedition__year','wallet_number')
@@ -98,7 +93,6 @@ class PersonExpeditionAdmin(TroggleModelAdmin):
class CaveAdmin(TroggleModelAdmin):
search_fields = ('official_name','kataster_number','unofficial_number')
- #inlines = (OtherCaveInline,)
extra = 4
@@ -109,8 +103,6 @@ class EntranceAdmin(TroggleModelAdmin):
admin.site.register(Cave, CaveAdmin)
admin.site.register(Area)
admin.site.register(CaveAndEntrance)
-#admin.site.register(NewSubCave)
-#admin.site.register(CaveDescription)
admin.site.register(Entrance, EntranceAdmin)
admin.site.register(SurvexBlock, SurvexBlockAdmin)
admin.site.register(Expedition)
@@ -138,5 +130,5 @@ def export_as_xml(modeladmin, request, queryset):
return response
-#admin.site.add_action(export_as_xml)
-#admin.site.add_action(export_as_json)
+admin.site.add_action(export_as_xml)
+admin.site.add_action(export_as_json)
diff --git a/core/models.py b/core/models.py
index c8eb965..cd6f1e2 100644
--- a/core/models.py
+++ b/core/models.py
@@ -23,6 +23,12 @@ from django.template import Context, loader
import troggle.core.models_survex
+"""This file declares TroggleModel which inherits from django.db.models.Model
+All TroggleModel subclasses inherit persistence in the django relational database. This is known as
+the django Object Relkational Mapping (ORM).
+There are more subclasses define in models_caves.py models_survex.py etc.
+"""
+
def get_process_memory():
usage=resource.getrusage(resource.RUSAGE_SELF)
return usage[2]/1024.0
diff --git a/core/models_survex.py b/core/models_survex.py
index 1330f75..569bbb0 100644
--- a/core/models_survex.py
+++ b/core/models_survex.py
@@ -21,7 +21,6 @@ class SurvexDirectory(models.Model):
# return "[SurvexDirectory:"+str(self.path) + "-" + str(self.primarysurvexfile.path) + "-" + str(self.cave)+"]"
-
class SurvexFile(models.Model):
path = models.CharField(max_length=200)
survexdirectory = models.ForeignKey("SurvexDirectory", blank=True, null=True,on_delete=models.SET_NULL)
@@ -140,13 +139,6 @@ class SurvexBlock(models.Model):
def DayIndex(self):
return list(self.expeditionday.survexblock_set.all()).index(self)
-
-# Fossil. No code uses this.
-# class SurvexTitle(models.Model):
- # survexblock = models.ForeignKey('SurvexBlock',null=True, on_delete=models.SET_NULL)
- # title = models.CharField(max_length=200) # needed by svxcavesingle.html template
- # cave = models.ForeignKey('Cave', blank=True, null=True,on_delete=models.SET_NULL)
-
#
# member of a SurvexBlock
#
@@ -211,7 +203,7 @@ class TunnelFile(models.Model):
tunnelcontains = models.ManyToManyField("TunnelFile") # case when its a frame type
filesize = models.IntegerField(default=0)
npaths = models.IntegerField(default=0)
- survexfiles = models.ManyToManyField("SurvexFile") # direct link to SVX files
+ survexfiles = models.ManyToManyField("SurvexFile") # direct link to SVX files - not populated yet
class Meta:
ordering = ('tunnelpath',)
\ No newline at end of file
diff --git a/parsers/imports.py b/parsers/imports.py
index 0d5420b..e2a6224 100644
--- a/parsers/imports.py
+++ b/parsers/imports.py
@@ -6,7 +6,6 @@ from django.core import management
from django.db import connection, close_old_connections, connections
from django.contrib.auth.models import User
from django.http import HttpResponse
-#from django.urls import reverse, resolve
from django.db import transaction
import troggle.settings
@@ -15,7 +14,6 @@ import troggle.parsers.people
import troggle.parsers.surveys
import troggle.parsers.logbooks
import troggle.parsers.QMs
-import troggle.parsers.subcaves
def import_caves():
print("-- Importing Caves to ",end="")
@@ -69,8 +67,4 @@ def import_drawingsfiles():
with transaction.atomic():
troggle.parsers.surveys.LoadDrawingFiles()
-# Fossil.
-# def import_subcaves():
- # print("-- Interpreting SubCaves from CaveDescriptions")
- # troggle.parsers.subcaves.importAllSubcaves()
diff --git a/parsers/subcaves.py b/parsers/subcaves.py
deleted file mode 100644
index 89aa9b6..0000000
--- a/parsers/subcaves.py
+++ /dev/null
@@ -1,60 +0,0 @@
-# '''
-# This module is the part of troggle that parses descriptions of cave parts (subcaves) from the legacy html files and saves them in the troggle database as instances of the model Subcave. Unfortunately, this parser can not be very flexible because the legacy format is poorly structured.
-# '''
-# import sys
-# import os
-# import re
-# import logging
-
-# from django.conf import settings
-
-# from troggle.core.models_caves import Cave, NewSubCave
-# from utils import save_carefully
-
-# def getLinksInCaveDescription(cave):
- # '''
- # Returns all HTML tags from a given cave as a list of tuples
- # in the format ('filename.html','Description')
- # '''
- # pattern='(.*?)'
- # if cave.underground_description:
- # return re.findall(pattern,cave.underground_description)
- # else:
- # return []
-
-# def importSubcaves(cave):
- # for link in getLinksInCaveDescription(cave):
- # try:
- # subcaveFilePath=os.path.join(
- # settings.EXPOWEB,
- # os.path.dirname(cave.description_file),
- # link[0])
- # subcaveFile=open(subcaveFilePath,'rb')
- # description=subcaveFile.read() # decode('iso-8859-1').encode('utf-8')
-
- # #lookupAttribs={'title':link[1], 'cave':cave}
- # #nonLookupAttribs={'description':description}
- # lookupAttribs={}
- # nonLookupAttribs={}
- # newSubcave=save_carefully(NewSubCave,lookupAttribs=lookupAttribs,nonLookupAttribs=nonLookupAttribs)
-
- # logging.info("Added " + str(newSubcave) + " to " + str(cave))
- # except IOError:
- # logging.info("Subcave import couldn't open "+subcaveFilePath)
-
-# def getLinksInSubcaveDescription(subcave):
- # pattern='(.*?)'
- # if subcave.description:
- # return re.findall(pattern,subcave.description)
- # else:
- # return []
-
-# def getLinksInAllSubcaves():
- # bigList=[]
- # for subcave in NewSubCave.objects.all():
- # bigList+=getLinksInSubcaveDescription(subcave)
- # return bigList
-
-# def importAllSubcaves():
- # for cave in Cave.objects.all():
- # importSubcaves(cave)