Browse Source

Corrections

prieto 8 years ago
parent
commit
b0a1be8fcb

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

226
         uid_handlers = set( cls._fields[name] for name in cls._uid )
226
         uid_handlers = set( cls._fields[name] for name in cls._uid )
227
         for pcls in cls.hierarch()[1:]:
227
         for pcls in cls.hierarch()[1:]:
228
             puid_handlers = set(cls._fields[name] for name in pcls._uid)
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
                 or puid_handlers != uid_handlers:
230
                 or puid_handlers != uid_handlers:
231
                 break
231
                 break
232
             prev = pcls
232
             prev = pcls

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

30
         obj = (target_leo.get(('lodel_id = %s' % (uid))))[0]
30
         obj = (target_leo.get(('lodel_id = %s' % (uid))))[0]
31
         inserted = obj.update(fields)
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
         else:
35
         else:
36
             msg = 'Oops something wrong happened...object not saved'
36
             msg = 'Oops something wrong happened...object not saved'
37
         return get_response('admin/admin_edit.html', target=target_leo, lodel_id = uid, msg = msg)
37
         return get_response('admin/admin_edit.html', target=target_leo, lodel_id = uid, msg = msg)
51
         obj = dyncode.Object.get(['lodel_id = %d' % lodel_id])
51
         obj = dyncode.Object.get(['lodel_id = %d' % lodel_id])
52
         if len(obj) == 0:
52
         if len(obj) == 0:
53
             raise HttpException(404)
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
     template_vars = {
63
     template_vars = {
55
         'params': request.GET
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
 def admin_create(request):
68
 def admin_create(request):
60
     classname = None
69
     classname = None

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

1
 {% extends "base_backend.html" %}
1
 {% extends "base_backend.html" %}
2
 {% import "admin/editable_component.html" as edit %}
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
 {% set obj = objects.pop() %}
4
 {% set obj = objects.pop() %}
8
 {% block title %}- Edit Object{% endblock %}
5
 {% block title %}- Edit Object{% endblock %}
9
 {% block body %}
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
     <form action="" method ="post">
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
     {% for fieldname, fieldvalue in obj.fields().items() %}
11
     {% for fieldname, fieldvalue in obj.fields().items() %}
15
        <p> {{edit.input(fieldname, fieldvalue, obj.data(fieldname)) }} </p>
12
        <p> {{edit.input(fieldname, fieldvalue, obj.data(fieldname)) }} </p>
16
     {% endfor %}
13
     {% endfor %}

Loading…
Cancel
Save