|
@@ -1,8 +1,51 @@
|
|
1
|
+from ...exceptions import *
|
1
|
2
|
from .base import get_response
|
2
|
3
|
|
|
4
|
+from lodel.leapi.exceptions import *
|
|
5
|
+from lodel import logger
|
|
6
|
+
|
|
7
|
+import leapi_dyncode as dyncode
|
|
8
|
+
|
3
|
9
|
def index_admin(request):
|
4
|
10
|
return get_response('admin/admin.html')
|
5
|
11
|
|
|
12
|
+def admin_update(request):
|
|
13
|
+ test_valid = 'lodel_id' in request.GET \
|
|
14
|
+ and len(request.GET['lodel_id']) == 1
|
|
15
|
+
|
|
16
|
+ if test_valid:
|
|
17
|
+ try:
|
|
18
|
+ lodel_id = int(request.GET['lodel_id'][0])
|
|
19
|
+ except (ValueError, TypeError):
|
|
20
|
+ test_valid = False
|
|
21
|
+
|
|
22
|
+ if not test_valid:
|
|
23
|
+ raise HttpException(400)
|
|
24
|
+ else:
|
|
25
|
+ obj = dyncode.Object.get(['lodel_id = %d' % lodel_id])
|
|
26
|
+ if len(obj) == 0:
|
|
27
|
+ raise HttpException(404)
|
|
28
|
+ print("WHAT WE GOT AS RESPONSE : ")
|
|
29
|
+ for n,o in enumerate(obj):
|
|
30
|
+ print("\t",n,o.datas(True))
|
|
31
|
+ return get_response('admin/admin_edit.html', obj = obj)
|
|
32
|
+
|
|
33
|
+def admin_create(request):
|
|
34
|
+ classname = None
|
|
35
|
+ if 'classname' in request.GET:
|
|
36
|
+ classname = request.GET['classname']
|
|
37
|
+ if len(classname) > 1:
|
|
38
|
+ raise HttpException(400)
|
|
39
|
+ classname = classname[0]
|
|
40
|
+ try:
|
|
41
|
+ target_leo = dyncode.Object.name2class(classname)
|
|
42
|
+ except LeApiError:
|
|
43
|
+ classname = None
|
|
44
|
+ if classname is None or target_leo.is_abstract():
|
|
45
|
+ raise HttpException(400)
|
|
46
|
+
|
|
47
|
+ return get_response('admin/admin_create.html', target=target_leo)
|
|
48
|
+
|
6
|
49
|
def admin(request):
|
7
|
50
|
return get_response('admin/admin.html')
|
8
|
51
|
|