Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Workflow tab in Operation #680

Merged
merged 2 commits into from
Sep 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 0 additions & 57 deletions docs/manual/service_catalog/operation.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,60 +62,3 @@ flowchart LR
**Default inventory ID** field is expecting an integer that correspond the the inventory ID in RHAAP/AWX.

**Default credential IDs** field is expecting a comma separated list of integer that correspond existings credentials ID in RHAAP/AWX.


## Survey

The survey of an operation can be edited to change the behavior of the generated form of a request.

!!! note

Surveys in Squest are actually surveys attached to each job templates in your RHAAP/AWX.
Squest can only disable the ones that you don't want to be filled by your end users.
Those fields, if declared as mandatory on RHAAP/AWX, will need to be filled anyway by the admin when approving a request.

### Is customer field

A **customer field** is a field that will be displayed into the end user survey.
By default, all fields are enabled when creating a new operation.

!!! note

If the field is set as **required** into the RHAAP/AWX job template survey config then the administrator
will have to fill it in any case during the review of the request.

### Default value


When set, the default value is pre-filled into the final form. It takes precedence over the default value set in RHAAP/AWX job template survey config.

Default value precedence:

```mermaid
flowchart LR
RHAAP/AWX(Default from RHAAP/AWX) --> squest(Default from Squest value) --> User(User's input) --> Admin(Admin's input)
```

!!! note

When used with a 'multiple select' or 'multiple select multiple' type of field, the value need to be a valid one from the RHAAP/AWX survey field options.

**Jinja templating**

Jinja templating can be used in the default value based on the current `{{ instance }}` and `{{ user }}` objects as context.
Examples can be retrieved in the [dedicated documentation section](../advanced/jinja.md).

Full `instance` and `user `object definition can be retrieved through the [API documentation](../../administration/api.md).

### Validators

Field validators are python modules that can be added as plugin to perform a custom check on a form field.
See related [documentation here](../advanced/validators.md).


### Attribute definition

Each field can be linked to an _Attribute definition_ from the resource tracking. This allows to automatically limit the field value to a [quota](../access.md#quota).
The available quota is shown in the form of the request so the end user know what he can still consume.

![survey_quota](../../images/survey_quota.png)
61 changes: 61 additions & 0 deletions docs/manual/service_catalog/survey.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Survey

The survey of an operation in Squest is actually the one configured in the RHAAP/AWX job templates.

Squest administrator can select which fields will be exposed to the end users when requesting a service or a day 2 operation.

By default, the approval workflow is composed of 2 steps:

- Customer form (fields noted as 'customer field')
- Admin form (All fields of the job template)

If more steps are needed, you can create a dedicated [approval workflow](../administration/approval_workflow.md).


## Is customer field

A **customer field** is a field that will be displayed into the end user survey.
By default, all fields are enabled when creating a new operation.

Fields that are not **customer fields** can be filled by any users who have the **accept_request** permission.

!!! note

If the field is set as **required** into the RHAAP/AWX job template survey config then the administrator
will have to fill it in any case during the review of the request.

## Default value


When set, the default value is pre-filled into the final form. It takes precedence over the default value set in RHAAP/AWX job template survey config.

Default value precedence:

```mermaid
flowchart LR
RHAAP/AWX(Default from RHAAP/AWX) --> squest(Default from Squest value) --> User(User's input) --> Admin(Admin's input)
```

!!! note

When used with a 'multiple select' or 'multiple select multiple' type of field, the value need to be a valid one from the RHAAP/AWX survey field options.

**Jinja templating**

Jinja templating can be used in the default value based on the current `{{ instance }}` and `{{ user }}` objects as context.
Examples can be retrieved in the [dedicated documentation section](../advanced/jinja.md).

Full `instance` and `user `object definition can be retrieved through the [API documentation](../../administration/api.md).

## Validators

Field validators are python modules that can be added as plugin to perform a custom check on a form field.
See related [documentation here](../advanced/validators.md).


## Attribute definition

Each field can be linked to an _Attribute definition_ from the resource tracking. This allows to automatically limit the field value to a [quota](../access.md#quota).
The available quota is shown in the form of the request so the end user know what he can still consume.

![survey_quota](../../images/survey_quota.png)
1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ nav:
- Concept: manual/service_catalog/concept.md
- Service: manual/service_catalog/service.md
- Operation: manual/service_catalog/operation.md
- Survey: manual/service_catalog/survey.md
- Resource tracking:
- Concept: manual/resource_tracking/concept.md
- Attribute: manual/resource_tracking/attributes.md
Expand Down
19 changes: 19 additions & 0 deletions service_catalog/migrations/0027_alter_approvalworkflow_scopes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Generated by Django 3.2.13 on 2023-09-22 12:42

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('profiles', '0019_alter_quota_options'),
('service_catalog', '0026_auto_20230919_1353'),
]

operations = [
migrations.AlterField(
model_name='approvalworkflow',
name='scopes',
field=models.ManyToManyField(blank=True, help_text='This workflow will be triggered for the following scopes. Leave empty to trigger for all scopes', related_name='approval_workflows', to='profiles.Scope', verbose_name='Restricted scopes'),
),
]
3 changes: 2 additions & 1 deletion service_catalog/models/approval_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ class ApprovalWorkflow(SquestModel):
'profiles.Scope',
related_name='approval_workflows',
blank=True,
verbose_name="Restricted scopes"
verbose_name="Restricted scopes",
help_text="This workflow will be triggered for the following scopes. Leave empty to trigger for all scopes"
)

@property
Expand Down
5 changes: 4 additions & 1 deletion service_catalog/views/operation.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
from Squest.utils.squest_views import *
from service_catalog.filters.operation_filter import OperationFilter, OperationFilterLimited
from service_catalog.forms import ServiceOperationForm
from service_catalog.models import Operation, Service, OperationType
from service_catalog.models import Operation, Service, OperationType, ApprovalWorkflow
from service_catalog.tables.approval_workflow_table import ApprovalWorkflowTable
from service_catalog.tables.operation_tables import OperationTable, CreateOperationTable


Expand Down Expand Up @@ -82,6 +83,8 @@ def get_context_data(self, **kwargs):
}
]
context['extra_html_button_path'] = "service_catalog/buttons/operation_survey_button.html"
if self.request.user.has_perm('service_catalog.view_approvalworkflow'):
context['workflows_table'] = ApprovalWorkflowTable(ApprovalWorkflow.objects.filter(operation=self.get_object()),exclude=['operation'])
return context


Expand Down
10 changes: 10 additions & 0 deletions templates/service_catalog/operation_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
{% include 'service_catalog/buttons/delete_operation_button.html' %}
{% endblock %}
{% block main %}
{% load django_tables2 %}
<div class="container-fluid">
<div class="row">
<section class="col-lg-3">
Expand Down Expand Up @@ -57,13 +58,22 @@ <h3 class="card-title">Details</h3>
<ul class="nav nav-pills squest-default-active" id="tabs">
<li class="nav-item"><a class="nav-link" href="#extra_vars" data-toggle="tab">Extra vars</a>
</li>
{% if workflows_table %}
<li class="nav-item"><a class="nav-link" href="#workflows"
data-toggle="tab">Workflows</a></li>
{% endif %}
</ul>
</div>
<div class="card-body">
<div class="tab-content">
<div class="tab-pane" id="extra_vars">
<pre><code class="language-json">{{ object.extra_vars | pretty_json }}</code></pre>
</div>
{% if workflows_table %}
<div class="tab-pane" id="workflows">
{% render_table workflows_table %}
</div>
{% endif %}
</div>
</div>
</div>
Expand Down
Loading