Document重命名为Page
This commit is contained in:
parent
f0ad4d5172
commit
c1cec5b6da
@ -46,38 +46,38 @@ class CRMServiceLevelAgreement(Page):
|
|||||||
_("The Condition '{0}' is invalid: {1}").format(self.condition, str(e))
|
_("The Condition '{0}' is invalid: {1}").format(self.condition, str(e))
|
||||||
)
|
)
|
||||||
|
|
||||||
def apply(self, pg: Document):
|
def apply(self, pg: Page):
|
||||||
self.handle_creation(pg)
|
self.handle_creation(pg)
|
||||||
self.handle_communication_status(pg)
|
self.handle_communication_status(pg)
|
||||||
self.handle_targets(pg)
|
self.handle_targets(pg)
|
||||||
self.handle_sla_status(pg)
|
self.handle_sla_status(pg)
|
||||||
|
|
||||||
def handle_creation(self, pg: Document):
|
def handle_creation(self, pg: Page):
|
||||||
pg.sla_creation = pg.sla_creation or now_datetime()
|
pg.sla_creation = pg.sla_creation or now_datetime()
|
||||||
|
|
||||||
def handle_communication_status(self, pg: Document):
|
def handle_communication_status(self, pg: Page):
|
||||||
if pg.is_new() or not pg.has_value_changed("communication_status"):
|
if pg.is_new() or not pg.has_value_changed("communication_status"):
|
||||||
return
|
return
|
||||||
self.set_first_responded_on(pg)
|
self.set_first_responded_on(pg)
|
||||||
self.set_first_response_time(pg)
|
self.set_first_response_time(pg)
|
||||||
|
|
||||||
def set_first_responded_on(self, pg: Document):
|
def set_first_responded_on(self, pg: Page):
|
||||||
if pg.communication_status != self.get_default_priority():
|
if pg.communication_status != self.get_default_priority():
|
||||||
pg.first_responded_on = (
|
pg.first_responded_on = (
|
||||||
pg.first_responded_on or now_datetime()
|
pg.first_responded_on or now_datetime()
|
||||||
)
|
)
|
||||||
|
|
||||||
def set_first_response_time(self, pg: Document):
|
def set_first_response_time(self, pg: Page):
|
||||||
start_at = pg.sla_creation
|
start_at = pg.sla_creation
|
||||||
end_at = pg.first_responded_on
|
end_at = pg.first_responded_on
|
||||||
if not start_at or not end_at:
|
if not start_at or not end_at:
|
||||||
return
|
return
|
||||||
pg.first_response_time = self.calc_elapsed_time(start_at, end_at)
|
pg.first_response_time = self.calc_elapsed_time(start_at, end_at)
|
||||||
|
|
||||||
def handle_targets(self, pg: Document):
|
def handle_targets(self, pg: Page):
|
||||||
self.set_response_by(pg)
|
self.set_response_by(pg)
|
||||||
|
|
||||||
def set_response_by(self, pg: Document):
|
def set_response_by(self, pg: Page):
|
||||||
start_time = pg.sla_creation
|
start_time = pg.sla_creation
|
||||||
communication_status = pg.communication_status
|
communication_status = pg.communication_status
|
||||||
|
|
||||||
@ -91,7 +91,7 @@ class CRMServiceLevelAgreement(Page):
|
|||||||
if end_time:
|
if end_time:
|
||||||
pg.response_by = end_time
|
pg.response_by = end_time
|
||||||
|
|
||||||
def handle_sla_status(self, pg: Document):
|
def handle_sla_status(self, pg: Page):
|
||||||
is_failed = self.is_first_response_failed(pg)
|
is_failed = self.is_first_response_failed(pg)
|
||||||
options = {
|
options = {
|
||||||
"Fulfilled": True,
|
"Fulfilled": True,
|
||||||
@ -102,7 +102,7 @@ class CRMServiceLevelAgreement(Page):
|
|||||||
if options[status]:
|
if options[status]:
|
||||||
pg.sla_status = status
|
pg.sla_status = status
|
||||||
|
|
||||||
def is_first_response_failed(self, pg: Document):
|
def is_first_response_failed(self, pg: Page):
|
||||||
if not pg.first_responded_on:
|
if not pg.first_responded_on:
|
||||||
return get_datetime(pg.response_by) < now_datetime()
|
return get_datetime(pg.response_by) < now_datetime()
|
||||||
return get_datetime(pg.response_by) < get_datetime(pg.first_responded_on)
|
return get_datetime(pg.response_by) < get_datetime(pg.first_responded_on)
|
||||||
|
|||||||
@ -5,7 +5,7 @@ from jingrow.utils.safe_exec import get_safe_globals
|
|||||||
from jingrow.utils import now_datetime
|
from jingrow.utils import now_datetime
|
||||||
from pypika import Criterion
|
from pypika import Criterion
|
||||||
|
|
||||||
def get_sla(pg: Document) -> Document:
|
def get_sla(pg: Page) -> Page:
|
||||||
"""
|
"""
|
||||||
Get Service Level Agreement for `pg`
|
Get Service Level Agreement for `pg`
|
||||||
|
|
||||||
@ -47,11 +47,11 @@ def get_sla(pg: Document) -> Document:
|
|||||||
break
|
break
|
||||||
return res
|
return res
|
||||||
|
|
||||||
def get_context(d: Document) -> dict:
|
def get_context(d: Page) -> dict:
|
||||||
"""
|
"""
|
||||||
Get safe context for `safe_eval`
|
Get safe context for `safe_eval`
|
||||||
|
|
||||||
:param pg: `Document` to add in context
|
:param pg: `Page` to add in context
|
||||||
:return: Context with `pg` and safe variables
|
:return: Context with `pg` and safe variables
|
||||||
"""
|
"""
|
||||||
utils = get_safe_globals().get("jingrow").get("utils")
|
utils = get_safe_globals().get("jingrow").get("utils")
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user