|
@@ -36,9 +36,13 @@ def admin_update(request):
|
36
|
36
|
|
37
|
37
|
for in_put, in_value in request.form.items():
|
38
|
38
|
if in_put != 'classname' and in_put != 'uid':
|
39
|
|
- fields[in_put[12:]] = in_value
|
40
|
|
- #elif in_put == 'classname':
|
41
|
|
- # fields['classname'] = in_value
|
|
39
|
+ dhl = target_leo.data_handler(in_put[12:])
|
|
40
|
+ if dhl.is_reference() and in_value != '':
|
|
41
|
+ in_value.replace(" ","")
|
|
42
|
+ in_value=in_value.split(',')
|
|
43
|
+ in_value=list(in_value)
|
|
44
|
+ if in_value != '':
|
|
45
|
+ fields[in_put[12:]] = in_value
|
42
|
46
|
|
43
|
47
|
filter_q = '%s = %s' % (uid_field, uid)
|
44
|
48
|
obj = (target_leo.get((filter_q)))[0]
|
|
@@ -130,6 +134,50 @@ def admin_create(request):
|
130
|
134
|
raise HttpException(400)
|
131
|
135
|
return get_response('admin/admin_create.html', target=target_leo)
|
132
|
136
|
|
|
137
|
+def admin_delete(request):
|
|
138
|
+ if WebUiClient.is_anonymous():
|
|
139
|
+ return get_response('users/signin.html')
|
|
140
|
+ classname = None
|
|
141
|
+
|
|
142
|
+ if 'classname' in request.GET:
|
|
143
|
+ classname = request.GET['classname']
|
|
144
|
+ if len(classname) > 1:
|
|
145
|
+ raise HttpException(400)
|
|
146
|
+ classname = classname[0]
|
|
147
|
+ try:
|
|
148
|
+ target_leo = dyncode.Object.name2class(classname)
|
|
149
|
+ except LeApiError:
|
|
150
|
+ # classname = None
|
|
151
|
+ raise HttpException(400)
|
|
152
|
+ logger.warning('Composed uids broken here')
|
|
153
|
+ uid_field = target_leo.uid_fieldname()[0]
|
|
154
|
+
|
|
155
|
+ test_valid = 'lodel_id' in request.GET \
|
|
156
|
+ and len(request.GET['lodel_id']) == 1
|
|
157
|
+
|
|
158
|
+ if test_valid:
|
|
159
|
+ try:
|
|
160
|
+ dh = target_leo.field(uid_field)
|
|
161
|
+ lodel_id = dh.cast_type(request.GET['lodel_id'][0])
|
|
162
|
+ except (ValueError, TypeError):
|
|
163
|
+ test_valid = False
|
|
164
|
+
|
|
165
|
+ if not test_valid:
|
|
166
|
+ raise HttpException(400)
|
|
167
|
+ else:
|
|
168
|
+ query_filters = list()
|
|
169
|
+ query_filters.append((uid_field,'=',lodel_id))
|
|
170
|
+ nb_deleted = target_leo.delete_bundle(query_filters)
|
|
171
|
+
|
|
172
|
+ if nb_deleted == 1:
|
|
173
|
+ msg = 'Object successfully deleted';
|
|
174
|
+ else:
|
|
175
|
+ msg = 'Oops something wrong happened...object still here'
|
|
176
|
+
|
|
177
|
+ return get_response('admin/admin_delete.html', target=target_leo, lodel_id =lodel_id, msg = msg)
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
|
133
|
181
|
def admin_classes(request):
|
134
|
182
|
if WebUiClient.is_anonymous():
|
135
|
183
|
return get_response('users/signin.html')
|
|
@@ -139,6 +187,11 @@ def create_object(request):
|
139
|
187
|
if WebUiClient.is_anonymous():
|
140
|
188
|
return get_response('users/signin.html')
|
141
|
189
|
return get_response('admin/list_classes_create.html', my_classes = dyncode.dynclasses)
|
|
190
|
+
|
|
191
|
+def delete_object(request):
|
|
192
|
+ if WebUiClient.is_anonymous():
|
|
193
|
+ return get_response('users/signin.html')
|
|
194
|
+ return get_response('admin/list_classes_delete.html', my_classes = dyncode.dynclasses)
|
142
|
195
|
|
143
|
196
|
def admin_class(request):
|
144
|
197
|
if WebUiClient.is_anonymous():
|
|
@@ -155,7 +208,23 @@ def admin_class(request):
|
155
|
208
|
if classname is None or target_leo.is_abstract():
|
156
|
209
|
raise HttpException(400)
|
157
|
210
|
return get_response('admin/show_class_admin.html', target=target_leo)
|
158
|
|
-
|
|
211
|
+
|
|
212
|
+def delete_in_class(request):
|
|
213
|
+ if WebUiClient.is_anonymous():
|
|
214
|
+ return get_response('users/signin.html')
|
|
215
|
+ if 'classname' in request.GET:
|
|
216
|
+ classname = request.GET['classname']
|
|
217
|
+ if len(classname) > 1:
|
|
218
|
+ raise HttpException(400)
|
|
219
|
+ classname = classname[0]
|
|
220
|
+ try:
|
|
221
|
+ target_leo = dyncode.Object.name2class(classname)
|
|
222
|
+ except LeApiError:
|
|
223
|
+ classname = None
|
|
224
|
+ if classname is None or target_leo.is_abstract():
|
|
225
|
+ raise HttpException(400)
|
|
226
|
+ return get_response('admin/show_class_delete.html', target=target_leo)
|
|
227
|
+
|
159
|
228
|
def admin(request):
|
160
|
229
|
if WebUiClient.is_anonymous():
|
161
|
230
|
return get_response('users/signin.html')
|