Commit a6012256 authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_jio: Inform user that his contract is disabled

      He can access it or open a ticket.
parent c86f24e3
Pipeline #11807 passed with stage
in 0 seconds
...@@ -21,10 +21,16 @@ ...@@ -21,10 +21,16 @@
}); });
function createAttentionPointTemplate(gadget, attention_point) { function createAttentionPointTemplate(gadget, attention_point) {
if (attention_point.link) { var page = "slap_controller", option_dict = {};
return gadget.getUrlFor({command: 'change', if (attention_point.link || attention_point.page) {
options: {jio_key: attention_point.link, if (attention_point.page) {
"page": "slap_controller"}}) page = attention_point.page;
}
option_dict.page = page;
if (attention_point.link) {
option_dict.jio_key = attention_point.link;
}
return gadget.getUrlFor({command: 'change', options: option_dict})
.push(function (link) { .push(function (link) {
return gadget.translateHtml(attention_point_item_template({ return gadget.translateHtml(attention_point_item_template({
option: [{ option: [{
...@@ -33,14 +39,13 @@ ...@@ -33,14 +39,13 @@
}] }]
})); }));
}); });
} else {
return gadget.translateHtml(attention_point_item_template({
option: [{
text: attention_point.text,
link: attention_point.link
}]
}));
} }
return gadget.translateHtml(attention_point_item_template({
option: [{
text: attention_point.text,
link: attention_point.link
}]
}));
} }
gadget_klass gadget_klass
////////////////////////////////////////////// //////////////////////////////////////////////
......
...@@ -142,116 +142,122 @@ ...@@ -142,116 +142,122 @@
</record> </record>
<record id="3" aka="AAAAAAAAAAM="> <record id="3" aka="AAAAAAAAAAM=">
<pickle> <pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/> <global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle> </pickle>
<pickle> <pickle>
<tuple> <dictionary>
<none/> <item>
<list> <key> <string>_log</string> </key>
<dictionary> <value>
<item> <list>
<key> <string>action</string> </key> <dictionary>
<value> <string>publish_alive</string> </value> <item>
</item> <key> <string>action</string> </key>
<item> <value> <string>publish_alive</string> </value>
<key> <string>actor</string> </key> </item>
<value> <string>zope</string> </value> <item>
</item> <key> <string>actor</string> </key>
<item> <value> <string>zope</string> </value>
<key> <string>comment</string> </key> </item>
<value> <string></string> </value> <item>
</item> <key> <string>comment</string> </key>
<item> <value> <string></string> </value>
<key> <string>error_message</string> </key> </item>
<value> <string></string> </value> <item>
</item> <key> <string>error_message</string> </key>
<item> <value> <string></string> </value>
<key> <string>time</string> </key> </item>
<value> <item>
<object> <key> <string>time</string> </key>
<klass> <value>
<global name="DateTime" module="DateTime.DateTime"/> <object>
</klass> <klass>
<tuple> <global name="DateTime" module="DateTime.DateTime"/>
<none/> </klass>
</tuple> <tuple>
<state> <none/>
<tuple> </tuple>
<float>1555594496.59</float> <state>
<string>UTC</string> <tuple>
</tuple> <float>1555594496.59</float>
</state> <string>UTC</string>
</object> </tuple>
</value> </state>
</item> </object>
<item> </value>
<key> <string>validation_state</string> </key> </item>
<value> <string>published_alive</string> </value> <item>
</item> <key> <string>validation_state</string> </key>
</dictionary> <value> <string>published_alive</string> </value>
</list> </item>
<none/> </dictionary>
</tuple> </list>
</value>
</item>
</dictionary>
</pickle> </pickle>
</record> </record>
<record id="4" aka="AAAAAAAAAAQ="> <record id="4" aka="AAAAAAAAAAQ=">
<pickle> <pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/> <global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle> </pickle>
<pickle> <pickle>
<tuple> <dictionary>
<none/> <item>
<list> <key> <string>_log</string> </key>
<dictionary> <value>
<item> <list>
<key> <string>action</string> </key> <dictionary>
<value> <string>edit</string> </value> <item>
</item> <key> <string>action</string> </key>
<item> <value> <string>edit</string> </value>
<key> <string>actor</string> </key> </item>
<value> <string>zope</string> </value> <item>
</item> <key> <string>actor</string> </key>
<item> <value> <string>zope</string> </value>
<key> <string>comment</string> </key> </item>
<value> <item>
<none/> <key> <string>comment</string> </key>
</value> <value>
</item> <none/>
<item> </value>
<key> <string>error_message</string> </key> </item>
<value> <string></string> </value> <item>
</item> <key> <string>error_message</string> </key>
<item> <value> <string></string> </value>
<key> <string>serial</string> </key> </item>
<value> <string>975.18542.14811.50363</string> </value> <item>
</item> <key> <string>serial</string> </key>
<item> <value> <string>987.9086.39006.59579</string> </value>
<key> <string>state</string> </key> </item>
<value> <string>current</string> </value> <item>
</item> <key> <string>state</string> </key>
<item> <value> <string>current</string> </value>
<key> <string>time</string> </key> </item>
<value> <item>
<object> <key> <string>time</string> </key>
<klass> <value>
<global name="DateTime" module="DateTime.DateTime"/> <object>
</klass> <klass>
<tuple> <global name="DateTime" module="DateTime.DateTime"/>
<none/> </klass>
</tuple> <tuple>
<state> <none/>
<tuple> </tuple>
<float>1556600431.66</float> <state>
<string>UTC</string> <tuple>
</tuple> <float>1602096464.77</float>
</state> <string>UTC</string>
</object> </tuple>
</value> </state>
</item> </object>
</dictionary> </value>
</list> </item>
<none/> </dictionary>
</tuple> </list>
</value>
</item>
</dictionary>
</pickle> </pickle>
</record> </record>
</ZopeData> </ZopeData>
...@@ -2,6 +2,8 @@ from json import dumps ...@@ -2,6 +2,8 @@ from json import dumps
attention_point_list = [] attention_point_list = []
portal = context.getPortalObject() portal = context.getPortalObject()
portal_type = context.getPortalType()
def addAttentionForTicket(ticket): def addAttentionForTicket(ticket):
msg = None msg = None
...@@ -18,9 +20,8 @@ def addAttentionForTicket(ticket): ...@@ -18,9 +20,8 @@ def addAttentionForTicket(ticket):
if msg: if msg:
return {"text": msg, "link": ticket.getRelativeUrl()} return {"text": msg, "link": ticket.getRelativeUrl()}
# Display unresponded tickets on services or servers # Display unresponded tickets on services or servers
if context.getPortalType() in ["Hosting Subscription", "Computer"]: if portal_type in ["Hosting Subscription", "Computer"]:
simulation_state = ["suspended", "confirmed"] simulation_state = ["suspended", "confirmed"]
for ticket in context.Base_getOpenRelatedTicketList( for ticket in context.Base_getOpenRelatedTicketList(
limit=3, simulation_state=simulation_state): limit=3, simulation_state=simulation_state):
...@@ -30,7 +31,7 @@ if context.getPortalType() in ["Hosting Subscription", "Computer"]: ...@@ -30,7 +31,7 @@ if context.getPortalType() in ["Hosting Subscription", "Computer"]:
# This is a limitation of the API that will consider that all tickets # This is a limitation of the API that will consider that all tickets
# Are from this module # Are from this module
if context.getPortalType() in ["Support Request Module"]: if portal_type in ["Support Request Module"]:
simulation_state = ["suspended", "confirmed"] simulation_state = ["suspended", "confirmed"]
person = portal.portal_membership.getAuthenticatedMember().getUserValue() person = portal.portal_membership.getAuthenticatedMember().getUserValue()
for ticket in portal.portal_catalog( for ticket in portal.portal_catalog(
...@@ -41,5 +42,22 @@ if context.getPortalType() in ["Support Request Module"]: ...@@ -41,5 +42,22 @@ if context.getPortalType() in ["Support Request Module"]:
entry = addAttentionForTicket(ticket) entry = addAttentionForTicket(ticket)
if entry is not None: if entry is not None:
attention_point_list.append(entry) attention_point_list.append(entry)
if portal_type in ["Hosting Subscription Module", "Hosting Subscription", "Person"]:
person = portal.portal_membership.getAuthenticatedMember().getUserValue()
contract = portal.portal_catalog.getResultValue(
portal_type="Cloud Contract",
default_destination_section_uid=person.getUid(),
validation_state=['invalidated', 'validated'],
)
if contract is None:
msg = context.Base_translateString(
"Your Contract is Desactivated")
attention_point_list.append({"text": msg, 'page': "slap_ticket_list"})
elif contract.getValidationState() == "invalidated":
msg = context.Base_translateString(
"Your Contract is Desactivated")
attention_point_list.append({"text": msg, "link": contract.getRelativeUrl()})
return dumps(attention_point_list) return dumps(attention_point_list)
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