Commit fb6bde41 authored by Cédric Le Ninivin's avatar Cédric Le Ninivin Committed by Romain Courteaud

slapos_cloud: Only add api_revision to JSON Data when defined

parent cf633c0a
......@@ -50,6 +50,9 @@ class SoftwareInstallation(Item, JSONType):
, PropertySheet.JSONTypeConstraint
)
def useRevision(self):
return getattr(self, "use_jio_api_revision", False)
security.declareProtected(Permissions.AccessContentsInformation,
'asJSONText')
def asJSONText(self):
......@@ -73,11 +76,15 @@ class SoftwareInstallation(Item, JSONType):
"status_message": status_dict.get("text"),
"portal_type": "Software Installation",
}
web_section = self.getWebSectionValue()
web_section = web_section.getRelativeUrl() if web_section else self.REQUEST.get("web_section_relative_url", None)
if web_section:
result["api_revision"] = self.getJIOAPIRevision(web_section)
result.update()
if self.useRevision():
web_section = self.getWebSectionValue()
web_section = web_section.getRelativeUrl() if web_section else self.REQUEST.get("web_section_relative_url", None)
if web_section:
revision = self.getJIOAPIRevision(web_section)
if revision:
result["api_revision"] = revision
return json.dumps(result, indent=2)
def getSlapTimestamp(self):
......
......@@ -414,7 +414,9 @@ class SoftwareInstance(Item, JSONType):
web_section = self.getWebSectionValue()
web_section = web_section.getRelativeUrl() if web_section else self.REQUEST.get("web_section_relative_url", None)
if web_section:
result["api_revision"] = self.getJIOAPIRevision(web_section)
revision = self.getJIOAPIRevision(web_section)
if revision:
result["api_revision"] = revision
self.REQUEST.response.setHeader('Cache-Control',
'private, max-age=0, must-revalidate')
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment