Changeset 58641b0
- Timestamp:
- 05/27/11 17:03:22 (2 years ago)
- Branches:
- master
- Children:
- 349a990, f87a326
- Parents:
- c0847d6
- git-author:
- Pall Sigurdsson <palli@…> (05/27/11 17:03:22)
- git-committer:
- Pall Sigurdsson <palli@…> (05/27/11 17:03:22)
- Location:
- adagios
- Files:
-
- 5 edited
-
configurator/views.py (modified) (1 diff)
-
objectbrowser/urls.py (modified) (1 diff)
-
objectbrowser/views.py (modified) (3 diffs)
-
templates/objectbrowser/list_objects.html (modified) (2 diffs)
-
templates/objectbrowser/view_object.html (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
adagios/configurator/views.py
r99e2774 r58641b0 35 35 c['contacts'] = get_contacts() 36 36 return render_to_response('configurator/list_contacts.html', c) 37 38 37 39 38 def host(request, host_name=None): -
adagios/objectbrowser/urls.py
rc5564f7 r58641b0 9 9 10 10 #(r'/contact/+$', 'objectbrowser.views.list_contacts'), 11 (r'/(?P<object_type>.+)/(?P<attribute_name>.+)=(?P<attribute_value>.+)$', 'objectbrowser.views.view_objects'), 12 (r'/(?P<attribute_name>.+)=(?P<attribute_value>.+)$', 'objectbrowser.views.list_objects'), 11 13 (r'/(?P<object_type>.+)+$', 'objectbrowser.views.list_objects'), 12 (r'/(?P<object_type>.+)/+$', 'objectbrowser.views.list_objects'), 14 (r'/+$', 'objectbrowser.views.list_object_types'), 15 13 16 #(r'/contact/(?P<contact_name>.+)$', 'objectbrowser.views.get_contact'), 14 17 -
adagios/objectbrowser/views.py
rc5564f7 r58641b0 30 30 return render_to_response('configurator/list_contacts.html', c) 31 31 32 def list_objects( request, object_type ): 32 33 def list_objects( request, object_type=None, attribute_name=None, attribute_value=None ): 33 34 c = {} 34 35 c['messages'] = m = [] 35 36 c['objects'] = objects = [] 37 if attribute_name=='object_type': 38 object_type=attribute_value 36 39 if not Model.string_to_class.has_key(object_type): 37 40 m.append('Model does not have any objects of type %s, valid types are %s' % (object_type, Model.string_to_class.keys())) 38 41 else: 39 42 myClass = Model.string_to_class[object_type] 40 c['objects'] = myClass.objects.all 43 if attribute_name is None: 44 c['objects'] = myClass.objects.all 45 else: 46 tmp = {attribute_name:attribute_value} 47 c['objects'] = myClass.objects.filter(**tmp) 48 m.append("I used the filter %s=%s" % (attribute_name, attribute_value)) 41 49 m.append( "Found %s objects of type %s" % (len(c['objects']), object_type)) 42 50 return render_to_response('objectbrowser/list_objects.html', c) … … 54 62 ''' 55 63 56 def view_object( request, object_type, object_name ): 57 c = {} 58 c['object_type'] = object_type 59 o = ObjectDefinition(object_type) 60 return render_to_response('objectbrowser/view_object.html') 64 def view_objects( request, object_type, attribute_name=None, attribute_value=None ): 65 c = {} 66 c['messages'] = m = [] 67 c['objects'] = objects = [] 68 if not Model.string_to_class.has_key(object_type): 69 m.append('Model does not have any objects of type %s, valid types are %s' % (object_type, Model.string_to_class.keys())) 70 else: 71 myClass = Model.string_to_class[object_type] 72 if attribute_name is None: 73 c['objects'] = myClass.objects.all 74 else: 75 tmp = {attribute_name:attribute_value} 76 c['objects'] = myClass.objects.filter(**tmp) 77 m.append("I used the filter %s=%s" % (attribute_name, attribute_value)) 78 m.append( "Found %s objects of type %s" % (len(c['objects']), object_type)) 79 attributes = [] 80 c['first_object'] = c['objects'][0] 81 c['first_object'].data = ["1","2"] 82 for tmp in c['objects']: 83 for k in tmp.keys(): 84 if k not in attributes: attributes.append( k ) 85 for i in c['objects']: 86 i.my_data = "test" 87 attr_val = [] 88 for i in attributes: 89 if c['first_object']._defined_attributes.has_key(i): 90 defined_attr = c['first_object']._defined_attributes[i] 91 else: 92 defined_attr = "" 93 if i in c['first_object']._inherited_attributes: 94 inherited_attr = c['first_object']._inherited_attributes[i] 95 else: 96 inherited_attr = "" 97 if None != inherited_attr or None != defined_attr: 98 attr_val.append( [i, defined_attr, inherited_attr ] ) 99 c['attr_val'] = attr_val 100 c['attr_val'] = c['first_object'].get_attribute_tuple() 101 m.append( "id=%s" % c['first_object'].get_id()) 102 c['first_object'].id = c['first_object'].get_id() 103 return render_to_response('objectbrowser/view_object.html', c) 61 104 62 105 def get_contact(request, contact_name=None): … … 72 115 c['attributes'] = {} 73 116 return render_to_response('configurator/contact.html', c) 117 74 118 def get_host(request, host_name): 75 119 pass -
adagios/templates/objectbrowser/list_objects.html
rc0847d6 r58641b0 1 1 2 2 3 {% block title %} Showing{{ object_type }}{% endblock %}3 {% block title %}{{ object_type }}{% endblock %} 4 4 5 5 {% block content %} … … 19 19 {% for o in objects %} 20 20 <tr> 21 <td><a href="{{ o.object_type }}/ {{ o.name}}">{{ o.name }} </a></td>21 <td><a href="{{ o.object_type }}/id={{ o.id }}">{{ o.name }} </a></td> 22 22 <td>{{ o.object_type }}</td> 23 23 <td>{{ o.use }}</td> -
adagios/templates/objectbrowser/view_object.html
rc0847d6 r58641b0 1 {% extends "configurator/base.html" %}2 1 3 {% block title %}c.object_type{% endblock %} 2 3 {% block title %}{{ object_type }}{% endblock %} 4 4 5 5 {% block content %} … … 14 14 {% endif %} 15 15 16 {% if contact %}17 <h1>{{ contact.contact_name }}</h1>18 <table border=1>19 {% for key,value in not_template.items %}20 <tr><td>{{ key }}</td><td>{{ value }} </td></tr>21 {% endfor %}22 </table>23 <pre>24 Attributes from template:25 <table border=1>26 {% for key,value in template.items %}27 <tr><td>{{ key }}</td><td>{{ value }} </td></tr>28 {% endfor %}29 </table>30 16 31 </pre> 32 17 {% if first_object %} 18 <!-- 19 {{ first_object }} 20 --> 21 id={{ first_object.id }} 22 <table border=1> 23 <tr><th>Attribute Name</th><th>Defined Value</th><th>Inherited Value</th></tr> 24 {{ first_object.data }} 25 {% for attr in attr_val %} 26 <tr> 27 <td>{{ attr.0 }}</td><td>{{ attr.1 }}</td><td> {{attr.2}}</td> 28 </tr> 29 {% endfor %} 30 33 31 {% else %} 34 <p> {{ c.object_type }} notfound. </p>32 <p>No objects found. </p> 35 33 {% endif %} 36 34
Note: See TracChangeset
for help on using the changeset viewer.
