Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
l y
Jumpserver
Commits
24793180
Commit
24793180
authored
2 years ago
by
feng626
Browse files
Options
Download
Email Patches
Plain Diff
feat: 工单审批人中去除申请人
parent
7eec5080
pr@dev@ticket
No related merge requests found
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
apps/acls/models/login_acl.py
+4
-2
apps/acls/models/login_acl.py
apps/acls/models/login_asset_acl.py
+1
-1
apps/acls/models/login_asset_acl.py
apps/assets/models/cmd_filter.py
+4
-2
apps/assets/models/cmd_filter.py
apps/tickets/api/ticket.py
+4
-3
apps/tickets/api/ticket.py
apps/tickets/models/ticket.py
+12
-3
apps/tickets/models/ticket.py
with
25 additions
and
11 deletions
+25
-11
apps/acls/models/login_acl.py
+
4
-
2
View file @
24793180
...
...
@@ -123,6 +123,8 @@ class LoginACL(BaseACL):
'org_id'
:
Organization
.
ROOT_ID
,
}
ticket
=
Ticket
.
objects
.
create
(
**
data
)
ticket
.
create_process_map_and_node
(
self
.
reviewers
.
all
())
ticket
.
open
(
self
.
user
)
applicant
=
self
.
user
assignees
=
self
.
reviewers
.
all
()
ticket
.
create_process_map_and_node
(
assignees
,
applicant
)
ticket
.
open
(
applicant
)
return
ticket
This diff is collapsed.
Click to expand it.
apps/acls/models/login_asset_acl.py
+
1
-
1
View file @
24793180
...
...
@@ -97,7 +97,7 @@ class LoginAssetACL(BaseACL, OrgModelMixin):
'org_id'
:
org_id
,
}
ticket
=
Ticket
.
objects
.
create
(
**
data
)
ticket
.
create_process_map_and_node
(
assignees
)
ticket
.
create_process_map_and_node
(
assignees
,
user
)
ticket
.
open
(
applicant
=
user
)
return
ticket
This diff is collapsed.
Click to expand it.
apps/assets/models/cmd_filter.py
+
4
-
2
View file @
24793180
...
...
@@ -181,8 +181,10 @@ class CommandFilterRule(OrgModelMixin):
'org_id'
:
org_id
,
}
ticket
=
Ticket
.
objects
.
create
(
**
data
)
ticket
.
create_process_map_and_node
(
self
.
reviewers
.
all
())
ticket
.
open
(
applicant
=
session
.
user_obj
)
applicant
=
session
.
user_obj
assignees
=
self
.
reviewers
.
all
()
ticket
.
create_process_map_and_node
(
assignees
,
applicant
)
ticket
.
open
(
applicant
)
return
ticket
@
classmethod
...
...
This diff is collapsed.
Click to expand it.
apps/tickets/api/ticket.py
+
4
-
3
View file @
24793180
...
...
@@ -53,9 +53,10 @@ class TicketViewSet(CommonApiMixin, viewsets.ModelViewSet):
def
perform_create
(
self
,
serializer
):
instance
=
serializer
.
save
()
instance
.
create_related_node
()
instance
.
process_map
=
instance
.
create_process_map
()
instance
.
open
(
applicant
=
self
.
request
.
user
)
applicant
=
self
.
request
.
user
instance
.
create_related_node
(
applicant
)
instance
.
process_map
=
instance
.
create_process_map
(
applicant
)
instance
.
open
(
applicant
)
@
action
(
detail
=
False
,
methods
=
[
POST
],
permission_classes
=
[
RBACPermission
,
])
def
open
(
self
,
request
,
*
args
,
**
kwargs
):
...
...
This diff is collapsed.
Click to expand it.
apps/tickets/models/ticket.py
+
12
-
3
View file @
24793180
...
...
@@ -188,22 +188,30 @@ class Ticket(CommonModelMixin, StatusMixin, OrgModelMixin):
.
exclude
(
state
=
ProcessStatus
.
notified
).
first
()
return
processor
.
assignee
if
processor
else
None
def
create_related_node
(
self
):
def
ignore_applicant
(
self
,
assignees
,
applicant
=
None
):
applicant
=
applicant
if
applicant
else
self
.
applicant
if
len
(
assignees
)
!=
1
:
assignees
=
set
(
assignees
)
-
{
applicant
,
}
return
list
(
assignees
)
def
create_related_node
(
self
,
applicant
=
None
):
org_id
=
self
.
flow
.
org_id
approval_rule
=
self
.
get_current_ticket_flow_approve
()
ticket_step
=
TicketStep
.
objects
.
create
(
ticket
=
self
,
level
=
self
.
approval_step
)
ticket_assignees
=
[]
assignees
=
approval_rule
.
get_assignees
(
org_id
=
org_id
)
assignees
=
self
.
ignore_applicant
(
assignees
,
applicant
)
for
assignee
in
assignees
:
ticket_assignees
.
append
(
TicketAssignee
(
step
=
ticket_step
,
assignee
=
assignee
))
TicketAssignee
.
objects
.
bulk_create
(
ticket_assignees
)
def
create_process_map
(
self
):
def
create_process_map
(
self
,
applicant
=
None
):
org_id
=
self
.
flow
.
org_id
approval_rules
=
self
.
flow
.
rules
.
order_by
(
'level'
)
nodes
=
list
()
for
node
in
approval_rules
:
assignees
=
node
.
get_assignees
(
org_id
=
org_id
)
assignees
=
self
.
ignore_applicant
(
assignees
,
applicant
)
assignee_ids
=
[
assignee
.
id
for
assignee
in
assignees
]
assignees_display
=
[
str
(
assignee
)
for
assignee
in
assignees
]
nodes
.
append
(
...
...
@@ -217,7 +225,8 @@ class Ticket(CommonModelMixin, StatusMixin, OrgModelMixin):
return
nodes
# TODO 兼容不存在流的工单
def
create_process_map_and_node
(
self
,
assignees
):
def
create_process_map_and_node
(
self
,
assignees
,
applicant
):
assignees
=
self
.
ignore_applicant
(
assignees
,
applicant
)
self
.
process_map
=
[{
'approval_level'
:
1
,
'state'
:
'notified'
,
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help