helper recursice data fetch
This commit is contained in:
@@ -4,10 +4,15 @@ from re import T
|
||||
from bson.json_util import loads
|
||||
from mongoengine import *
|
||||
|
||||
from .enumeration import BitumenCategoryEnum
|
||||
from .norm_specification import DeliveryGrain, EnumerateBase
|
||||
from .norm_documents import NormDocumentAggregate, NormDocumentBitumen, NormDocumentAsphalt
|
||||
from paveit.helper import fetch_recursive, mongo_to_dict
|
||||
|
||||
from .enumeration import BitumenCategoryEnum
|
||||
from .norm_documents import (
|
||||
NormDocumentAggregate,
|
||||
NormDocumentAsphalt,
|
||||
NormDocumentBitumen,
|
||||
)
|
||||
from .norm_specification import DeliveryGrain, EnumerateBase
|
||||
from .project import Project
|
||||
from .usermanagement import Organisation, User
|
||||
|
||||
@@ -36,25 +41,11 @@ class Material(Document):
|
||||
|
||||
def to_dict(self):
|
||||
# convert data to dict
|
||||
data = self.to_mongo().to_dict()
|
||||
|
||||
# Laden und hinzufügen der referenzierten Daten
|
||||
try:
|
||||
data['parameter'] = self.parameter.to_mongo().to_dict()
|
||||
except:
|
||||
pass
|
||||
|
||||
try:
|
||||
norm = self.norm.fetch() # Trigger the dereferencing
|
||||
data['norm'] = norm.to_mongo().to_dict()
|
||||
except:
|
||||
raise
|
||||
|
||||
data = fetch_recursive(self)
|
||||
data = mongo_to_dict(data)
|
||||
|
||||
return data
|
||||
|
||||
|
||||
|
||||
|
||||
meta = {
|
||||
'allow_inheritance': True,
|
||||
'index_opts': {},
|
||||
|
||||
Reference in New Issue
Block a user