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

Commented-out unused CaveDescription object

This commit is contained in:
Philip Sargent 2020-07-23 01:24:06 +01:00
parent 2a0aee5bf5
commit 64727e0d3a
5 changed files with 47 additions and 48 deletions

View File

@ -51,7 +51,7 @@ class SimpleTest(SimpleTestCase):
from django.http import HttpResponse, HttpResponseRedirect
from django.shortcuts import get_object_or_404, render
from troggle.core.models import Expedition
from troggle.core.models_caves import CaveSlug, Cave, CaveAndEntrance, QM, CaveDescription, EntranceSlug, Entrance, Area, SurvexStation
from troggle.core.models_caves import CaveSlug, Cave, CaveAndEntrance, QM, EntranceSlug, Entrance, Area, SurvexStation
from troggle.core.forms import CaveForm, CaveAndEntranceFormSet, VersionControlCommentForm, EntranceForm, EntranceLetterForm
from troggle.helper import login_required_if_public
from django.contrib.auth.decorators import login_required

View File

@ -6,7 +6,7 @@ from django.core import serializers
from troggle.core.views_other import downloadLogbook
from troggle.core.models import Person, PersonExpedition, Expedition, DataIssue
from troggle.core.models_caves import Cave, Area, Entrance, CaveAndEntrance, OtherCaveName, CaveDescription, LogbookEntry, PersonTrip, QM
from troggle.core.models_caves import Cave, Area, Entrance, CaveAndEntrance, OtherCaveName, LogbookEntry, PersonTrip, QM
from troggle.core.models_survex import SurvexBlock, SurvexPersonRole, SurvexStation, ScansFolder, SingleScan
@ -110,7 +110,7 @@ admin.site.register(Cave, CaveAdmin)
admin.site.register(Area)
admin.site.register(CaveAndEntrance)
#admin.site.register(NewSubCave)
admin.site.register(CaveDescription)
#admin.site.register(CaveDescription)
admin.site.register(Entrance, EntranceAdmin)
admin.site.register(SurvexBlock, SurvexBlockAdmin)
admin.site.register(Expedition)

View File

@ -361,34 +361,34 @@ 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)
# 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 __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 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
# 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)

View File

@ -15,7 +15,7 @@ from django.shortcuts import get_object_or_404, render
import troggle.settings as settings
import troggle.core.models as models
from troggle.core.models import Expedition
from troggle.core.models_caves import CaveSlug, Cave, CaveAndEntrance, QM, CaveDescription, EntranceSlug, Entrance, Area, SurvexStation
from troggle.core.models_caves import CaveSlug, Cave, CaveAndEntrance, QM, EntranceSlug, Entrance, Area, SurvexStation
from troggle.core.forms import CaveForm, CaveAndEntranceFormSet, VersionControlCommentForm, EntranceForm, EntranceLetterForm
from troggle.helper import login_required_if_public
@ -291,9 +291,9 @@ def surveyindex(request):
expeditions=Expedition.objects.order_by("-year")
return render(request,'survey.html',locals())
def cave_description(request, cavedescription_name):
cave_description = get_object_or_404(CaveDescription, short_name = cavedescription_name)
return render(request,'cave_description.html', locals())
# def cave_description(request, cavedescription_name):
# cave_description = get_object_or_404(CaveDescription, short_name = cavedescription_name)
# return render(request,'cave_description.html', locals())
def get_entrances(request, caveslug):
cave = Cave.objects.get(caveslug__slug = caveslug)

View File

@ -5,7 +5,7 @@ import logging
from django.conf import settings
from django.shortcuts import render
from troggle.core.models_caves import CaveDescription
#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,20 +113,20 @@ def get_single_match(regex, text):
else:
return None
def href_to_wikilinks(matchobj):
"""
Given an html link, checks for possible valid wikilinks.
# 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'
# 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'''"),
@ -142,8 +142,7 @@ re_subs = [(re.compile(r"\<b[^>]*\>(.*?)\</b\>", re.DOTALL), r"'''\1'''"),
#interpage link needed
(re.compile(r"\<a\s+href=['\"]#([^'\"]*)['\"]\s*\>(.*?)\</a\>", re.DOTALL), r"[[cavedescription:\1|\2]]"), #assumes that all links with target ids are cave descriptions. Not great.
(re.compile(r"\[\<a\s+href=['\"][^'\"]*['\"]\s+id=['\"][^'\"]*['\"]\s*\>([^\s]*).*?\</a\>\]", re.DOTALL), r"[[qm:\1]]"),
(re.compile(r'<a\shref="?(?P<target>.*)"?>(?P<text>.*)</a>'),href_to_wikilinks),
# (re.compile(r'<a\shref="?(?P<target>.*)"?>(?P<text>.*)</a>'),href_to_wikilinks),
]
def html_to_wiki(text, codec = "utf-8"):