Skip to content

Commit

Permalink
add back doc aside a new request
Browse files Browse the repository at this point in the history
  • Loading branch information
Sispheor committed Sep 5, 2023
1 parent c27e6a2 commit 5385dac
Show file tree
Hide file tree
Showing 4 changed files with 100 additions and 81 deletions.
9 changes: 8 additions & 1 deletion service_catalog/views/catalog_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from Squest.utils.squest_rbac import SquestPermissionRequiredMixin
from profiles.models import Scope
from service_catalog.models import Service, OperationType, Instance, Operation, Request, RequestMessage
from service_catalog.models import Service, OperationType, Doc


class ServiceRequestWizardView(SquestPermissionRequiredMixin, SessionWizardView):
Expand All @@ -21,6 +21,13 @@ def get_permission_required(self):
if not self.operation.is_admin_operation:
return 'service_catalog.request_on_service'

def get_context_data(self, form, **kwargs):
context = super().get_context_data(form=form, **kwargs)
if self.steps.current == '1':
docs = Doc.objects.filter(operations__in=[self.operation])
context.update({'docs': docs})
return context

def get_form_kwargs(self, step):
kwargs = super().get_form_kwargs()
kwargs.update({'user': self.request.user})
Expand Down
26 changes: 26 additions & 0 deletions templates/generics/doc_aside.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{% has_perm request.user "service_catalog.view_doc" as can_view_doc %}
{% if can_view_doc %}
{% load martortags %}
{% for doc in docs %}
<div class="card">
<div class="card-header">
<h3 class="card-title">
<i class="fas fa-info"></i> {{ doc.title }}
</h3>
{% if request.user.is_staff %}
<div class="card-tools">
<a href="{% url 'admin:service_catalog_doc_change' doc.id %}"
class="btn btn-default btn-sm">
<i class="far fa-edit"></i>
</a>
</div>
{% endif %}
</div>
<div class="card-body p-0">
<div class="martor-preview{% if request.user.profile.theme == "dark" %} bg-dark{% endif %}">
{{ doc.content|safe_markdown }}
</div>
</div>
</div>
{% endfor %}
{% endif %}
23 changes: 1 addition & 22 deletions templates/service_catalog/customer/generic_list_with_docs.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,28 +18,7 @@
</div>
</div>
<div class="col-6">
{% for doc in docs %}
<div class="card">
<div class="card-header">
<h3 class="card-title">
<i class="fas fa-info"></i> {{ doc.title }}
</h3>
{% if request.user.is_staff %}
<div class="card-tools">
<a href="{% url 'admin:service_catalog_doc_change' doc.id %}"
class="btn btn-default btn-sm">
<i class="far fa-edit"></i>
</a>
</div>
{% endif %}
</div>
<div class="card-body p-0">
<div class="martor-preview{% if request.user.profile.theme == "dark" %} bg-dark{% endif %}">
{{ doc.content|safe_markdown }}
</div>
</div>
</div>
{% endfor %}
{% include "generics/doc_aside.html" %}
</div>
</div>
</div>
Expand Down
123 changes: 65 additions & 58 deletions templates/service_catalog/generic_form_multiple_step.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,69 +9,76 @@

<div class="content">
<div class="container-fluid">
{% if form_header %}{% include form_header %}{% endif %}
<div class="card">
<div class="card-body">
<form class="form-horizontal" action="" method="post">{% csrf_token %}
{{ wizard.management_form }}
{% if wizard.form.forms %}
{{ wizard.form.management_form }}
{% for form in wizard.form.forms %}
{{ form.as_table }}
{% endfor %}
{% else %}
{% for field in wizard.form %}
{% if field.field.separator %}
<div class="mb-8">
<hr class="solid">
</div>
{% endif %}
{% if field.field.form_title %}
<h5 class="text-primary">{{ field.field.form_title }}</h5>
{% endif %}
{% if field.field.widget.input_type == "checkbox" %}
<div class="mb-1 {% if field.errors %}has-error{% endif %}">
{{ field }}
<label for="{{ field.id_for_label }}" class="form-check-label">
{{ field.label }}
</label>
{% if field.help_text %}
<small class="pl-3 pb-2 form-text text-muted">{{ field.help_text|safe }}</small>
{% endif %}
</div>
<div class="row">
<div class="col-6">
{% if form_header %}{% include form_header %}{% endif %}
<div class="card">
<div class="card-body">
<form class="form-horizontal" action="" method="post">{% csrf_token %}
{{ wizard.management_form }}
{% if wizard.form.forms %}
{{ wizard.form.management_form }}
{% for form in wizard.form.forms %}
{{ form.as_table }}
{% endfor %}
{% else %}
<div class="form-group {% if field.errors %}has-error{% endif %}">
{% if not field.is_hidden %}
<label for="{{ field.id_for_label }}" class="control-label">
{{ field.label }} {% if field.field.required %}<span class="text-danger">*</span>{% endif %}
</label>
{% for field in wizard.form %}
{% if field.field.separator %}
<div class="mb-8">
<hr class="solid">
</div>
{% endif %}
<div class="col-sm-12">
{{ field }}
{% if field.help_text %}
<small class="form-text text-muted">{{ field.help_text|safe }}</small>
{% endif %}
{% if field.field.quota %}
<small class="form-text text-primary">Quota: {{ field.field.quota }}</small>
{% endif %}
</div>
</div>
{% if field.field.form_title %}
<h5 class="text-primary">{{ field.field.form_title }}</h5>
{% endif %}
{% if field.field.widget.input_type == "checkbox" %}
<div class="mb-1 {% if field.errors %}has-error{% endif %}">
{{ field }}
<label for="{{ field.id_for_label }}" class="form-check-label">
{{ field.label }}
</label>
{% if field.help_text %}
<small class="pl-3 pb-2 form-text text-muted">{{ field.help_text|safe }}</small>
{% endif %}
</div>
{% else %}
<div class="form-group {% if field.errors %}has-error{% endif %}">
{% if not field.is_hidden %}
<label for="{{ field.id_for_label }}" class="control-label">
{{ field.label }} {% if field.field.required %}<span class="text-danger">*</span>{% endif %}
</label>
{% endif %}
<div class="col-sm-12">
{{ field }}
{% if field.help_text %}
<small class="form-text text-muted">{{ field.help_text|safe }}</small>
{% endif %}
{% if field.field.quota %}
<small class="form-text text-primary">Quota: {{ field.field.quota }}</small>
{% endif %}
</div>
</div>
{% endif %}
{% endfor %}
{% endif %}
{% endfor %}
{% endif %}

<div class="mt-2 form-group">
<div class="col-sm-offset-2 col-sm-10">
{% if wizard.steps.prev %}
{# <button name="wizard_goto_step" type="submit" value="{{ wizard.steps.first }}">{% translate "first step" %}</button>#}
<button formnovalidate="formnovalidate" class="btn btn-default" name="wizard_goto_step" type="submit" value="{{ wizard.steps.prev }}">Previous step</button>
{% endif %}
<input type="submit" class="btn btn-primary" value="{% if wizard.steps.step1 == wizard.steps.count %}Submit{% else %}Next{% endif %}"/>
</div>
<div class="mt-2 form-group">
<div class="col-sm-offset-2 col-sm-10">
{% if wizard.steps.prev %}
{# <button name="wizard_goto_step" type="submit" value="{{ wizard.steps.first }}">{% translate "first step" %}</button>#}
<button formnovalidate="formnovalidate" class="btn btn-default" name="wizard_goto_step" type="submit" value="{{ wizard.steps.prev }}">Previous step</button>
{% endif %}
<input type="submit" class="btn btn-primary" value="{% if wizard.steps.step1 == wizard.steps.count %}Submit{% else %}Next{% endif %}"/>
</div>
</div>
</form>
<p>Step {{ wizard.steps.step1 }} of {{ wizard.steps.count }}</p>
<small class="form-text text-muted"><span class="text-danger">*</span> Required field</small>
</div>
</form>
<p>Step {{ wizard.steps.step1 }} of {{ wizard.steps.count }}</p>
<small class="form-text text-muted"><span class="text-danger">*</span> Required field</small>
</div>
</div>
<div class="col-6">
{% include "generics/doc_aside.html" %}
</div>
</div>
</div>
Expand Down

0 comments on commit 5385dac

Please sign in to comment.