forked from expo/troggle
Commented-out unused CaveDescription object
This commit is contained in:
parent
2a0aee5bf5
commit
64727e0d3a
@ -51,7 +51,7 @@ class SimpleTest(SimpleTestCase):
|
|||||||
from django.http import HttpResponse, HttpResponseRedirect
|
from django.http import HttpResponse, HttpResponseRedirect
|
||||||
from django.shortcuts import get_object_or_404, render
|
from django.shortcuts import get_object_or_404, render
|
||||||
from troggle.core.models import Expedition
|
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.core.forms import CaveForm, CaveAndEntranceFormSet, VersionControlCommentForm, EntranceForm, EntranceLetterForm
|
||||||
from troggle.helper import login_required_if_public
|
from troggle.helper import login_required_if_public
|
||||||
from django.contrib.auth.decorators import login_required
|
from django.contrib.auth.decorators import login_required
|
||||||
|
@ -6,7 +6,7 @@ from django.core import serializers
|
|||||||
|
|
||||||
from troggle.core.views_other import downloadLogbook
|
from troggle.core.views_other import downloadLogbook
|
||||||
from troggle.core.models import Person, PersonExpedition, Expedition, DataIssue
|
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
|
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(Area)
|
||||||
admin.site.register(CaveAndEntrance)
|
admin.site.register(CaveAndEntrance)
|
||||||
#admin.site.register(NewSubCave)
|
#admin.site.register(NewSubCave)
|
||||||
admin.site.register(CaveDescription)
|
#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)
|
||||||
|
@ -361,34 +361,34 @@ class Entrance(TroggleModel):
|
|||||||
f.write(u8)
|
f.write(u8)
|
||||||
f.close()
|
f.close()
|
||||||
|
|
||||||
class CaveDescription(TroggleModel):
|
# class CaveDescription(TroggleModel):
|
||||||
short_name = models.CharField(max_length=50, unique = True)
|
# short_name = models.CharField(max_length=50, unique = True)
|
||||||
long_name = models.CharField(max_length=200, blank=True, null=True)
|
# long_name = models.CharField(max_length=200, blank=True, null=True)
|
||||||
description = models.TextField(blank=True,null=True)
|
# description = models.TextField(blank=True,null=True)
|
||||||
#linked_subcaves = models.ManyToManyField("NewSubCave", blank=True)
|
# #linked_subcaves = models.ManyToManyField("NewSubCave", blank=True)
|
||||||
linked_entrances = models.ManyToManyField("Entrance", blank=True)
|
# linked_entrances = models.ManyToManyField("Entrance", blank=True)
|
||||||
linked_qms = models.ManyToManyField("QM", blank=True)
|
# linked_qms = models.ManyToManyField("QM", blank=True)
|
||||||
|
|
||||||
def __str__(self):
|
# def __str__(self):
|
||||||
if self.long_name:
|
# if self.long_name:
|
||||||
return str(self.long_name)
|
# return str(self.long_name)
|
||||||
else:
|
# else:
|
||||||
return str(self.short_name)
|
# return str(self.short_name)
|
||||||
|
|
||||||
def get_absolute_url(self):
|
# def get_absolute_url(self):
|
||||||
return urljoin(settings.URL_ROOT, reverse('cavedescription', args=(self.short_name,)))
|
# return urljoin(settings.URL_ROOT, reverse('cavedescription', args=(self.short_name,)))
|
||||||
|
|
||||||
def save(self):
|
# def save(self):
|
||||||
"""
|
# """
|
||||||
Overridden save method which stores wikilinks in text as links in database.
|
# Overridden save method which stores wikilinks in text as links in database.
|
||||||
"""
|
# """
|
||||||
TroggleModel.save()
|
# TroggleModel.save()
|
||||||
#super(CaveDescription, self).save() # fails in python 3.8, OK in python 3.5
|
# #super(CaveDescription, self).save() # fails in python 3.8, OK in python 3.5
|
||||||
qm_list=get_related_by_wikilinks(self.description)
|
# qm_list=get_related_by_wikilinks(self.description)
|
||||||
for qm in qm_list:
|
# for qm in qm_list:
|
||||||
self.linked_qms.add(qm)
|
# self.linked_qms.add(qm)
|
||||||
TroggleModel.save()
|
# TroggleModel.save()
|
||||||
#super(CaveDescription, self).save() # fails in python 3.8, OK in python 3.5
|
# #super(CaveDescription, self).save() # fails in python 3.8, OK in python 3.5
|
||||||
|
|
||||||
# class NewSubCave(TroggleModel):
|
# class NewSubCave(TroggleModel):
|
||||||
# name = models.CharField(max_length=200, unique = True)
|
# name = models.CharField(max_length=200, unique = True)
|
||||||
|
@ -15,7 +15,7 @@ from django.shortcuts import get_object_or_404, render
|
|||||||
import troggle.settings as settings
|
import troggle.settings as settings
|
||||||
import troggle.core.models as models
|
import troggle.core.models as models
|
||||||
from troggle.core.models import Expedition
|
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.core.forms import CaveForm, CaveAndEntranceFormSet, VersionControlCommentForm, EntranceForm, EntranceLetterForm
|
||||||
from troggle.helper import login_required_if_public
|
from troggle.helper import login_required_if_public
|
||||||
|
|
||||||
@ -291,9 +291,9 @@ def surveyindex(request):
|
|||||||
expeditions=Expedition.objects.order_by("-year")
|
expeditions=Expedition.objects.order_by("-year")
|
||||||
return render(request,'survey.html',locals())
|
return render(request,'survey.html',locals())
|
||||||
|
|
||||||
def cave_description(request, cavedescription_name):
|
# def cave_description(request, cavedescription_name):
|
||||||
cave_description = get_object_or_404(CaveDescription, short_name = cavedescription_name)
|
# cave_description = get_object_or_404(CaveDescription, short_name = cavedescription_name)
|
||||||
return render(request,'cave_description.html', locals())
|
# return render(request,'cave_description.html', locals())
|
||||||
|
|
||||||
def get_entrances(request, caveslug):
|
def get_entrances(request, caveslug):
|
||||||
cave = Cave.objects.get(caveslug__slug = caveslug)
|
cave = Cave.objects.get(caveslug__slug = caveslug)
|
||||||
|
31
utils.py
31
utils.py
@ -5,7 +5,7 @@ import logging
|
|||||||
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.shortcuts import render
|
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
|
"""Oddball mixture of critical, superfluous and useful functions which should
|
||||||
be re-located more sensibly to other modules:
|
be re-located more sensibly to other modules:
|
||||||
|
|
||||||
@ -113,20 +113,20 @@ def get_single_match(regex, text):
|
|||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def href_to_wikilinks(matchobj):
|
# def href_to_wikilinks(matchobj):
|
||||||
"""
|
# """
|
||||||
Given an html link, checks for possible valid wikilinks.
|
# Given an html link, checks for possible valid wikilinks.
|
||||||
|
|
||||||
Returns the first valid wikilink. Valid means the target
|
# Returns the first valid wikilink. Valid means the target
|
||||||
object actually exists.
|
# object actually exists.
|
||||||
"""
|
# """
|
||||||
res=CaveDescription.objects.filter(long_name__icontains=matchobj.groupdict()['text'])
|
# res=CaveDescription.objects.filter(long_name__icontains=matchobj.groupdict()['text'])
|
||||||
if res and res[0]:
|
# if res and res[0]:
|
||||||
return r'[[cavedescription:'+res[0].short_name+'|'+res[0].long_name+']]'
|
# return r'[[cavedescription:'+res[0].short_name+'|'+res[0].long_name+']]'
|
||||||
else:
|
# else:
|
||||||
return matchobj.group()
|
# return matchobj.group()
|
||||||
#except:
|
# #except:
|
||||||
#print 'fail'
|
# #print 'fail'
|
||||||
|
|
||||||
|
|
||||||
re_subs = [(re.compile(r"\<b[^>]*\>(.*?)\</b\>", re.DOTALL), r"'''\1'''"),
|
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
|
#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*\>(.*?)\</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\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"):
|
def html_to_wiki(text, codec = "utf-8"):
|
||||||
|
Loading…
Reference in New Issue
Block a user