Commit Graph

8666 Commits

Author SHA1 Message Date
jimmoffet
dad051a662 2767 passing 2022-08-05 00:25:03 -07:00
jimmoffet
9315474b75 correct local url 2022-08-03 18:23:02 -07:00
jimmoffet
6042289411 corrected cmd palette shortcut in readme 2022-08-03 15:52:27 -07:00
jimmoffet
f11b37f30a commit uk build-time vendor info and freeze it 2022-08-03 15:06:18 -07:00
James Moffet
c3541ddcb5 UI tweaks 2022-07-29 15:28:10 -07:00
James Moffet
c697596d1a fix indent 2022-07-26 12:37:13 -07:00
James Moffet
68365f8b08 comments and logs 2022-07-26 11:45:27 -07:00
James Moffet
1a204ae872 remove extra logs 2022-07-26 11:39:00 -07:00
James Moffet
17e25d6f61 comments 2022-07-26 11:24:36 -07:00
James Moffet
4c25a81004 disable cache until we can fix on cloud deployment 2022-07-26 11:17:43 -07:00
James Moffet
e6b36becf1 more config 2022-07-25 15:18:39 -07:00
James Moffet
772731e73e stop using UK cdn for images 2022-07-21 18:54:21 -07:00
James Moffet
c782d5d80b images and overrides 2022-07-21 18:25:23 -07:00
James Moffet
e53d12733a branding 2022-07-20 15:23:54 -07:00
James Moffet
ec86fe8d23 clean up 2022-07-19 18:59:48 -07:00
James Moffet
e9302552ee clean up 2022-07-19 18:58:38 -07:00
James Moffet
6c60183a10 delete log 2022-07-19 18:49:05 -07:00
James Moffet
50e660a73f devcontainer config 2022-07-19 18:23:48 -07:00
James Moffet
6ad5cefe30 minor configs 2022-07-15 13:53:48 -05:00
Jim Moffet
b932294a9c formatting 2022-07-01 11:49:31 -07:00
Jim Moffet
8e9be686d2 clean obsolete import 2022-07-01 11:48:17 -07:00
Jim Moffet
522ed32a01 clean obsolete import 2022-07-01 11:47:44 -07:00
Jim Moffet
b5e2b67576 clean obsolete import 2022-07-01 11:38:19 -07:00
Jim Moffet
4001332741 clean comments 2022-07-01 11:36:47 -07:00
Jim Moffet
b8d5a0b5eb clean comments 2022-07-01 11:36:15 -07:00
Jim Moffet
e9a3b3d5e3 move CustomBasicAuth override to import 2022-07-01 11:34:51 -07:00
Jim Moffet
1c5d432427 clean up and turn off auth for test env 2022-07-01 11:19:58 -07:00
Jim Moffet
1e979ad519 fix basic auth for live environment 2022-07-01 07:58:58 -07:00
Jim Moffet
509cce38f4 set up basicauth config to protect staging site 2022-06-30 17:05:42 -07:00
Christa Hartsock
6d3f67fb9b Initial config for local deployments
Not yet working properly on cloud.gov
2022-06-23 15:53:23 -07:00
Jim Moffet
e17c26d1f6 config buckets 2022-06-23 14:08:29 -07:00
Jim Moffet
2b727e13b4 local dev upgrades 2022-06-13 14:26:46 -07:00
Ben Thorner
543be77776 Merge pull request #4258 from alphagov/speed-up-templates-page-179736794
Optimise load time for service "Templates" page
2022-06-08 13:37:58 +01:00
Chris Hill-Scott
b91babc67e Fix relative URLs in support tickets
When we get a support ticket we put a link to the service at the end.

As part of 8b7f2fbf04 we accidentally made
these URLs relative, rather than absolute. This means they aren’t made
into links by email clients or Zendesk.

This commit fixes the links to include the domain again.
2022-06-07 13:50:24 +01:00
Chris Hill-Scott
197e98d891 Refactor support ticket into a template
This is the same thing we do for go live requests and branding requests.

It’s easier to do templating logic in a templating language than in
Python.
2022-06-07 13:50:24 +01:00
Ben Thorner
5db2581669 Simplify tests for TemplateList class
In response to: [^1][^2][^3].

Originally there were three tests:

- One was testing the "get_user_template_folders" method directly.

- The other two were testing "get_template_folders", which calls
the "_user_" method if a user is passed - this is what the tests
were primarily checking, by passing or not passing a User object.

The two tests of "get_template_folders" also implicitly checked
that it filtered folders based on a "parent_folder_id". I wanted
to emulate the tests but it makes more sense to simplify them, as
the methods are now only used by TemplateList internally.

To simplify, we just keep just two tests to check that the overall
set of folders is filtered based on the presence of a User. We do
lose the implicit check of filtering by "parent_folder_id", but:

- We are still checking this implicitly in the sense that the loop
to generate the overall set of folders terminates. If the method
didn't do any filtering, the loop would be infinite.

- We need to acknowledge that these tests were incomplete to begin
with. There is also lots of coverage in higher level tests [^4],
although it's harder to reason exactly what is covered.

[^1]: https://github.com/alphagov/notifications-admin/pull/4258#discussion_r890144076
[^2]: https://github.com/alphagov/notifications-admin/pull/4258#discussion_r890151220
[^3]: https://github.com/alphagov/notifications-admin/pull/4258#discussion_r890147506
[^4]: 1787f9f42f/tests/app/main/views/test_template_folders.py
2022-06-07 11:31:09 +01:00
Ben Thorner
1c4a2b4790 Cache templates and folders in TemplateList
This gives us the performance gains identified in [^1] for the test
service described in the spike:

- user_template_folders - from 10s to a little above 3s on its own

- get_templates_and_folders - from 10s to below 6s on its own

In combination, these two uses of caching reduce the test page load
time from 10s to a little above 3s. This is slightly higher than in
the spike PR due to all the extra work we're doing to generate the
"move to" list of folders, as described in a previous commit.

The render time is unchanged for services with few folders. We start
to see the benefit of this change at around 200 templates + folders,
with no evidence that any service will experience worse render times,
despite the extra work we're doing from previous commits.

[^1]: https://github.com/alphagov/notifications-admin/pull/4251
2022-06-07 11:05:36 +01:00
Ben Thorner
2771ae1274 Remove redundant user param from template methods
This will finally make it possible to cache some of the methods.
2022-06-07 11:05:35 +01:00
Ben Thorner
9126c8ca5e Move _template_ methods to TemplateList class
This is a straight move with a few minor tweaks:

- Some references to self.X in the code from Service now need to
become self.service.X.

- Some reference to self.service.Y in TemplateList can now become
self.Y for the methods that were migrated.

The remaining _template_ methods in Service are still called from
multiple places and there's no performance gain to motivate moving
them out of the Service class, which is now a more manageable size.
2022-06-07 11:05:34 +01:00
Ben Thorner
487dc1b488 Test _template_folders functions via TemplateList
This is part of the overall migration of the "_template_folders"
methods to the TemplateList class. Moving the existing tests now
will make the actual migration easier to follow.

To emulate the second and third tests, we need to grab a specific
folder from the TemplateList and then look at its folders - these
are set based on "get_template_folders" as before.
2022-06-07 11:05:30 +01:00
Ben Thorner
b97bf19b45 Make creating TemplateListServices consistent
TemplateListServices are used when we want to show the service
as an additional layer of hierarchy when a user copies a template,
potentially across services [^1].

Normally a TemplateFolder is given "folders" and "templates" by
TemplateList [^2]; TemplateListService was doing it the other
way round and getting its own instead.

Using a subclass of TemplateList means we can make the approach
consistent, which will support the caching approach later on, as
well as simplifying how we work with templates and folders.

[^1]: 2e637f801f/app/main/views/templates.py (L356)
[^2]: bef0382cca/app/models/template_list.py (L31-L36)
2022-06-07 10:43:30 +01:00
Chris Hill-Scott
8b7f2fbf04 Stop using _external=True in tests
It looks like, by default, Flask no longer makes full URLs, for example
`https://example.com/path`. Instead it does `/path`. This will still
work fine, and if anything is better because it reduces the number of
bytes of HTML we are sending.

It won’t mean that requests go over `http` instead of `https` without
the protocol because we set the appropriate HSTS header here:
0c57da7781/ansible/roles/paas-proxy/templates/admin.conf.j2 (L11)

This commit changes all our tests to reflect that URLs no longer have
the protocol and domain in them. `_external=True` is Flask’s way of
saying whether a URL should be generated with the domain and protocol
(`True`) or without it (`False`).

Again, I can’t find the changelog or diff where this was introuduced,
but if you’d like to go spelunking then here’s a starting point:
50374e3cfe/src/flask/helpers.py (L192)
2022-06-06 12:12:52 +01:00
Chris Hill-Scott
2a62586799 Reflect change in argument name
`filename_or_fp` was changed to `path_or_file` here:
https://github.com/pallets/flask/pull/3828/files#diff-1f51c8ded4d4ff7e13badab599ef22436c529c2b5f9c25dc6250c1f9fd985440R479
2022-06-06 12:12:52 +01:00
Chris Hill-Scott
78a1a3099d Work around incompatibilty between govuk-frontend-jinja and Flask 2
This line:
ddbe208a97/govuk_frontend_jinja/flask_ext.py (L22)

Raises `KeyError: 'extensions'` when using Flask 2

I think this is because there are no default Jinja extensions in Flask
as of pallets/flask@81ba6c2 in accordance with
https://github.com/pallets/jinja/issues/1203

So we need to manually add an `extensions` field to the `jinja_options`
`dict` if one doesn’t exist already.

Issue raised here: https://www.github.com/Crown-Commercial-Service/govuk-frontend-jinja/issues/66
2022-06-06 12:12:52 +01:00
Ben Thorner
a87138b9f9 Refactor loop over TemplateList items
This is a technique we'll use in later commits.
2022-06-06 10:36:49 +01:00
Ben Thorner
ad4ef12251 Reuse TemplateList to display move-to options
This is slightly less efficient than getting the folder dicts from
"get_user_template_folders" directly, since:

- TemplateList returns both templates and folders.
- TemplateList encapsulates the dicts in model classes.

We'll compensate for this later on:

- We'll introduce a new caching approach to make the call fast.
- We'll expose a property to avoid the "if" in the comprehension.
2022-06-06 10:36:48 +01:00
Ben Thorner
f500db44f1 Reuse TemplateList class when deleting a folder
Part of moving "get_template_folders" et al. into TemplateList so we
can cache it more effectively. This is slightly less efficient as
iterating a TemplateList will instantiate an object for each item
in the folder; but the difference is minimal.

Note that:

- The default template_type for TemplateList is "all".
- We need to pass realistic template "JSON" in the test now.
2022-06-06 10:36:47 +01:00
Ben Thorner
fe13bb8dbc Merge pull request #4254 from alphagov/fix-go-live-bug-179736794
Fix go-live checks ignoring nested templates
2022-06-06 10:36:28 +01:00
Ben Thorner
524fa12cde Merge pull request #4260 from alphagov/bump-utils-56
Bump utils to version 56.0.0
2022-06-06 10:28:20 +01:00
Ben Thorner
ee3d2d1804 Bump utils to version 56.0.0
The only impactful change is the major version itself, where I've
fixed the breaking changes due to the upgrade of PyPDF2 [^1] and
checked there are no deprecation warnings when I run the tests.

[^1]: https://github.com/alphagov/notifications-utils/pull/973
2022-06-01 13:29:54 +01:00