Commit 4d71a257 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 6d38db62
...@@ -50,6 +50,9 @@ class SoftwareInstallation(Item, JSONType): ...@@ -50,6 +50,9 @@ class SoftwareInstallation(Item, JSONType):
, PropertySheet.JSONTypeConstraint , PropertySheet.JSONTypeConstraint
) )
def useRevision(self):
return getattr(self, "use_jio_api_revision", False)
security.declareProtected(Permissions.AccessContentsInformation, security.declareProtected(Permissions.AccessContentsInformation,
'asJSONText') 'asJSONText')
def asJSONText(self): def asJSONText(self):
...@@ -73,11 +76,15 @@ class SoftwareInstallation(Item, JSONType): ...@@ -73,11 +76,15 @@ class SoftwareInstallation(Item, JSONType):
"status_message": status_dict.get("text"), "status_message": status_dict.get("text"),
"portal_type": "Software Installation", "portal_type": "Software Installation",
} }
if self.useRevision():
web_section = self.getWebSectionValue() web_section = self.getWebSectionValue()
web_section = web_section.getRelativeUrl() if web_section else self.REQUEST.get("web_section_relative_url", None) web_section = web_section.getRelativeUrl() if web_section else self.REQUEST.get("web_section_relative_url", None)
if web_section: if web_section:
result["api_revision"] = self.getJIOAPIRevision(web_section) revision = self.getJIOAPIRevision(web_section)
result.update() if revision:
result["api_revision"] = revision
return json.dumps(result, indent=2) return json.dumps(result, indent=2)
def getSlapTimestamp(self): def getSlapTimestamp(self):
......
...@@ -414,7 +414,9 @@ class SoftwareInstance(Item, JSONType): ...@@ -414,7 +414,9 @@ class SoftwareInstance(Item, JSONType):
web_section = self.getWebSectionValue() web_section = self.getWebSectionValue()
web_section = web_section.getRelativeUrl() if web_section else self.REQUEST.get("web_section_relative_url", None) web_section = web_section.getRelativeUrl() if web_section else self.REQUEST.get("web_section_relative_url", None)
if web_section: 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', self.REQUEST.response.setHeader('Cache-Control',
'private, max-age=0, must-revalidate') '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