Browse Source

Corrections

prieto 8 years ago
parent
commit
b0a1be8fcb

+ 1
- 1
lodel/leapi/leobject.py View File

@@ -226,7 +226,7 @@ class LeObject(object):
226 226
         uid_handlers = set( cls._fields[name] for name in cls._uid )
227 227
         for pcls in cls.hierarch()[1:]:
228 228
             puid_handlers = set(cls._fields[name] for name in pcls._uid)
229
-            if set(pcls._uid) != set(pcls._uid) \
229
+            if set(pcls._uid) != set(prev._uid) \
230 230
                 or puid_handlers != uid_handlers:
231 231
                 break
232 232
             prev = pcls

+ 12
- 3
plugins/webui/interface/controllers/admin.py View File

@@ -30,8 +30,8 @@ def admin_update(request):
30 30
         obj = (target_leo.get(('lodel_id = %s' % (uid))))[0]
31 31
         inserted = obj.update(fields)
32 32
         
33
-        if new_uid==1:
34
-            msg = 'Successfull creation';
33
+        if inserted==1:
34
+            msg = 'Successfully updated';
35 35
         else:
36 36
             msg = 'Oops something wrong happened...object not saved'
37 37
         return get_response('admin/admin_edit.html', target=target_leo, lodel_id = uid, msg = msg)
@@ -51,10 +51,19 @@ def admin_update(request):
51 51
         obj = dyncode.Object.get(['lodel_id = %d' % lodel_id])
52 52
         if len(obj) == 0:
53 53
             raise HttpException(404)
54
+    if 'classname' in request.GET:
55
+        classname = request.GET['classname']
56
+        if len(classname) > 1:
57
+            raise HttpException(400)
58
+        classname = classname[0]
59
+        try:
60
+            target_leo = dyncode.Object.name2class(classname)
61
+        except LeApiError:
62
+            classname = None
54 63
     template_vars = {
55 64
         'params': request.GET
56 65
     }
57
-    return get_response('admin/admin_edit.html', tpl_vars=template_vars)
66
+    return get_response('admin/admin_edit.html', target=target_leo, lodel_id =lodel_id, tpl_vars=template_vars)
58 67
 
59 68
 def admin_create(request):
60 69
     classname = None

+ 4
- 7
plugins/webui/templates/admin/admin_edit.html View File

@@ -1,16 +1,13 @@
1 1
 {% extends "base_backend.html" %}
2 2
 {% import "admin/editable_component.html" as edit %}
3
-{% set my_id = params['lodel_id'].pop() %}
4
-{% set classname = params['classname'].pop() %}}
5
-{% set my_class = leapi.Object.name2class(classname) %}
6
-{% set objects = my_class.get(('lodel_id = %s') % (my_id)) %}
3
+{% set objects = target.get(('lodel_id = %s') % (lodel_id)) %}
7 4
 {% set obj = objects.pop() %}
8 5
 {% block title %}- Edit Object{% endblock %}
9 6
 {% block body %}
10
-<h1>Lodel 2 - Edit Object {{ my_id }} of {{ classname }}</h1>
7
+<h1>Lodel 2 - Edit Object {{ lodel_id }} of {{ target.__name__ }}</h1>
11 8
     <form action="" method ="post">
12
-    <input type="hidden" name="uid" value="{{ my_id}}" >
13
-    <input type="hidden" name="classname" value={{ classname }} />
9
+    <input type="hidden" name="uid" value="{{ lodel_id}}" >
10
+    <input type="hidden" name="classname" value={{ target.__name__ }} />
14 11
     {% for fieldname, fieldvalue in obj.fields().items() %}
15 12
        <p> {{edit.input(fieldname, fieldvalue, obj.data(fieldname)) }} </p>
16 13
     {% endfor %}

Loading…
Cancel
Save