mirror of
https://expo.survex.com/repositories/troggle/.git
synced 2024-11-21 14:51:51 +00:00
Delete commented-out code
This commit is contained in:
parent
809633bdd3
commit
924c5a3bf8
@ -6,6 +6,9 @@ Troggle has been forked into two projects. The original one is maintained by Aro
|
||||
and is used for Erebus caves. The CUCC variant uses files as the definitive data,
|
||||
not the database and lives at http://expo.survex.com/repositories/troggle/.git/
|
||||
|
||||
See copyright notices in
|
||||
http://expo.survex.com/handbook/computing/contribute.html
|
||||
|
||||
Troggle setup
|
||||
=============
|
||||
1. git clone troggle into correct directory structure
|
||||
|
@ -27,11 +27,13 @@ class Area(TroggleModel):
|
||||
name = models.CharField(max_length=200, blank=True, null=True)
|
||||
description = models.TextField(blank=True,null=True)
|
||||
parent = models.ForeignKey('Area', blank=True, null=True,on_delete=models.SET_NULL)
|
||||
|
||||
def __str__(self):
|
||||
if self.parent:
|
||||
return str(self.parent) + " - " + str(self.short_name)
|
||||
else:
|
||||
return str(self.short_name)
|
||||
|
||||
def kat_area(self):
|
||||
if self.short_name in ["1623", "1626"]:
|
||||
return self.short_name
|
||||
@ -44,7 +46,7 @@ class CaveAndEntrance(models.Model):
|
||||
entrance_letter = models.CharField(max_length=20,blank=True, null=True)
|
||||
def __str__(self):
|
||||
return str(self.cave) + str(self.entrance_letter)
|
||||
|
||||
|
||||
class CaveSlug(models.Model):
|
||||
cave = models.ForeignKey('Cave',on_delete=models.CASCADE)
|
||||
slug = models.SlugField(max_length=50, unique = True)
|
||||
@ -202,12 +204,6 @@ class Cave(TroggleModel):
|
||||
pass
|
||||
return lowestareas[0]
|
||||
|
||||
# class OtherCaveName(TroggleModel):
|
||||
# name = models.CharField(max_length=160)
|
||||
# cave = models.ForeignKey(Cave,on_delete=models.CASCADE)
|
||||
# def __str__(self):
|
||||
# return str(self.name)
|
||||
|
||||
class EntranceSlug(models.Model):
|
||||
entrance = models.ForeignKey('Entrance',on_delete=models.CASCADE)
|
||||
slug = models.SlugField(max_length=50, unique = True)
|
||||
@ -258,10 +254,10 @@ class Entrance(TroggleModel):
|
||||
|
||||
def exact_location(self):
|
||||
return SurvexStation.objects.lookup(self.exact_station)
|
||||
|
||||
def other_location(self):
|
||||
return SurvexStation.objects.lookup(self.other_station)
|
||||
|
||||
|
||||
def find_location(self):
|
||||
r = {'': 'To be entered ',
|
||||
'?': 'To be confirmed:',
|
||||
@ -313,26 +309,24 @@ class Entrance(TroggleModel):
|
||||
for m in self.MARKING_CHOICES:
|
||||
if m[0] == self.marking:
|
||||
return m[1]
|
||||
|
||||
def findability_val(self):
|
||||
for f in self.FINDABLE_CHOICES:
|
||||
if f[0] == self.findability:
|
||||
return f[1]
|
||||
|
||||
|
||||
def tag(self):
|
||||
return SurvexStation.objects.lookup(self.tag_station)
|
||||
|
||||
|
||||
def needs_surface_work(self):
|
||||
return self.findability != "S" or not self.has_photo or self.marking != "T"
|
||||
|
||||
def get_absolute_url(self):
|
||||
|
||||
ancestor_titles='/'.join([subcave.title for subcave in self.get_ancestors()])
|
||||
if ancestor_titles:
|
||||
res = '/'.join((self.get_root().cave.get_absolute_url(), ancestor_titles, self.title))
|
||||
|
||||
else:
|
||||
res = '/'.join((self.get_root().cave.get_absolute_url(), self.title))
|
||||
|
||||
return res
|
||||
|
||||
def slug(self):
|
||||
@ -361,40 +355,6 @@ class Entrance(TroggleModel):
|
||||
f.write(u8)
|
||||
f.close()
|
||||
|
||||
# class CaveDescription(TroggleModel):
|
||||
# short_name = models.CharField(max_length=50, unique = True)
|
||||
# long_name = models.CharField(max_length=200, blank=True, null=True)
|
||||
# description = models.TextField(blank=True,null=True)
|
||||
# #linked_subcaves = models.ManyToManyField("NewSubCave", blank=True)
|
||||
# linked_entrances = models.ManyToManyField("Entrance", blank=True)
|
||||
# linked_qms = models.ManyToManyField("QM", blank=True)
|
||||
|
||||
# def __str__(self):
|
||||
# if self.long_name:
|
||||
# return str(self.long_name)
|
||||
# else:
|
||||
# return str(self.short_name)
|
||||
|
||||
# def get_absolute_url(self):
|
||||
# return urljoin(settings.URL_ROOT, reverse('cavedescription', args=(self.short_name,)))
|
||||
|
||||
# def save(self):
|
||||
# """
|
||||
# Overridden save method which stores wikilinks in text as links in database.
|
||||
# """
|
||||
# TroggleModel.save()
|
||||
# #super(CaveDescription, self).save() # fails in python 3.8, OK in python 3.5
|
||||
# qm_list=get_related_by_wikilinks(self.description)
|
||||
# for qm in qm_list:
|
||||
# self.linked_qms.add(qm)
|
||||
# TroggleModel.save()
|
||||
# #super(CaveDescription, self).save() # fails in python 3.8, OK in python 3.5
|
||||
|
||||
# class NewSubCave(TroggleModel):
|
||||
# name = models.CharField(max_length=200, unique = True)
|
||||
# def __str__(self):
|
||||
# return str(self.name)
|
||||
|
||||
class LogbookEntry(TroggleModel):
|
||||
"""Single parsed entry from Logbook
|
||||
"""
|
||||
@ -402,7 +362,6 @@ class LogbookEntry(TroggleModel):
|
||||
("wiki", "Wiki style logbook"),
|
||||
("html", "Html style logbook")
|
||||
)
|
||||
|
||||
date = models.DateField()#MJG wants to turn this into a datetime such that multiple Logbook entries on the same day can be ordered.ld()
|
||||
expeditionday = models.ForeignKey("ExpeditionDay", null=True,on_delete=models.SET_NULL)#MJG wants to KILL THIS (redundant information)
|
||||
expedition = models.ForeignKey(Expedition,blank=True, null=True,on_delete=models.SET_NULL) # yes this is double-
|
||||
@ -473,15 +432,12 @@ class LogbookEntry(TroggleModel):
|
||||
def DayIndex(self):
|
||||
return list(self.expeditionday.logbookentry_set.all()).index(self)
|
||||
|
||||
|
||||
class QM(TroggleModel):
|
||||
# based on qm.csv in trunk/expoweb/1623/204 which has the fields:
|
||||
#"Number","Grade","Area","Description","Page reference","Nearest station","Completion description","Comment"
|
||||
"""This is based on qm.csv in trunk/expoweb/1623/204 which has the fields:
|
||||
"Number","Grade","Area","Description","Page reference","Nearest station","Completion description","Comment"
|
||||
"""
|
||||
found_by = models.ForeignKey(LogbookEntry, related_name='QMs_found',blank=True, null=True,on_delete=models.SET_NULL )
|
||||
ticked_off_by = models.ForeignKey(LogbookEntry, related_name='QMs_ticked_off',blank=True, null=True,on_delete=models.SET_NULL)
|
||||
#cave = models.ForeignKey(Cave,on_delete=models.SET_NULL)
|
||||
#expedition = models.ForeignKey(Expedition,on_delete=models.SET_NULL)
|
||||
|
||||
number = models.IntegerField(help_text="this is the sequential number in the year", )
|
||||
GRADE_CHOICES=(
|
||||
('A', 'A: Large obvious lead'),
|
||||
@ -521,33 +477,15 @@ class QM(TroggleModel):
|
||||
def wiki_link(self):
|
||||
return "%s%s%s" % ('[[QM:',self.code(),']]')
|
||||
|
||||
scansFileStorage = FileSystemStorage(location=settings.SURVEY_SCANS, base_url=settings.SURVEYS_URL)
|
||||
def get_scan_path(instance, filename):
|
||||
year=instance.survey.expedition.year
|
||||
#print("WN: ", type(instance.survey.wallet_number), instance.survey.wallet_number, instance.survey.wallet_letter)
|
||||
number=str(instance.survey.wallet_number)
|
||||
if str(instance.survey.wallet_letter) != "None":
|
||||
number=str(instance.survey.wallet_letter) + number #two strings formatting because convention is 2009#01 or 2009#X01
|
||||
return os.path.join('./',year,year+r'#'+number,str(instance.contents)+str(instance.number_in_wallet)+r'.jpg')
|
||||
#
|
||||
# Single Person going on a trip, which may or may not be written up (accounts for different T/U for people in same logbook entry)
|
||||
#
|
||||
class PersonTrip(TroggleModel):
|
||||
"""Single Person going on a trip, which may or may not be written up.
|
||||
It accounts for different T/U for people in same logbook entry.
|
||||
"""
|
||||
personexpedition = models.ForeignKey("PersonExpedition",null=True,on_delete=models.CASCADE)
|
||||
|
||||
#expeditionday = models.ForeignKey("ExpeditionDay",on_delete=models.SET_NULL)#MJG wants to KILL THIS (redundant information)
|
||||
#date = models.DateField() #MJG wants to KILL THIS (redundant information)
|
||||
time_underground = models.FloatField(help_text="In decimal hours")
|
||||
logbook_entry = models.ForeignKey(LogbookEntry,on_delete=models.CASCADE)
|
||||
is_logbook_entry_author = models.BooleanField(default=False)
|
||||
|
||||
|
||||
# sequencing by person (difficult to solve locally)
|
||||
#persontrip_next = models.ForeignKey('PersonTrip', related_name='pnext',
|
||||
#blank=True,null=True,on_delete=models.SET_NULL)#MJG wants to KILL THIS (and use funstion persontrip_next_auto)
|
||||
#persontrip_prev = models.ForeignKey('PersonTrip', related_name='pprev',
|
||||
#blank=True,null=True,on_delete=models.SET_NULL)#MJG wants to KILL THIS(and use funstion persontrip_prev_auto)
|
||||
|
||||
|
||||
def persontrip_next(self):
|
||||
futurePTs = PersonTrip.objects.filter(personexpedition = self.personexpedition, logbook_entry__date__gt = self.logbook_entry.date).order_by('logbook_entry__date').all()
|
||||
if len(futurePTs) > 0:
|
||||
@ -568,10 +506,19 @@ class PersonTrip(TroggleModel):
|
||||
def __str__(self):
|
||||
return "%s (%s)" % (self.personexpedition, self.logbook_entry.date)
|
||||
|
||||
# lookup function modelled on GetPersonExpeditionNameLookup
|
||||
# repeated assignment each call, needs refactoring
|
||||
scansFileStorage = FileSystemStorage(location=settings.SURVEY_SCANS, base_url=settings.SURVEYS_URL)
|
||||
def get_scan_path(instance, filename):
|
||||
year=instance.survey.expedition.year
|
||||
number=str(instance.survey.wallet_number)
|
||||
if str(instance.survey.wallet_letter) != "None":
|
||||
number=str(instance.survey.wallet_letter) + number #two strings formatting because convention is 2009#01 or 2009#X01
|
||||
return os.path.join('./',year,year+r'#'+number,str(instance.contents)+str(instance.number_in_wallet)+r'.jpg')
|
||||
|
||||
Gcavelookup = None
|
||||
def GetCaveLookup():
|
||||
"""lookup function modelled on GetPersonExpeditionNameLookup
|
||||
repeated assignment each call, needs refactoring
|
||||
"""
|
||||
global Gcavelookup
|
||||
if Gcavelookup:
|
||||
return Gcavelookup
|
||||
|
12
urls.py
12
urls.py
@ -33,7 +33,7 @@ admin.autodiscover()
|
||||
actualurlpatterns = [
|
||||
url(r'^troggle$', views_other.frontpage, name="frontpage"),
|
||||
url(r'^caves$', views_caves.caveindex, name="caveindex"),
|
||||
url(r'^indxal.htm$', views_caves.caveindex, name="caveindex"),
|
||||
url(r'^indxal.htm$', views_caves.caveindex, name="caveindex"), # ~420 hrefs to this in expoweb files
|
||||
url(r'^people/?$', views_logbooks.personindex, name="personindex"),
|
||||
|
||||
url(r'^newqmnumber/?$', views_other.ajax_QM_number, ),
|
||||
@ -47,9 +47,9 @@ actualurlpatterns = [
|
||||
url(r'^expeditions/?$', views_logbooks.ExpeditionListView.as_view(), name="expeditions"),
|
||||
url(r'^personexpedition/(?P<first_name>[A-Z]*[a-z&;]*)[^a-zA-Z]*(?P<last_name>[A-Z]*[a-zA-Z&;]*)/(?P<year>\d+)/?$', views_logbooks.personexpedition, name="personexpedition"),
|
||||
url(r'^logbookentry/(?P<date>.*)/(?P<slug>.*)/?$', views_logbooks.logbookentry,name="logbookentry"),
|
||||
url(r'^newlogbookentry/(?P<expeditionyear>.*)$', views_logbooks.newLogbookEntry, name="newLogBookEntry"),
|
||||
url(r'^editlogbookentry/(?P<expeditionyear>[^/]*)/(?P<pdate>[^/]*)/(?P<pslug>[^/]*)/$', views_logbooks.newLogbookEntry, name="editLogBookEntry"), # working !
|
||||
url(r'^deletelogbookentry/(?P<expeditionyear>[^/]*)/(?P<date>[^/]*)/(?P<slug>[^/]*)/$', views_logbooks.deleteLogbookEntry, name="deleteLogBookEntry"),
|
||||
url(r'^newlogbookentry/(?P<expeditionyear>.*)$', views_logbooks.newLogbookEntry, name="newLogBookEntry"), # Needed !
|
||||
# url(r'^editlogbookentry/(?P<expeditionyear>[^/]*)/(?P<pdate>[^/]*)/(?P<pslug>[^/]*)/$', views_logbooks.newLogbookEntry, name="editLogBookEntry"), # working !
|
||||
# url(r'^deletelogbookentry/(?P<expeditionyear>[^/]*)/(?P<date>[^/]*)/(?P<slug>[^/]*)/$', views_logbooks.deleteLogbookEntry, name="deleteLogBookEntry"),
|
||||
url(r'^newfile', views_other.newFile, name="newFile"), # oddly broken, needs investigating more
|
||||
|
||||
url(r'^getEntrances/(?P<caveslug>.*)', views_caves.get_entrances, name = "get_entrances"), #works
|
||||
@ -73,10 +73,6 @@ actualurlpatterns = [
|
||||
|
||||
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'^cavesearch', caveSearch),
|
||||
|
||||
url(r'^prospecting_guide/$', views_caves.prospecting),
|
||||
url(r'^logbooksearch/(.*)/?$', views_logbooks.logbookSearch),
|
||||
|
18
utils.py
18
utils.py
@ -5,7 +5,7 @@ import logging
|
||||
|
||||
from django.conf import settings
|
||||
from django.shortcuts import render
|
||||
#from troggle.core.models_caves import CaveDescription
|
||||
|
||||
"""Oddball mixture of critical, superfluous and useful functions which should
|
||||
be re-located more sensibly to other modules:
|
||||
|
||||
@ -113,22 +113,6 @@ def get_single_match(regex, text):
|
||||
else:
|
||||
return None
|
||||
|
||||
# def href_to_wikilinks(matchobj):
|
||||
# """
|
||||
# Given an html link, checks for possible valid wikilinks.
|
||||
|
||||
# Returns the first valid wikilink. Valid means the target
|
||||
# object actually exists.
|
||||
# """
|
||||
# res=CaveDescription.objects.filter(long_name__icontains=matchobj.groupdict()['text'])
|
||||
# if res and res[0]:
|
||||
# return r'[[cavedescription:'+res[0].short_name+'|'+res[0].long_name+']]'
|
||||
# else:
|
||||
# return matchobj.group()
|
||||
# #except:
|
||||
# #print 'fail'
|
||||
|
||||
|
||||
re_subs = [(re.compile(r"\<b[^>]*\>(.*?)\</b\>", re.DOTALL), r"'''\1'''"),
|
||||
(re.compile(r"\<i\>(.*?)\</i\>", re.DOTALL), r"''\1''"),
|
||||
(re.compile(r"\<h1[^>]*\>(.*?)\</h1\>", re.DOTALL), r"=\1="),
|
||||
|
Loading…
Reference in New Issue
Block a user