Skip to content

Commit 1424b90

Browse files
committed
Merge remote-tracking branch 'origin/main' into feat/onboarding-prototype-v2
2 parents c43838e + 49d8fc2 commit 1424b90

33 files changed

+139
-66
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# This file was automatically copied from notifications-utils@101.0.0
1+
# This file was automatically copied from notifications-utils@101.1.0
22

33
repos:
44
- repo: https://github.com/pre-commit/pre-commit-hooks

app/__init__.py

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
# ruff: noqa: E402
4545
memo_resetters: list[Callable] = []
4646

47-
from app import proxy_fix, webauthn_server
47+
from app import webauthn_server
4848
from app.commands import setup_commands
4949
from app.config import Config, configs
5050
from app.event_handlers import Events
@@ -193,7 +193,6 @@ def create_app(application):
193193
metrics,
194194
csrf,
195195
login_manager,
196-
proxy_fix,
197196
request_helper,
198197
# External API clients
199198
redis_client,
@@ -629,3 +628,42 @@ def init_jinja(application):
629628

630629
application.jinja_env.filters["format_provider"] = format_provider
631630
application.jinja_env.add_extension("jinja2.ext.do")
631+
application.jinja_env.undefined = NotifyJinjaUndefined
632+
633+
634+
class NotifyJinjaUndefined(jinja2.Undefined):
635+
"""
636+
The same as jinja2.StrictUndefined with a few exceptions, noted
637+
in specific comments.
638+
639+
For more context see:
640+
https://jinja.palletsprojects.com/en/stable/api/#undefined-types
641+
"""
642+
643+
__slots__ = ()
644+
__iter__ = jinja2.Undefined._fail_with_undefined_error
645+
__len__ = jinja2.Undefined._fail_with_undefined_error
646+
__hash__ = jinja2.Undefined._fail_with_undefined_error
647+
# __bool__: UndefinedErrors remain supressed
648+
__contains__ = jinja2.Undefined._fail_with_undefined_error
649+
__str__ = jinja2.Undefined._fail_with_undefined_error
650+
651+
def __eq__(self, other):
652+
if isinstance(self._undefined_obj, dict):
653+
# Accessing a missing field on a dict, we do this too
654+
# often to be strict about it
655+
return super().__eq__(other)
656+
657+
if isinstance(other, NotifyJinjaUndefined):
658+
# Comparing to something else which is undefined, you are
659+
# probably doing this on purpose
660+
return True
661+
662+
if isinstance(self._undefined_obj, jinja2.utils._MissingType):
663+
# Comparing to an internal Jinja type, you are probably
664+
# doing this on purpose
665+
return False
666+
667+
# In any other case comparing undefined to something is bad
668+
# so raise an exception
669+
jinja2.Undefined._fail_with_undefined_error(self, other)

app/assets/stylesheets/govuk-frontend/extensions.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ $govuk-grid-widths: map.merge($govuk-grid-widths, $notify-grid-widths);
184184
white-space: pre-wrap;
185185
overflow-wrap: break-word;
186186
word-wrap: break-word;
187+
box-sizing: border-box;
187188
padding: 4px 4px govuk-spacing(6) 4px;
188189
border: 2px solid transparent;
189190
z-index: 10;

app/main/views/send.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ def get_example_letter_address(key):
8989

9090

9191
@main.route("/services/<uuid:service_id>/send/<uuid:template_id>/csv", methods=["GET", "POST"])
92-
@user_has_permissions("send_messages", restrict_admin_usage=True)
92+
@user_has_permissions("send_messages")
9393
def send_messages(service_id, template_id):
9494
template = current_service.get_template_with_user_permission_or_403(
9595
template_id,
@@ -197,7 +197,7 @@ def _should_show_set_sender_page(service_id, template) -> bool:
197197

198198

199199
@main.route("/services/<uuid:service_id>/send/<uuid:template_id>/set-sender", methods=["GET", "POST"])
200-
@user_has_permissions("send_messages", restrict_admin_usage=True)
200+
@user_has_permissions("send_messages")
201201
def set_sender(service_id, template_id):
202202
template = current_service.get_template_with_user_permission_or_403(template_id, current_user)
203203

@@ -333,7 +333,7 @@ def get_sender_details(service_id, template_type):
333333

334334

335335
@main.route("/services/<uuid:service_id>/send/<uuid:template_id>/one-off")
336-
@user_has_permissions("send_messages", restrict_admin_usage=True)
336+
@user_has_permissions("send_messages")
337337
def send_one_off(service_id, template_id):
338338
session["recipient"] = None
339339
session["placeholders"] = {}
@@ -375,7 +375,7 @@ def get_notification_check_endpoint(service_id, template):
375375

376376

377377
@main.route("/services/<uuid:service_id>/send/<uuid:template_id>/one-off/address", methods=["GET", "POST"])
378-
@user_has_permissions("send_messages", restrict_admin_usage=True)
378+
@user_has_permissions("send_messages")
379379
def send_one_off_letter_address(service_id, template_id):
380380
if {"recipient", "placeholders"} - set(session.keys()):
381381
# if someone has come here via a bookmark or back button they might have some stuff still in their session
@@ -439,7 +439,7 @@ def send_one_off_letter_address(service_id, template_id):
439439
"/services/<uuid:service_id>/send/<uuid:template_id>/one-off/step-<int:step_index>",
440440
methods=["GET", "POST"],
441441
)
442-
@user_has_permissions("send_messages", restrict_admin_usage=True)
442+
@user_has_permissions("send_messages")
443443
def send_one_off_step(service_id, template_id, step_index): # noqa: C901
444444
if {"recipient", "placeholders"} - set(session.keys()):
445445
return redirect(
@@ -781,7 +781,7 @@ def _check_messages(service_id, template_id, upload_id, preview_row, emergency_c
781781
@main.route(
782782
"/services/<uuid:service_id>/<uuid:template_id>/check/<uuid:upload_id>/row-<int:row_index>", methods=["GET"]
783783
)
784-
@user_has_permissions("send_messages", restrict_admin_usage=True)
784+
@user_has_permissions("send_messages")
785785
def check_messages(service_id, template_id, upload_id, row_index=2):
786786
emergency_contact = bool(request.args.get("emergency_contact"))
787787
data = _check_messages(service_id, template_id, upload_id, row_index, emergency_contact)
@@ -1005,7 +1005,7 @@ def get_skip_link(step_index, template):
10051005

10061006

10071007
@main.route("/services/<uuid:service_id>/template/<uuid:template_id>/one-off/send-to-myself", methods=["GET"])
1008-
@user_has_permissions("send_messages", restrict_admin_usage=True)
1008+
@user_has_permissions("send_messages")
10091009
def send_one_off_to_myself(service_id, template_id):
10101010
# We aren't concerned with creating the exact template (for example adding recipient and sender names)
10111011
# we just want to create enough to use `fields_to_fill_in`
@@ -1027,7 +1027,7 @@ def send_one_off_to_myself(service_id, template_id):
10271027

10281028

10291029
@main.route("/services/<uuid:service_id>/template/<uuid:template_id>/notification/check", methods=["GET"])
1030-
@user_has_permissions("send_messages", restrict_admin_usage=True)
1030+
@user_has_permissions("send_messages")
10311031
def check_notification(service_id, template_id):
10321032
return render_template(
10331033
"views/notifications/check.html",

app/main/views/uploads.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ def uploaded_letters(service_id, letter_print_day):
127127
service_id=current_service.id,
128128
from_uploaded_letters=letter_print_day,
129129
),
130+
limit_days=None,
130131
)
131132

132133

app/main/views/verify.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,12 @@ def _check_code(code):
2525
session.pop("user_details", None)
2626
return activate_user(user_id)
2727

28-
return render_template("views/two-factor-sms.html", form=form, error_summary_enabled=True)
28+
return render_template(
29+
"views/two-factor-sms.html",
30+
form=form,
31+
error_summary_enabled=True,
32+
redirect_url=None,
33+
)
2934

3035

3136
@main.route("/verify-email/<string:token>")

app/models/organisation.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ def __init__(self, _dict):
113113
self.name = None
114114
self.crown = None
115115
self.agreement_signed = None
116+
self.agreement_signed_by_id = None
116117
self.domains = []
117118
self.organisation_type = None
118119
self.request_to_go_live_notes = None

app/proxy_fix.py

Lines changed: 0 additions & 15 deletions
This file was deleted.

app/templates/admin_template.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,9 @@
5555
"homepageUrl": url_for('main.show_accounts_or_dashboard'),
5656
"productName": "Notify",
5757
"assetsPath": asset_path + "images",
58-
"rebrand": govukRebrand
58+
"rebrand": govukRebrand,
59+
"serviceName": None,
60+
"navigation": [],
5961
}) }}
6062

6163
{{ govukServiceNavigation({

app/templates/components/copy-to-clipboard.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
{% macro copy_to_clipboard(value, name, thing) %}
2-
{% if name|lower == thing|lower %}
2+
{% if name and name|lower == thing|lower %}
33
<h2 class="copy-to-clipboard__name">
44
{{ name }}
55
</h2>
66
{% endif %}
7-
<div data-notify-module="copy-to-clipboard" data-value="{{ value }}" data-thing="{{ thing }}" data-name="{{ name }}">
7+
<div data-notify-module="copy-to-clipboard" data-value="{{ value }}" data-thing="{{ thing }}" data-name="{{ name or "" }}">
88
<span class="copy-to-clipboard__value">
9-
{%- if name|lower != thing|lower %}<span class="govuk-visually-hidden">{{ thing }}: </span>{% endif %}{{ value -}}
9+
{%- if name and name|lower != thing|lower %}<span class="govuk-visually-hidden">{{ thing }}: </span>{% endif %}{{ value -}}
1010
</span>
1111
<span class="copy-to-clipboard__notice" aria-live="assertive"></span>
1212
</div>

0 commit comments

Comments
 (0)