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

remove commented out code, more comments

This commit is contained in:
Philip Sargent 2020-07-29 22:54:09 +01:00
parent 42456e8e98
commit 95b9daca80
6 changed files with 25 additions and 85 deletions

View File

@ -95,6 +95,21 @@ class PageTests(TestCase):
self.assertEqual(response.status_code, 200) self.assertEqual(response.status_code, 200)
h1 = re.search(r'<h1 id="site-name">Troggle administration</h1>', content) h1 = re.search(r'<h1 id="site-name">Troggle administration</h1>', 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'<h1>Model documentation</h1>', 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'<td>logbookentry_set.all</td>', content)
def test_page_folk(self): def test_page_folk(self):
# This page is separately generated, so it has the full data content # This page is separately generated, so it has the full data content
response = self.client.get('/folk/') response = self.client.get('/folk/')
@ -122,6 +137,7 @@ class PageTests(TestCase):
response = self.client.get('/survey_scans/') response = self.client.get('/survey_scans/')
self.assertEqual(response.status_code, 200) 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/page0002.png')
#response = self.client.get('/survey_scans/1991surveybook/') #response = self.client.get('/survey_scans/1991surveybook/')
#content = response.content.decode() #content = response.content.decode()

View File

@ -30,11 +30,6 @@ class SurvexBlockAdmin(TroggleModelAdmin):
inlines = (RoleInline,) inlines = (RoleInline,)
# class OtherCaveInline(admin.TabularInline):
# model = OtherCaveName
# extra = 1
class SurveyAdmin(TroggleModelAdmin): class SurveyAdmin(TroggleModelAdmin):
#inlines = (ScannedImageInline,) #inlines = (ScannedImageInline,)
search_fields = ('expedition__year','wallet_number') search_fields = ('expedition__year','wallet_number')
@ -98,7 +93,6 @@ class PersonExpeditionAdmin(TroggleModelAdmin):
class CaveAdmin(TroggleModelAdmin): class CaveAdmin(TroggleModelAdmin):
search_fields = ('official_name','kataster_number','unofficial_number') search_fields = ('official_name','kataster_number','unofficial_number')
#inlines = (OtherCaveInline,)
extra = 4 extra = 4
@ -109,8 +103,6 @@ class EntranceAdmin(TroggleModelAdmin):
admin.site.register(Cave, CaveAdmin) admin.site.register(Cave, CaveAdmin)
admin.site.register(Area) admin.site.register(Area)
admin.site.register(CaveAndEntrance) admin.site.register(CaveAndEntrance)
#admin.site.register(NewSubCave)
#admin.site.register(CaveDescription)
admin.site.register(Entrance, EntranceAdmin) admin.site.register(Entrance, EntranceAdmin)
admin.site.register(SurvexBlock, SurvexBlockAdmin) admin.site.register(SurvexBlock, SurvexBlockAdmin)
admin.site.register(Expedition) admin.site.register(Expedition)
@ -138,5 +130,5 @@ def export_as_xml(modeladmin, request, queryset):
return response return response
#admin.site.add_action(export_as_xml) admin.site.add_action(export_as_xml)
#admin.site.add_action(export_as_json) admin.site.add_action(export_as_json)

View File

@ -23,6 +23,12 @@ from django.template import Context, loader
import troggle.core.models_survex 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(): def get_process_memory():
usage=resource.getrusage(resource.RUSAGE_SELF) usage=resource.getrusage(resource.RUSAGE_SELF)
return usage[2]/1024.0 return usage[2]/1024.0

View File

@ -21,7 +21,6 @@ class SurvexDirectory(models.Model):
# return "[SurvexDirectory:"+str(self.path) + "-" + str(self.primarysurvexfile.path) + "-" + str(self.cave)+"]" # return "[SurvexDirectory:"+str(self.path) + "-" + str(self.primarysurvexfile.path) + "-" + str(self.cave)+"]"
class SurvexFile(models.Model): class SurvexFile(models.Model):
path = models.CharField(max_length=200) path = models.CharField(max_length=200)
survexdirectory = models.ForeignKey("SurvexDirectory", blank=True, null=True,on_delete=models.SET_NULL) survexdirectory = models.ForeignKey("SurvexDirectory", blank=True, null=True,on_delete=models.SET_NULL)
@ -140,13 +139,6 @@ class SurvexBlock(models.Model):
def DayIndex(self): def DayIndex(self):
return list(self.expeditionday.survexblock_set.all()).index(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 # member of a SurvexBlock
# #
@ -211,7 +203,7 @@ class TunnelFile(models.Model):
tunnelcontains = models.ManyToManyField("TunnelFile") # case when its a frame type tunnelcontains = models.ManyToManyField("TunnelFile") # case when its a frame type
filesize = models.IntegerField(default=0) filesize = models.IntegerField(default=0)
npaths = 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: class Meta:
ordering = ('tunnelpath',) ordering = ('tunnelpath',)

View File

@ -6,7 +6,6 @@ from django.core import management
from django.db import connection, close_old_connections, connections from django.db import connection, close_old_connections, connections
from django.contrib.auth.models import User from django.contrib.auth.models import User
from django.http import HttpResponse from django.http import HttpResponse
#from django.urls import reverse, resolve
from django.db import transaction from django.db import transaction
import troggle.settings import troggle.settings
@ -15,7 +14,6 @@ import troggle.parsers.people
import troggle.parsers.surveys import troggle.parsers.surveys
import troggle.parsers.logbooks import troggle.parsers.logbooks
import troggle.parsers.QMs import troggle.parsers.QMs
import troggle.parsers.subcaves
def import_caves(): def import_caves():
print("-- Importing Caves to ",end="") print("-- Importing Caves to ",end="")
@ -69,8 +67,4 @@ def import_drawingsfiles():
with transaction.atomic(): with transaction.atomic():
troggle.parsers.surveys.LoadDrawingFiles() troggle.parsers.surveys.LoadDrawingFiles()
# Fossil.
# def import_subcaves():
# print("-- Interpreting SubCaves from CaveDescriptions")
# troggle.parsers.subcaves.importAllSubcaves()

View File

@ -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 <a href> tags from a given cave as a list of tuples
# in the format ('filename.html','Description')
# '''
# pattern='<a href=\"(.*?)\">(.*?)</a>'
# 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='<a href=\"(.*?)\">(.*?)</a>'
# 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)