mirror of https://github.com/jumpserver/jumpserver
fix(tickets): 工单申请资产授权通过人显示不对
parent
70a8db895d
commit
6b2f606430
|
@ -104,6 +104,9 @@ class RequestAssetPermTicketViewSet(JMSModelViewSet):
|
||||||
if system_users is None:
|
if system_users is None:
|
||||||
raise ConfirmedSystemUserChanged(detail=_('Confirmed system-users changed'))
|
raise ConfirmedSystemUserChanged(detail=_('Confirmed system-users changed'))
|
||||||
|
|
||||||
|
instance.perform_action(instance.ACTION.APPROVE,
|
||||||
|
request.user,
|
||||||
|
self._get_extra_comment(instance))
|
||||||
self._create_asset_permission(instance, assets, system_users)
|
self._create_asset_permission(instance, assets, system_users)
|
||||||
return Response({'detail': _('Succeed')})
|
return Response({'detail': _('Succeed')})
|
||||||
|
|
||||||
|
@ -116,14 +119,13 @@ class RequestAssetPermTicketViewSet(JMSModelViewSet):
|
||||||
|
|
||||||
def _create_asset_permission(self, instance: Ticket, assets, system_users):
|
def _create_asset_permission(self, instance: Ticket, assets, system_users):
|
||||||
meta = instance.meta
|
meta = instance.meta
|
||||||
request = self.request
|
|
||||||
actions = meta.get('actions', Action.CONNECT)
|
actions = meta.get('actions', Action.CONNECT)
|
||||||
|
|
||||||
ap_kwargs = {
|
ap_kwargs = {
|
||||||
'name': _('From request ticket: {} {}').format(instance.user_display, instance.id),
|
'name': _('From request ticket: {} {}').format(instance.user_display, instance.id),
|
||||||
'created_by': self.request.user.username,
|
'created_by': self.request.user.username,
|
||||||
'comment': _('{} request assets, approved by {}').format(instance.user_display,
|
'comment': _('{} request assets, approved by {}').format(instance.user_display,
|
||||||
instance.assignees_display),
|
instance.assignee_display),
|
||||||
'actions': actions,
|
'actions': actions,
|
||||||
}
|
}
|
||||||
date_start = dt_parser(meta.get('date_start'))
|
date_start = dt_parser(meta.get('date_start'))
|
||||||
|
@ -132,9 +134,7 @@ class RequestAssetPermTicketViewSet(JMSModelViewSet):
|
||||||
ap_kwargs['date_start'] = date_start
|
ap_kwargs['date_start'] = date_start
|
||||||
if date_expired:
|
if date_expired:
|
||||||
ap_kwargs['date_expired'] = date_expired
|
ap_kwargs['date_expired'] = date_expired
|
||||||
instance.perform_action(instance.ACTION.APPROVE,
|
|
||||||
request.user,
|
|
||||||
self._get_extra_comment(instance))
|
|
||||||
ap = AssetPermission.objects.create(**ap_kwargs)
|
ap = AssetPermission.objects.create(**ap_kwargs)
|
||||||
ap.system_users.add(*system_users)
|
ap.system_users.add(*system_users)
|
||||||
ap.assets.add(*assets)
|
ap.assets.add(*assets)
|
||||||
|
|
Loading…
Reference in New Issue