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))
|
||||
)
|
||||
|
||||
def apply(self, pg: Document):
|
||||
def apply(self, pg: Page):
|
||||
self.handle_creation(pg)
|
||||
self.handle_communication_status(pg)
|
||||
self.handle_targets(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()
|
||||
|
||||
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"):
|
||||
return
|
||||
self.set_first_responded_on(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():
|
||||
pg.first_responded_on = (
|
||||
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
|
||||
end_at = pg.first_responded_on
|
||||
if not start_at or not end_at:
|
||||
return
|
||||
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)
|
||||
|
||||
def set_response_by(self, pg: Document):
|
||||
def set_response_by(self, pg: Page):
|
||||
start_time = pg.sla_creation
|
||||
communication_status = pg.communication_status
|
||||
|
||||
@ -91,7 +91,7 @@ class CRMServiceLevelAgreement(Page):
|
||||
if 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)
|
||||
options = {
|
||||
"Fulfilled": True,
|
||||
@ -102,7 +102,7 @@ class CRMServiceLevelAgreement(Page):
|
||||
if options[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:
|
||||
return get_datetime(pg.response_by) < now_datetime()
|
||||
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 pypika import Criterion
|
||||
|
||||
def get_sla(pg: Document) -> Document:
|
||||
def get_sla(pg: Page) -> Page:
|
||||
"""
|
||||
Get Service Level Agreement for `pg`
|
||||
|
||||
@ -47,11 +47,11 @@ def get_sla(pg: Document) -> Document:
|
||||
break
|
||||
return res
|
||||
|
||||
def get_context(d: Document) -> dict:
|
||||
def get_context(d: Page) -> dict:
|
||||
"""
|
||||
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
|
||||
"""
|
||||
utils = get_safe_globals().get("jingrow").get("utils")
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user