Changeset f116422
- Timestamp:
- 05/29/11 23:06:01 (2 years ago)
- Branches:
- master
- Children:
- 69e8ce1
- Parents:
- 582de6e
- git-author:
- Pall Sigurdsson <palli@…> (05/29/11 23:06:01)
- git-committer:
- Pall Sigurdsson <palli@…> (05/29/11 23:06:01)
- Location:
- adagios
- Files:
-
- 3 edited
-
objectbrowser/urls.py (modified) (1 diff)
-
objectbrowser/views.py (modified) (6 diffs)
-
templates/configurator/base.html (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
adagios/objectbrowser/urls.py
r582de6e rf116422 3 3 4 4 urlpatterns = patterns('', 5 # Example:6 #(r'^/', 'objectbrowser.views.index'),7 #(r'^/host', 'objectbrowser.views.list_hosts'),8 #(r'^/host/(?P<host_name>.+)$', 'objectbrowser.views.get_host'),9 10 #(r'/contact/+$', 'objectbrowser.views.list_contacts'),11 5 (r'/id=(?P<object_id>.+)$', 'objectbrowser.views.view_object'), 6 12 7 (r'/(?P<attribute_name>.+)=(?P<attribute_value>.+?)/(?P<attribute2_name>.+)=(?P<attribute2_value>.+?)/(?P<attribute3_name>.+)=(?P<attribute3_value>.+?)/?$', 'objectbrowser.views.list_objects'), 13 #(r'/(?P<attribute_name>.+)=(?P<attribute_value>.+?)$', 'objectbrowser.views.list_objects'), 14 (r'/(?P<attribute_name>.+)=(?P<attribute_value>.+?)/(?P<attribute2_name>.+)=(?P<attribute2_value>.+?)$', 'objectbrowser.views.list_objects'), 8 (r'/(?P<attribute_name>.+)=(?P<attribute_value>.+?)/(?P<attribute2_name>.+)=(?P<attribute2_value>.+?)/?$', 'objectbrowser.views.list_objects'), 15 9 (r'/(?P<attribute_name>.+)=(?P<attribute_value>.+?)/?$', 'objectbrowser.views.list_objects'), 16 10 11 # By default, lets just display a list of object_types available 17 12 (r'/$', 'objectbrowser.views.list_object_types'), 13 # 18 14 (r'/(?P<object_type>.+)/?$', 'objectbrowser.views.list_objects'), 19 15 -
adagios/objectbrowser/views.py
r582de6e rf116422 1 # -*- coding: utf-8 -*- 2 # 3 # Copyright 2010, Pall Sigurdsson <palli@opensource.is> 4 # 5 # This script is free software: you can redistribute it and/or modify 6 # it under the terms of the GNU General Public License as published by 7 # the Free Software Foundation, either version 3 of the License, or 8 # (at your option) any later version. 9 # 10 # This script is distributed in the hope that it will be useful, 11 # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 # GNU General Public License for more details. 14 # 15 # You should have received a copy of the GNU General Public License 16 # along with this program. If not, see <http://www.gnu.org/licenses/>. 17 1 18 from django.shortcuts import render_to_response, redirect 2 19 from django.core import serializers … … 20 37 return list_hosts(request) 21 38 39 ## DEPRECATED for list_objects 22 40 def list_hosts(request): 23 41 c = {} 24 42 c['hosts'] = Host.objects.all 25 43 return render_to_response('configurator/index.html', c) 26 44 ## Deprecated for list_objects 27 45 def list_contacts(request): 28 46 c = {} … … 36 54 c['objects'] = objects = [] 37 55 38 if attribute_name=='object_type': 39 object_type=attribute_value 56 search = tmp = {} 57 if attribute_name != None: 58 search = {attribute_name:attribute_value} 59 if attribute2_name != None: 60 search[attribute2_name]=attribute2_value 61 if attribute3_name != None: 62 search[attribute3_name]=attribute3_value 63 64 for k,v in search.items(): 65 if k == 'object_type': 66 object_type = v 67 elif v == 'None': 68 search[k] = None 40 69 # If a non-existent object_type is requested, lets display a warning 41 70 if not Model.string_to_class.has_key(object_type): … … 49 78 c['objects'] = myClass.objects.all 50 79 else: 51 if attribute_name != None: 52 tmp = {attribute_name:attribute_value} 53 if attribute2_name != None: 54 tmp[attribute2_name]=attribute2_value 55 if attribute3_name != None: 56 tmp[attribute3_name]=attribute3_value 57 58 c['objects'] = myClass.objects.filter(**tmp) 59 m.append("I used the filter %s=%s" % (tmp.keys(), tmp.values())) 80 c['objects'] = myClass.objects.filter(**search) 81 m.append("I used the filter %s=%s" % (search.keys(), search.values())) 60 82 m.append( "Found %s objects of type %s" % (len(c['objects']), object_type)) 61 83 return render_to_response('objectbrowser/list_objects.html', c) … … 64 86 c = {} 65 87 c['object_types'] = t = [] 66 for i in Model.string_to_class.keys(): 67 t.append( i ) 88 for name,Class in Model.string_to_class.items(): 89 if name != None: 90 active = inactive = 0 91 all_instances = Class.objects.all 92 for i in all_instances: 93 if i['register'] == "0": 94 inactive += 1 95 else: 96 active += 1 97 c['object_types'].append( (name, active, inactive) ) 68 98 return render_to_response('objectbrowser/list_object_types.html', c) 69 99 … … 72 102 c['messages'] = m = [] 73 103 o = ObjectDefinition.objects.filter(id=object_id)[0] 104 #o = ObjectDefinition.objects.get_by_id(id=object_id) 74 105 c['my_object'] = o 75 106 c['attr_val'] = o.get_attribute_tuple() 76 107 return render_to_response('objectbrowser/view_object.html', c) 77 108 78 def get_services_without_service_description(self):79 c = {}80 s = Service.objects.filter(register=1, service_description=None)81 return render_to_response('objectbrowser/list_objects.html', c)82 83 def get_services_without_host_name(self):84 c = {}85 s = Service.objects.filter(register=1, host_name=None)86 return render_to_response('objectbrowser/list_objects.html', c)87 109 88 110 -
adagios/templates/configurator/base.html
r582de6e rf116422 38 38 Cool Searches: 39 39 <ul> 40 <li><a href="/objectbrowser/ ">Services With no service_description</a></li>41 <li><a href="/objectbrowser/ host">Services With no host_name</a></li>40 <li><a href="/objectbrowser/object_type=service/register=1/service_description=None">Services With no service_description</a></li> 41 <li><a href="/objectbrowser/object_type=service/register=1/host_name=None">Services With no host_name</a></li> 42 42 <li><a href="/objectbrowser/contact">Services that are not okconfig compatible</a></li> 43 43 </ul>
Note: See TracChangeset
for help on using the changeset viewer.
