def read(self, request, path=None): if not path: return ConfigurationItem.objects.filter(is_active=True) # As the path might contain %20 instead of ' ' dequote it # and also add in the original slash path = '/Devices/%s' % urllib.unquote(path) logging.debug('In API module, path=%s' % path) s = get_schema_for_ci(ci_path=path) try: initial_ci = ConfigurationItem.objects.get(path=path) except ConfigurationItem.DoesNotExist: return rc.NOT_HERE if initial_ci.is_container: ci = eval('''%s.objects.filter(path__startswith='%s')''' % (s.class_name, path)) logging.debug('ci = %s' % ci) return ci else: ci = eval('''%s.objects.get(path__startswith='%s')''' % (s.class_name, path)) if user_allowed_to_view_ci(request.user, ci): return ci else: return rc.FORBIDDEN
def read(self, request, path=None): if not path: return ConfigurationItem.objects.filter(is_active=True) # As the path might contain %20 instead of ' ' dequote it # and also add in the original slash path = '/Devices/%s' % urllib.unquote(path) logging.debug('In API module, path=%s' % path) s = get_schema_for_ci(ci_path=path) try: initial_ci = ConfigurationItem.objects.get(path=path) except ConfigurationItem.DoesNotExist: return rc.NOT_HERE if initial_ci.is_container: ci = eval('''%s.objects.filter(path__startswith='%s')''' % ( s.class_name, path )) logging.debug('ci = %s' % ci) return ci else: ci = eval('''%s.objects.get(path__startswith='%s')''' % ( s.class_name, path )) if user_allowed_to_view_ci(request.user, ci): return ci else: return rc.FORBIDDEN
def add_ci(request): if request.method == "GET": ci_path = request.GET.get("path") logging.debug("""Adding CI under %s""" % ci_path) schema = get_schema_for_ci(ci_path=ci_path) form = eval(schema.form_name)() return render_to_response(schema.add_template, locals(), context_instance=RequestContext(request)) if request.method == "POST": # Add object pass
def add_ci(request): if request.method == 'GET': ci_path = request.GET.get('path') logging.debug('''Adding CI under %s''' % ci_path) schema = get_schema_for_ci(ci_path=ci_path) form = eval(schema.form_name)() return render_to_response(schema.add_template, locals(), context_instance=RequestContext(request)) if request.method == 'POST': # Add object pass
def view_ci(request, ci_path): as_json = request.POST.get("as_json") ci_path = prefix_slash(ci_path) # Is user allowed to view this CI? schema = get_schema_for_ci(ci_path=ci_path) try: ci = eval("""%s.objects.get(path='%s')""" % (schema.class_name, ci_path)) except: ci = False if ci: return render_to_response(schema.view_template, locals(), context_instance=RequestContext(request)) else: handle_404_error(ci_path)
def view_ci(request, ci_path): as_json = request.POST.get('as_json') ci_path = prefix_slash(ci_path) # Is user allowed to view this CI? schema = get_schema_for_ci(ci_path=ci_path) try: ci = eval('''%s.objects.get(path='%s')''' % (schema.class_name, ci_path)) except: ci = False if ci: return render_to_response(schema.view_template, locals(), context_instance=RequestContext(request)) else: handle_404_error(ci_path)