Skip to content

Commit

Permalink
Merge pull request #601 from ministryofjustice/govuk-frontend-5
Browse files Browse the repository at this point in the history
MTP-1980: Upgrade to `govuk-frontend` 5 and other dependencies
  • Loading branch information
ushkarev committed Jan 11, 2024
2 parents 290a96f + 798a920 commit 305de8b
Show file tree
Hide file tree
Showing 11 changed files with 120 additions and 92 deletions.
5 changes: 5 additions & 0 deletions mtp_cashbook/apps/cashbook/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,11 @@ def get_form_kwargs(self):
kwargs['request'] = self.request
return kwargs

def dispatch(self, request, *args, **kwargs):
response = super().dispatch(request, *args, **kwargs)
response['X-Frame-Options'] = 'SAMEORIGIN'
return response

def get(self, request, *args, **kwargs):
form = self.get_form()
if form.is_bound:
Expand Down
1 change: 1 addition & 0 deletions mtp_cashbook/assets-src/app.scss
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

// app components
@import './display';
@import './components/breadcrumb-bar';
@import './components/cashbook';
@import './components/disbursements';
@import './components/footer';
Expand Down
5 changes: 5 additions & 0 deletions mtp_cashbook/assets-src/components/breadcrumb-bar/_index.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
@media print {
.mtp-breadcrumb-bar {
display: none;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,7 @@
}
}
}

.mtp-new-credits-help {
width: 85%;
}
18 changes: 14 additions & 4 deletions mtp_cashbook/assets-src/components/cashbook/_search-header.scss
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
.mtp-header-app-links__search {
width: 280px;
width: 18rem;

.govuk-input, .govuk-button {
margin: 0;
}

.govuk-input {
position: relative;
width: 220px;
width: 15rem;
max-width: none;
height: 2.25rem;
font-size: 1em;
}

.govuk-button {
width: 38px;
height: 40px;
width: 2.25rem;
height: 2.25rem;
text-indent: -200px;
font-size: 1px;
background: govuk-colour('blue') mtp-static-url('images/search-icon.png') no-repeat 50% 50%;
Expand Down Expand Up @@ -49,5 +51,13 @@
@include govuk-media-query($from: desktop) {
float: right;
text-align: right;

.govuk-input {
right: 3px;
}

.govuk-button {
float: right;
}
}
}
2 changes: 1 addition & 1 deletion mtp_cashbook/templates/cashbook/new_credits.html
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ <h2 class="govuk-heading-m">
<thead>
{% if new_object_list %}
<tr class="govuk-!-display-none-print">
<td colspan="{% if request.pre_approval_required %}5{% else %}4{% endif %}" class="mtp-table__cell--compact">
<td colspan="{% if request.pre_approval_required %}5{% else %}4{% endif %}" class="mtp-table__cell--compact mtp-new-credits-help">

{% captureoutput as body %}
<p>
Expand Down
6 changes: 5 additions & 1 deletion mtp_cashbook/templates/cashbook/processed_credits.html
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,11 @@ <h3 class="govuk-heading-m">{% trans 'Filter by' %}</h3>
<td>{% trans 'No' %}</td>
{% endif %}
{% endif %}
<td class="govuk-!-display-none-print"><a href="{% url 'processed-credits-detail' date=batch.logged_at|date:'Ymd' user_id=batch.owner %}" class="mtp-print-link-target">{% trans 'Print' %}</a></td>
<td class="govuk-!-display-none-print">
<a href="{% url 'processed-credits-detail' date=batch.logged_at|date:'Ymd' user_id=batch.owner %}" class="mtp-print-link-target">
{% trans 'Print' %}
</a>
</td>
</tr>
{% endfor %}
</tbody>
Expand Down
153 changes: 78 additions & 75 deletions mtp_cashbook/templates/mtp_auth/login.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,87 +7,90 @@
{% block page_title %}{% trans 'Sign in' %} – {{ block.super }}{% endblock %}

{% block main %}
<div class="mtp-masthead govuk-!-margin-bottom-9">
<div class="govuk-width-container">
<main id="main-content" role="main">

<div class="govuk-grid-row">
{% language_switch %}
</div>
<div class="mtp-masthead govuk-!-margin-bottom-9">
<div class="govuk-width-container">

<div class="govuk-grid-row govuk-!-margin-top-9 govuk-!-margin-bottom-6">
<header class="govuk-grid-column-two-thirds">
<h1 class="govuk-heading-xl">
{% trans 'Process money in and out of your prison' %}
</h1>

<aside>
<p>
{% trans 'These tools will help you manage prisoner money' %}:
</p>
<ul class="govuk-list govuk-list--bullet">
<li>{% trans 'digital cashbook' %}</li>
<li>{% trans 'digital disbursements' %}</li>
</ul>
</aside>
</header>

<div class="govuk-grid-column-one-third">
<img alt="{% trans 'Digital cashbook' %}" src="{% static 'images/landing-cashbook.png' %}" srcset="{% static 'images/landing-cashbook@2x.png' %} 2x"/>
<div class="govuk-grid-row">
{% language_switch %}
</div>
</div>

<div class="govuk-grid-row govuk-!-margin-top-9 govuk-!-margin-bottom-6">
<header class="govuk-grid-column-two-thirds">
<h1 class="govuk-heading-xl">
{% trans 'Process money in and out of your prison' %}
</h1>

<aside>
<p>
{% trans 'These tools will help you manage prisoner money' %}:
</p>
<ul class="govuk-list govuk-list--bullet">
<li>{% trans 'digital cashbook' %}</li>
<li>{% trans 'digital disbursements' %}</li>
</ul>
</aside>
</header>

<div class="govuk-grid-column-one-third">
<img alt="{% trans 'Digital cashbook' %}" src="{% static 'images/landing-cashbook.png' %}" srcset="{% static 'images/landing-cashbook@2x.png' %} 2x"/>
</div>
</div>

</div>
</div>
</div>

<div class="govuk-width-container govuk-!-margin-bottom-9">
{% notification_banners request 'cashbook_login' %}

<div class="govuk-grid-row">
<section class="govuk-grid-column-one-half">
<h2 class="govuk-heading-m">{% trans 'Need access?' %}</h2>
<p>
{% trans 'If you’re a business hub staff member in a public prison in England or Wales, you can request access to the digital cashbook.' %}
</p>
<p>
<a href="{% url 'sign-up' %}">
{% trans 'Request access' %}
</a>
</p>
<p>
{% blocktrans trimmed %}
Intelligence staff need to log into the <a href="{{ noms_ops_url }}">prisoner money intelligence tool</a> instead.
{% endblocktrans %}
</p>
</section>

<section class="govuk-grid-column-one-half">
<h2 class="govuk-heading-m">{% trans 'Sign in' %}</h2>

{% include 'govuk-frontend/components/error-summary.html' with form=form only %}

<form action="{{ app_path }}" method="post">
{% csrf_token %}
<input type="hidden" name="next" value="{{ next }}">

{% include 'mtp_common/forms/field.html' with field=form.username input_classes='govuk-input--width-10' only %}
{% include 'mtp_common/forms/field.html' with field=form.password input_classes='govuk-input--width-10' only %}

<button type="submit" class="govuk-button" data-module="govuk-button" name="signin">{% trans 'Sign in' %}</button>
</form>

<p><a href="{% url 'reset_password' %}">{% trans 'Forgotten your password?' %}</a></p>

</section>
</div>

<br />
<div class="govuk-width-container govuk-!-margin-bottom-9">
{% notification_banners request 'cashbook_login' %}

<div class="govuk-grid-row">
<section class="govuk-grid-column-one-half">
<h2 class="govuk-heading-m">{% trans 'Need access?' %}</h2>
<p>
{% trans 'If you’re a business hub staff member in a public prison in England or Wales, you can request access to the digital cashbook.' %}
</p>
<p>
<a href="{% url 'sign-up' %}">
{% trans 'Request access' %}
</a>
</p>
<p>
{% blocktrans trimmed %}
Intelligence staff need to log into the <a href="{{ noms_ops_url }}">prisoner money intelligence tool</a> instead.
{% endblocktrans %}
</p>
</section>

<section class="govuk-grid-column-one-half">
<h2 class="govuk-heading-m">{% trans 'Sign in' %}</h2>

{% include 'govuk-frontend/components/error-summary.html' with form=form only %}

<form action="{{ app_path }}" method="post">
{% csrf_token %}
<input type="hidden" name="next" value="{{ next }}">

{% include 'mtp_common/forms/field.html' with field=form.username input_classes='govuk-input--width-10' only %}
{% include 'mtp_common/forms/field.html' with field=form.password input_classes='govuk-input--width-10' only %}

<button type="submit" class="govuk-button" data-module="govuk-button" name="signin">{% trans 'Sign in' %}</button>
</form>

<p><a href="{% url 'reset_password' %}">{% trans 'Forgotten your password?' %}</a></p>

</section>
</div>

<br />

<p>
{% url 'faq' as faq_url %}
{% blocktrans trimmed %}
<a href="{{ faq_url }}">Get help</a> if you’re having difficulties requesting access or signing in.
{% endblocktrans %}
</p>
</div>
<p>
{% url 'faq' as faq_url %}
{% blocktrans trimmed %}
<a href="{{ faq_url }}">Get help</a> if you’re having difficulties requesting access or signing in.
{% endblocktrans %}
</p>
</div>

</main>
{% endblock %}
2 changes: 1 addition & 1 deletion requirements/base.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Dependencies needed for all environments

money-to-prisoners-common~=16.5.0
money-to-prisoners-common~=16.6.0
2 changes: 1 addition & 1 deletion requirements/dev.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Place development and testing dependencies here

money-to-prisoners-common[testing]~=16.5.0
money-to-prisoners-common[testing]~=16.6.0

-r base.txt
14 changes: 5 additions & 9 deletions run.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,13 @@
import mtp_common

# NB: this version does not need to be updated unless mtp_common changes significantly
if mtp_common.VERSION < (10,):
if mtp_common.VERSION < (16,):
raise ImportError
except ImportError:
try:
import pkg_resources
except ImportError:
raise SystemExit('setuptools and pip are required')
try:
pip = pkg_resources.load_entry_point('pip', 'console_scripts', 'pip')
except pkg_resources.ResolutionError:
raise SystemExit('setuptools and pip are required')
import importlib.metadata

(entry_point,) = importlib.metadata.entry_points(name='pip', group='console_scripts')
pip = entry_point.load()

print('Pre-installing MTP-common and base requirements')
pip(['install', '--requirement', f'{root_path}/requirements/base.txt'])
Expand Down

0 comments on commit 305de8b

Please sign in to comment.