feat: base ticketmixin传入other_data
This commit is contained in:
parent
aa15a48cf5
commit
9cb0c5c681
|
|
@ -13,7 +13,6 @@ class TicketMixin:
|
||||||
workflow_key = None
|
workflow_key = None
|
||||||
ticket_auto_submit_on_update = True
|
ticket_auto_submit_on_update = True
|
||||||
ticket_auto_submit_on_create = True
|
ticket_auto_submit_on_create = True
|
||||||
ticket_data_save_fields = []
|
|
||||||
|
|
||||||
def get_workflow_key(self, instance):
|
def get_workflow_key(self, instance):
|
||||||
return self.workflow_key
|
return self.workflow_key
|
||||||
|
|
@ -21,18 +20,14 @@ class TicketMixin:
|
||||||
def should_create_ticket(self, instance):
|
def should_create_ticket(self, instance):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
def gen_other_ticket_data(self, instance):
|
||||||
|
return {}
|
||||||
|
|
||||||
def gen_ticket_data(self, instance):
|
def gen_ticket_data(self, instance):
|
||||||
ticket_data = {"t_model": instance.__class__.__name__, "t_id": str(instance.id)}
|
ticket_data = {"t_model": instance.__class__.__name__, "t_id": str(instance.id)}
|
||||||
if self.ticket_data_save_fields:
|
other_data = self.gen_other_ticket_data(instance)
|
||||||
for field in self.ticket_data_save_fields:
|
if other_data:
|
||||||
if '.' in field:
|
ticket_data.update(other_data)
|
||||||
attr_list = field.split('.')
|
|
||||||
expr = instance
|
|
||||||
for a in attr_list:
|
|
||||||
expr = getattr(expr, a)
|
|
||||||
ticket_data[field] = expr
|
|
||||||
else:
|
|
||||||
ticket_data[field] = getattr(instance, field)
|
|
||||||
return ticket_data
|
return ticket_data
|
||||||
|
|
||||||
def perform_update(self, serializer):
|
def perform_update(self, serializer):
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue