Commit 75e45246 authored by Cédric Le Ninivin's avatar Cédric Le Ninivin

slapos_cloud: Only add api_revision to JSON Data when defined

parent 47ae7595
...@@ -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",
} }
web_section = self.getWebSectionValue()
web_section = web_section.getRelativeUrl() if web_section else self.REQUEST.get("web_section_relative_url", None) if self.useRevision():
if web_section: web_section = self.getWebSectionValue()
result["api_revision"] = self.getJIOAPIRevision(web_section) web_section = web_section.getRelativeUrl() if web_section else self.REQUEST.get("web_section_relative_url", None)
result.update() if web_section:
revision = self.getJIOAPIRevision(web_section)
if revision:
result["api_revision"] = revision
return json.dumps(result, indent=2) return json.dumps(result, indent=2)
def getSlapTimestamp(self): def getSlapTimestamp(self):
......
...@@ -413,7 +413,9 @@ class SoftwareInstance(Item, JSONType): ...@@ -413,7 +413,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