Skip to content

Commit

Permalink
show step counter in request list
Browse files Browse the repository at this point in the history
  • Loading branch information
Sispheor committed Sep 19, 2023
1 parent 319c4d2 commit 4f9289c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
6 changes: 6 additions & 0 deletions service_catalog/tables/request_tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,11 @@ def render_id(self, value, record):

def render_state(self, record, value):
from service_catalog.views import map_request_state
if record.approval_workflow_state is not None and record.approval_workflow_state.current_step is not None:
position = record.approval_workflow_state.current_step.approval_step.position
number_of_steps = record.approval_workflow_state.approval_step_states.count()
return format_html(
f'<a href="{record.get_absolute_url()}"><strong class="text-{map_request_state(record.state)}">{value} ({position}/{number_of_steps})</strong></a>')

return format_html(
f'<a href="{record.get_absolute_url()}"><strong class="text-{map_request_state(record.state)}">{value}</strong></a>')
4 changes: 3 additions & 1 deletion service_catalog/views/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ def get_queryset(self):
return Request.get_queryset_for_user(
self.request.user, 'service_catalog.view_request'
).prefetch_related(
"user", "operation", "instance__requester", "instance__quota_scope", "instance__service", "operation__service"
"user", "operation", "instance__requester", "instance__quota_scope", "instance__service",
"operation__service", "approval_workflow_state", "approval_workflow_state__current_step",
"approval_workflow_state__current_step__approval_step", "approval_workflow_state__approval_step_states"
).exclude(state=RequestState.ARCHIVED)

def get_context_data(self, **kwargs):
Expand Down

0 comments on commit 4f9289c

Please sign in to comment.