forked from expo/troggle
fix tests to match new error messages
This commit is contained in:
parent
b3aa99f008
commit
406b4590a9
@ -162,7 +162,7 @@ class PageTests(TestCase):
|
||||
response = self.client.get('/cave/115')
|
||||
self.assertEqual(response.status_code, 200)
|
||||
content = response.content.decode()
|
||||
ph = r"Cave not found in database"
|
||||
ph = r"Cave Identifier not found in database"
|
||||
phmatch = re.search(ph, content)
|
||||
self.assertIsNotNone(phmatch, "Failed to find expected text: '" + ph +"'")
|
||||
|
||||
@ -435,7 +435,7 @@ class PageTests(TestCase):
|
||||
response = self.client.get('/survexfile/not_a_real_cave_number')
|
||||
self.assertEqual(response.status_code, 200)
|
||||
content = response.content.decode()
|
||||
ph = r'Cave not found in database'
|
||||
ph = r'Cave Identifier not found in database'
|
||||
phmatch = re.search(ph, content)
|
||||
self.assertIsNotNone(phmatch, "Failed to find expected text: '" + ph +"'")
|
||||
|
||||
|
@ -294,14 +294,22 @@ def caveEntrance(request, slug):
|
||||
return render(request,'cave_entrances.html', {'cave': cave})
|
||||
|
||||
def caveDescription(request, slug):
|
||||
cave = Cave.objects.get(caveslug__slug = slug)
|
||||
try:
|
||||
cave = Cave.objects.get(caveslug__slug = slug)
|
||||
except:
|
||||
return render(request,'errors/badslug.html', {'badslug': slug})
|
||||
|
||||
if cave.non_public and settings.PUBLIC_SITE and not request.user.is_authenticated:
|
||||
return render(request,'nonpublic.html', {'instance': cave})
|
||||
else:
|
||||
return render(request,'cave_uground_description.html', {'cave': cave})
|
||||
|
||||
def caveQMs(request, slug):
|
||||
cave = Cave.objects.get(caveslug__slug = slug)
|
||||
try:
|
||||
cave = Cave.objects.get(caveslug__slug = slug)
|
||||
except:
|
||||
return render(request,'errors/badslug.html', {'badslug': slug})
|
||||
|
||||
if cave.non_public and settings.PUBLIC_SITE and not request.user.is_authenticated:
|
||||
return render(request,'nonpublic.html', {'instance': cave})
|
||||
else:
|
||||
@ -316,7 +324,10 @@ def edit_cave(request, slug=None):
|
||||
'''
|
||||
message = ""
|
||||
if slug is not None:
|
||||
cave = Cave.objects.get(caveslug__slug = slug)
|
||||
try:
|
||||
cave = Cave.objects.get(caveslug__slug = slug)
|
||||
except:
|
||||
return render(request,'errors/badslug.html', {'badslug': slug})
|
||||
else:
|
||||
cave = Cave()
|
||||
if request.POST:
|
||||
@ -375,7 +386,10 @@ def edit_entrance(request, caveslug=None, slug=None):
|
||||
'''
|
||||
message = ""
|
||||
if caveslug is not None:
|
||||
cave = Cave.objects.get(caveslug__slug = caveslug)
|
||||
try:
|
||||
cave = Cave.objects.get(caveslug__slug = caveslug)
|
||||
except:
|
||||
return render(request,'errors/badslug.html', {'badslug': caveslug})
|
||||
else:
|
||||
cave = Cave()
|
||||
if slug is not None:
|
||||
@ -460,9 +474,15 @@ def surveyindex(request):
|
||||
return render(request,'survey.html',locals())
|
||||
|
||||
def get_entrances(request, caveslug):
|
||||
cave = Cave.objects.get(caveslug__slug = caveslug)
|
||||
try:
|
||||
cave = Cave.objects.get(caveslug__slug = caveslug)
|
||||
except:
|
||||
return render(request,'errors/badslug.html', {'badslug': caveslug})
|
||||
return render(request,'options.html', {"items": [(e.entrance.slug(), e.entrance.slug()) for e in cave.entrances()]})
|
||||
|
||||
def get_qms(request, caveslug):
|
||||
cave = Cave.objects.get(caveslug__slug = caveslug)
|
||||
try:
|
||||
cave = Cave.objects.get(caveslug__slug = caveslug)
|
||||
except:
|
||||
return render(request,'errors/badslug.html', {'badslug': caveslug})
|
||||
return render(request,'options.html', {"items": [(e.entrance.slug(), e.entrance.slug()) for e in cave.entrances()]})
|
||||
|
@ -418,14 +418,14 @@ def survexcavesingle(request, survex_cave):
|
||||
return render(request, 'svxcavesingle.html', {'settings': settings, "cave":cave })
|
||||
except ObjectDoesNotExist:
|
||||
continue # next attempt in for loop
|
||||
return render(request, 'svxcavesingle404.html', {'settings': settings, "cave":sc })
|
||||
return render(request, 'errors/svxcavesingle404.html', {'settings': settings, "cave":sc })
|
||||
|
||||
except MultipleObjectsReturned:
|
||||
caves = Cave.objects.filter(kataster_number=survex_cave)
|
||||
return render(request, 'svxcaveseveral.html', {'settings': settings, "caves":caves })
|
||||
|
||||
except:
|
||||
return render(request, 'svxcavesingle404.html', {'settings': settings, "cave":sc })
|
||||
return render(request, 'errors/svxcavesingle404.html', {'settings': settings, "cave":sc })
|
||||
|
||||
|
||||
def check_cave_registered(area, survex_cave):
|
||||
|
@ -1,4 +1,4 @@
|
||||
<!-- svxcavesingle404.html - this text visible because this template has been included -->
|
||||
<!-- errors/svxcavesingle404.html - this text visible because this template has been included -->
|
||||
{% extends "base.html" %}
|
||||
{% block title %}Troggle Error - Bad Cave ID{% endblock %}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user