-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathviews.py
executable file
·56 lines (53 loc) · 1.76 KB
/
views.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
from django.shortcuts import render_to_response, get_object_or_404
from django.http import HttpResponseRedirect
from django.template import Context, RequestContext
from django.contrib.gis.measure import D
from django.conf import settings
from models import TestViewDefinitions
def applist(request):
apps = []
for app in settings.INSTALLED_APPS:
if TestViewDefinitions(app).exists():
apps.append( app )
return render_to_response("applist.html",
{"apps": apps,
},
context_instance=RequestContext(request))
def testapp(request,app):
urls = []
error = None
definitions = TestViewDefinitions(app)
if definitions.exists():
urls = definitions.urls()
else:
error = "Failed to import from app %s" % (app)
return render_to_response("urllist.html",
{'app':app,
"urls": urls,
"error":error
},
context_instance=RequestContext(request))
def testurl(request,app,test_id):
urls = []
error = None
definitions = TestViewDefinitions(app)
if definitions.exists():
urls = definitions.urls()
else:
error = "Failed to import from app %s" % (app)
test_id = int(test_id)
(test_url,test_text) = urls[ test_id - 1]
prev = None
next = None
if test_id != 1:
prev = test_id - 1
if test_id != len(urls):
next = test_id + 1
return render_to_response("testview.html",
{"testurl": test_url,
"testtext":test_text,
"prev": prev,
"next": next,
'app': app,
"error":error, },
context_instance=RequestContext(request))