Procházet zdrojové kódy

"fixed json response normalization"

ash před 2 roky
rodič
revize
720ee7f104

+ 1 - 4
Backend/Sources/Model/model_manager.py

@@ -113,13 +113,10 @@ def setModelItemAttributesFromJson(Item, JsonString):
 
 def ModelObjectToJsonString(object) -> str:
 
-
-
-
     json_string = json.dumps(object, cls=ComplexEncoder)
     json_dict : dict = json.loads(json_string)
     json_dict.pop("registry") # removing the registry item that comes from the sql alchemy type.
-    json_string = json.dumps(json_dict)
+    json_string = json.dumps(json_dict,indent=4)
 
     assert isinstance(json_string,str)
 

+ 30 - 0
Backend/Sources/Modules/Inventory/inventory.py

@@ -234,3 +234,33 @@ def get_all_inventory_groups() :
 
 def get_inventory_group(group_id) :
     return __getItem(group_id,inventory_group)
+
+
+
+
+## AGREGATION METHODS
+## method a bit smart to have processed data
+def get_inventory_group_items(group_id) :
+    with persistence.get_Session_Instance() as sess :
+        group : inventory_group = sess.query(inventory_group).filter(inventory_group.id == group_id).first()
+
+        return sess.query(inventory_item).filter(inventory_item.group_id == group.id)
+
+def get_inventory_site_items(site_id) :
+    with persistence.get_Session_Instance() as sess :
+        site : inventory_site = sess.query(inventory_site).filter(inventory_site.id == site_id).first()
+
+        return sess.query(inventory_item).filter(inventory_item.site_id == site.id)
+
+def get_inventory_contact_items(contact_id) :
+    with persistence.get_Session_Instance() as sess :
+        contact : inventory_contact = sess.query(inventory_contact).filter(inventory_contact.id == contact_id).first()
+
+        return sess.query(inventory_item).filter(inventory_item.contact_id == contact.id)
+
+
+def get_inventory_items_by_tag(str : str) :
+    #TODO get all tags
+    raise Exception("not implemented yet")
+    with persistence.get_Session_Instance() as sess :
+        return sess.query(inventory_contact).filter(inventory_contact.tags.contains(str))