Ejemplo n.º 1
0
 def _bulk_field_is_builtin(self, data):
     """
     Apply is_builtin field
     :param data:
     :return:
     """
     builtins = Collection.get_builtins(self.json_collection)
     for x in data:
         u = x.get("uuid")
         x["is_builtin"] = u and u in builtins
     return data
Ejemplo n.º 2
0
 def report_html(self, request, result=None, query=None):
     builtins = Collection.get_builtins("fm.eventclassificationrules")
     r = ["["]
     r += [
         ",\n".join([
             indent(rr.to_json())
             for rr in EventClassificationRule.objects.order_by("name")
             if rr.uuid and smart_text(rr.uuid) not in builtins
         ])
     ]
     r += ["]", ""]
     return "<pre>" + escape("\n".join(r)) + "</pre>"
Ejemplo n.º 3
0
 def cleaned_query(self, q):
     q = q.copy()
     for p in self.ignored_params:
         if p in q:
             del q[p]
     for p in (
             self.limit_param,
             self.page_param,
             self.start_param,
             self.format_param,
             self.sort_param,
             self.query_param,
             self.only_param,
     ):
         if p in q:
             del q[p]
     # Extract IN
     # extjs not working with same parameter name in query
     for p in list(q.keys()):
         if p.endswith("__in") and self.rx_oper_splitter.match(p):
             field = self.rx_oper_splitter.match(p).group("field") + "__in"
             if field not in q:
                 q[field] = [q[p]]
             else:
                 q[field] += [q[p]]
             del q[p]
     # Normalize parameters
     for p in q:
         if p.endswith("__exists"):
             v = BooleanParameter().clean(q[p])
             q[p] = v
         elif p in self.clean_fields:
             q[p] = self.clean_fields[p].clean(q[p])
     # @todo: correct __ lookups
     if any(p for p in q if p.endswith("__referred")):
         del q[p]
     # builtin
     is_builtin = q.pop("is_builtin", None)
     if self.json_collection and is_builtin in ("true", "false"):
         builtins = [
             uuid.UUID(x)
             for x in Collection.get_builtins(self.json_collection)
         ]
         if is_builtin == "true":
             q["uuid__in"] = builtins
         else:
             q["uuid__nin"] = builtins
     return q