[views] fix json dumps: add data in the correct format and only if available
authorPaul Tonelli <paul.tonelli@logilab.fr>
Wed, 02 Apr 2014 11:35:07 +0200
changeset 1483 d3587ade9829
parent 1482 36756b6d7fcc
child 1484 05ddb62b92b4
[views] fix json dumps: add data in the correct format and only if available
entities.py
--- a/entities.py	Wed Apr 23 12:22:19 2014 +0200
+++ b/entities.py	Wed Apr 02 11:35:07 2014 +0200
@@ -204,7 +204,8 @@
     def __json_encode__(self):
         data = super(ProjectEnvironment, self).__json_encode__()
         data['apycot_process_environment'] = self.apycot_process_environment()
-        data['repository'] = self.repository
+        if self.repository:
+            data['repository'] = self.repository.__json_encode__()
         data['apycot_configuration'] = self.apycot_configuration()
         return data
 
@@ -466,8 +467,10 @@
 
     def __json_encode__(self):
         data = super(TestExecution, self).__json_encode__()
-        data['environment'] = self.environment
-        data['configuration'] = self.configuration
+        if self.environment:
+            data['environment'] = self.environment.__json_encode__()
+        if self.configuration:
+            data['configuration'] = self.configuration.__json_encode__()
         return data
 
 class CheckResult(AnyEntity):