|
@@ -19,17 +19,17 @@ LIST_SEPARATOR = ','
|
19
|
19
|
##@brief These functions are called by the rules defined in ../urls.py
|
20
|
20
|
## To administrate the instance of the editorial model
|
21
|
21
|
|
22
|
|
-##@brief Controller's function to redirect on the home page of the admin
|
|
22
|
+##@brief Controller's function to redirect on the home page of the admin
|
23
|
23
|
# @param request : the request (get or post)
|
24
|
24
|
# @note the response is given in a html page called in get_response_function
|
25
|
25
|
def index_admin(request):
|
26
|
26
|
# We have to be identified to admin the instance
|
27
|
|
- # temporary, the acl will be more restrictive
|
|
27
|
+ # temporary, the acl will be more restrictive
|
28
|
28
|
#if WebUiClient.is_anonymous():
|
29
|
29
|
# return get_response('users/signin.html')
|
30
|
30
|
return get_response('admin/admin.html')
|
31
|
31
|
|
32
|
|
-##@brief Controller's function to update an object of the editorial model
|
|
32
|
+##@brief Controller's function to update an object of the editorial model
|
33
|
33
|
# @param request : the request (get or post)
|
34
|
34
|
# @note the response is given in a html page (in templates/admin) called in get_response_function
|
35
|
35
|
def admin_update(request):
|
|
@@ -38,7 +38,7 @@ def admin_update(request):
|
38
|
38
|
#if WebUiClient.is_anonymous():
|
39
|
39
|
# return get_response('users/signin.html')
|
40
|
40
|
msg=''
|
41
|
|
-
|
|
41
|
+
|
42
|
42
|
datas = process_form(request)
|
43
|
43
|
if not(datas is False):
|
44
|
44
|
if 'lodel_id' not in datas:
|
|
@@ -55,8 +55,8 @@ def admin_update(request):
|
55
|
55
|
except LeApiDataCheckErrors as e:
|
56
|
56
|
raise HttpErrors(
|
57
|
57
|
title='Form validation errors', errors = e._exceptions)
|
58
|
|
-
|
59
|
|
-
|
|
58
|
+
|
|
59
|
+
|
60
|
60
|
|
61
|
61
|
# Display of the form with the object's values to be updated
|
62
|
62
|
if 'classname' in request.GET:
|
|
@@ -72,7 +72,7 @@ def admin_update(request):
|
72
|
72
|
raise HttpException(400)
|
73
|
73
|
logger.warning('Composed uids broken here')
|
74
|
74
|
uid_field = target_leo.uid_fieldname()[0]
|
75
|
|
-
|
|
75
|
+
|
76
|
76
|
# We need the uid of the object
|
77
|
77
|
test_valid = 'lodel_id' in request.GET \
|
78
|
78
|
and len(request.GET['lodel_id']) == 1
|
|
@@ -91,11 +91,14 @@ def admin_update(request):
|
91
|
91
|
else:
|
92
|
92
|
# Check if the object actually exists
|
93
|
93
|
# We get it from the database
|
94
|
|
- if not target_leo.is_exist(lodel_id):
|
|
94
|
+ query_filters = list()
|
|
95
|
+ query_filters.append((uid_field,'=',lodel_id))
|
|
96
|
+ obj = target_leo.get(query_filters)
|
|
97
|
+ if len(obj) == 0:
|
95
|
98
|
raise HttpException(404)
|
96
|
99
|
return get_response('admin/admin_edit.html', target=target_leo, lodel_id =lodel_id)
|
97
|
100
|
|
98
|
|
-##@brief Controller's function to create an object of the editorial model
|
|
101
|
+##@brief Controller's function to create an object of the editorial model
|
99
|
102
|
# @param request : the request (get or post)
|
100
|
103
|
# @note the response is given in a html page (in templates/admin) called in get_response_function
|
101
|
104
|
def admin_create(request):
|
|
@@ -138,7 +141,7 @@ def admin_create(request):
|
138
|
141
|
raise HttpException(400)
|
139
|
142
|
return get_response('admin/admin_create.html', target=target_leo)
|
140
|
143
|
|
141
|
|
-##@brief Controller's function to delete an object of the editorial model
|
|
144
|
+##@brief Controller's function to delete an object of the editorial model
|
142
|
145
|
# @param request : the request (get)
|
143
|
146
|
# @note the response is given in a html page (in templates/admin) called in get_response_function
|
144
|
147
|
def admin_delete(request):
|
|
@@ -161,7 +164,7 @@ def admin_delete(request):
|
161
|
164
|
raise HttpException(400)
|
162
|
165
|
logger.warning('Composed uids broken here')
|
163
|
166
|
uid_field = target_leo.uid_fieldname()[0]
|
164
|
|
-
|
|
167
|
+
|
165
|
168
|
# We also need the uid of the object to delete
|
166
|
169
|
test_valid = 'lodel_id' in request.GET \
|
167
|
170
|
and len(request.GET['lodel_id']) == 1
|
|
@@ -186,11 +189,11 @@ def admin_delete(request):
|
186
|
189
|
msg = 'Object successfully deleted';
|
187
|
190
|
else:
|
188
|
191
|
msg = 'Oops something wrong happened...object still here'
|
189
|
|
-
|
|
192
|
+
|
190
|
193
|
return get_response('admin/admin_delete.html', target=target_leo, lodel_id =lodel_id, msg = msg)
|
191
|
194
|
|
192
|
|
-
|
193
|
|
-
|
|
195
|
+
|
|
196
|
+
|
194
|
197
|
def admin_classes(request):
|
195
|
198
|
# We have to be identified to admin the instance
|
196
|
199
|
# temporary, the acl will be more restrictive
|
|
@@ -211,7 +214,7 @@ def delete_object(request):
|
211
|
214
|
#if WebUiClient.is_anonymous():
|
212
|
215
|
# return get_response('users/signin.html')
|
213
|
216
|
return get_response('admin/list_classes_delete.html', my_classes = dyncode.dynclasses)
|
214
|
|
-
|
|
217
|
+
|
215
|
218
|
def admin_class(request):
|
216
|
219
|
# We have to be identified to admin the instance
|
217
|
220
|
# temporary, the acl will be more restrictive
|
|
@@ -313,7 +316,7 @@ def process_form(request):
|
313
|
316
|
if hasattr(dh, 'default'):
|
314
|
317
|
value = dh.default
|
315
|
318
|
else:
|
316
|
|
- #if not explicit default value, enforcing default as
|
|
319
|
+ #if not explicit default value, enforcing default as
|
317
|
320
|
#an empty list
|
318
|
321
|
value = []
|
319
|
322
|
else:
|
|
@@ -328,4 +331,3 @@ def process_form(request):
|
328
|
331
|
del(res)
|
329
|
332
|
raise HttpErrors(errors, title="Form validation error")
|
330
|
333
|
return res
|
331
|
|
-
|