diff --git a/core/TESTS/tests.py b/core/TESTS/tests.py index 446bd69..98b3215 100644 --- a/core/TESTS/tests.py +++ b/core/TESTS/tests.py @@ -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 diff --git a/core/admin.py b/core/admin.py index e0ba235..35cddb7 100644 --- a/core/admin.py +++ b/core/admin.py @@ -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) diff --git a/core/models_caves.py b/core/models_caves.py index cf388d9..b872489 100644 --- a/core/models_caves.py +++ b/core/models_caves.py @@ -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) diff --git a/core/views_caves.py b/core/views_caves.py index a0796f3..c4d06a1 100644 --- a/core/views_caves.py +++ b/core/views_caves.py @@ -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) diff --git a/utils.py b/utils.py index 8f30add..7bf57fa 100644 --- a/utils.py +++ b/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 +#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"\]*\>(.*?)\", re.DOTALL), r"'''\1'''"), @@ -142,8 +142,7 @@ re_subs = [(re.compile(r"\]*\>(.*?)\", re.DOTALL), r"'''\1'''"), #interpage link needed (re.compile(r"\(.*?)\", re.DOTALL), r"[[cavedescription:\1|\2]]"), #assumes that all links with target ids are cave descriptions. Not great. (re.compile(r"\[\([^\s]*).*?\\]", re.DOTALL), r"[[qm:\1]]"), - (re.compile(r'.*)"?>(?P.*)'),href_to_wikilinks), - +# (re.compile(r'.*)"?>(?P.*)'),href_to_wikilinks), ] def html_to_wiki(text, codec = "utf-8"):