Commit Graph

7170 Commits

Author SHA1 Message Date
Leo Hemsted
023c4121b3 separate urgent and p1 concepts in feedback.
p1 == "should notify team be alerted of this (via pagerduty)"
urgent == "should the user be told we'll look at it"

* If it's in office hours, it's always urgent. It's never a P1 because
  we'll notice it anyway
* If it's outside of office hours, it's urgent and P1 if it's severe,
  otherwise it's neither
2018-04-27 14:20:15 +01:00
Chris Hill-Scott
0b331f3e23 Upgrade GOV.UK template to newest version
Changes: https://github.com/alphagov/govuk_template/compare/v0.23.0...v0.24.0

Includes a new way of serving the font files which will:
- save us ~300kb on non-cachd requests
- speed up the parsing of the CSS file
2018-04-27 14:12:02 +01:00
Chris Hill-Scott
0fd13058ba Fix which Lincolnshire council signed agreement
North East Lincolnshire Council have signed the agreement, but we had
it down as North Lincolnshire Council.
2018-04-27 10:16:23 +01:00
Chris Hill-Scott
4847ee81a4 Merge pull request #2039 from alphagov/highland
Updating Highland Council MOU status
2018-04-26 16:53:03 +01:00
Chris Hill-Scott
0eb3efb28c Add some crown bodies who haven’t signed the MOU
These organisations are, to the best of my knowledge:
- crown
- without an MOU in place

Scavenged from:
- http://www.nationalarchives.gov.uk/information-management/re-using-public-sector-information/uk-government-licensing-framework/crown-copyright/uk-crown-bodies/
- https://www.gov.uk/government/organisations

And cross referenced with the Google Drive folder.

This should give us a better chance of being able to give people the the MOU to download, once it’s available.
2018-04-26 16:24:37 +01:00
Chris Hill-Scott
e0af280a94 Mark agreement signed by GCHQ
The one we had for NCSC is actually for the whole of GCHQ.
2018-04-26 15:47:58 +01:00
Pete Herlihy
d2bd878a9a Updating Highland Council MOU status 2018-04-26 15:08:33 +01:00
Chris Hill-Scott
09cf529222 Note agreement signed by Wigan Council 2018-04-26 14:49:42 +01:00
Chris Hill-Scott
310b4ec0e0 Merge pull request #2036 from alphagov/pyup-update-notifications-python-client-4.8.1-to-4.8.2
Update notifications-python-client to 4.8.2
2018-04-25 16:14:37 +01:00
Chris Hill-Scott
555820bb15 Merge pull request #2035 from alphagov/pyup-update-pytest-3.5.0-to-3.5.1
Update pytest to 3.5.1
2018-04-25 16:14:20 +01:00
Chris Hill-Scott
9e78c5f575 Strip obscure whitespace from form submissions
We strip most whitespace as of:
https://github.com/alphagov/notifications-admin/pull/1701

However we are still getting some bad email addresses through, for
example one that had a leading zero-width space character. This means
that the user sees a validation error; really we should just deal with
the mess for them.

So this commit also includes characters without Unicode character
property "WSpace=Y" (which includes zero-width space) to those which are
stripped from form submissions.

List taken from here: https://en.wikipedia.org/wiki/Whitespace_character

See issue and discussion here: https://bugs.python.org/issue13391
2018-04-25 16:12:24 +01:00
Leo Hemsted
be038e345d define isort first party (app and tests)
we were seeing isort produce different outputs locally and in docker -
this was due to it having different opinions about whether the tests
module (ie all our unit tests) is a first party (local) or third party
(pip installed) import. It's a first party import, so by defining this
in the setup.cfg isort settings, we can force it to be consistent
between environments.

Note: I don't know why it was different in the first place though
2018-04-25 14:12:58 +01:00
Leo Hemsted
198bc476bb remove old feedback urls
not been hit in the last couple of weeks
2018-04-25 13:43:15 +01:00
Chris Hill-Scott
9f5d42a788 Add selected navigation for organisations page
To match how the navigation works for a single service.
2018-04-25 13:17:47 +01:00
Chris Hill-Scott
511ca8f652 Merge pull request #2032 from alphagov/increase-redis-ttl
Make Redis hold onto cached API responses longer
2018-04-25 11:42:19 +01:00
Chris Hill-Scott
8a7525a809 Highlight selected item in proposition navigation
It is standard practice when using GOV.UK template to highlight the
selected navigation item in the propositional navigation (black bar) by
colouring it blue.

This commit adds a new subclass of `Navigation` with the mapping needed
to decide which pages belong to which item in the navigation (or none
at all).
2018-04-25 11:30:39 +01:00
Chris Hill-Scott
e1fd63e184 Rewrite navigation as a class
Because we have multiple navigations, which will share the same methods
(by subclassing) but different mappings of navigation items to endpoints
by overriding the `.mapping` and `.exclude` attributes.
2018-04-25 11:15:13 +01:00
pyup-bot
7cf8775435 Update notifications-python-client from 4.8.1 to 4.8.2 2018-04-25 10:40:45 +01:00
Chris Hill-Scott
1fba5d186d Highlight selected navigation item
In research I’ve sometimes seen people click the wrong nav item. I
reckon that people’s concept of which pages live behind which navigation
items isn’t very strong.

We can reinforce this relationship by showing, for every page, which is
the corresponding nav item. The conventional way of doing this is either
with some kind of emphasis, typically colour or bold. I’ve gone for bold
because colour would be weird.

---

The implementation of this is quite loosely coupled to our application
code because:
- our application code is not well structured (eg we don’t make any use
  of blueprints)
- spreading this change across lots of files in our application would
  make it harder to test without actually hitting each endpoints; such
  tests would be slow and verbose

So I’ve gone for more of a meta approach. Rather than testing that each
endpoint has a specific navigation item selected, I’ve gone for
validating that:
- all endpoints being mapped to are real
- all endpoints have _a_ selected navigation item (or are specifically
  excluded)

This means that it’s impossible to add, change or remove an endpoint
without also updating which navigation item should be selected. And the
actual mapping is so declarative that it testing it would be redundant.
2018-04-25 09:37:35 +01:00
pyup-bot
3952b62e2e Update pytest from 3.5.0 to 3.5.1 2018-04-25 00:01:47 +01:00
Leo Hemsted
d675ceb5c2 send zendesk rather than deskpro tickets 2018-04-24 17:37:15 +01:00
Chris Hill-Scott
589dbea971 Make Redis hold onto cached API responses longer
Redis is giving us a big performance boost (it’s roughly halved the
median request time on the admin app).

Once we’re confident that it’s working properly[1] we can eke out a bit
more performance from it by keeping the caches alive for longer. As
far as I can tell we’re still using Redis in a very low-volume way[2],
so increasing the number of things we’re storing shouldn’t start taxing
our Redis server at all. But reducing the number of times we have to
hit the API to refresh the cache _should_ result in some performance
increase.

---

1. ie we’re not seeing instances of stale caches not being invalidated

2. We have 2.5G of available space in Redis. Here is our current usage:
```
used_memory:7728960
used_memory_human:7.37M
used_memory_rss:7728960
used_memory_peak:16563776
used_memory_peak_human:15.79M
used_memory_lua:37888
```
2018-04-23 17:07:41 +01:00
Chris Hill-Scott
63061b1bab Merge pull request #2031 from alphagov/failure-anchor
Fix broken anchor links from message status fields
2018-04-23 16:05:46 +01:00
Chris Hill-Scott
c6b2c5285e Fix broken anchor links from message status fields
These IDs existed at some point but have been lost. They are needed because 
we link to them from a failed message to give a bit more explanation.

Need to match here: https://github.com/alphagov/notifications-admin/blob/master/app/__init__.py#L394-L396
2018-04-23 15:07:31 +01:00
Chris Hill-Scott
54e2c94d09 Merge pull request #2026 from alphagov/redis-cache-template
Cache `GET /template…` methods in Redis
2018-04-23 14:02:59 +01:00
Chris Hill-Scott
aff6177abb Merge pull request #1996 from alphagov/snyk-fix-2a80a3df
[Snyk Update] New fixes for 1 vulnerable dependency path
2018-04-23 10:35:33 +01:00
Chris Hill-Scott
61a7e38911 Merge pull request #2029 from alphagov/gdpr-ize
Tweak to make page GDPR relevant
2018-04-23 10:31:29 +01:00
Chris Hill-Scott
222a67959a Add tests for all templates and template versions 2018-04-20 17:32:01 +01:00
Chris Hill-Scott
06de94f1c5 Rewrite cache decorator to use format string
This is easier to read than having to understand the arguments 1…n of
the cache decorator are ‘magic’, and gives us more flexibility about
how the cache keys are formatted, eg being able to add words in the
middle of them.

Also changes the key format for all templates to be
`service-{service_id}-templates` instead of `templates-{service_id}`
because then it’s clearer what the ID represents.
2018-04-20 16:32:02 +01:00
Katie Smith
056ba11f6b Merge pull request #2030 from alphagov/link-to-new-python-docs
Link to new Python docs on Documentation page
2018-04-20 16:23:29 +01:00
Pete Herlihy
78cd4bf9d7 Tweak to make page GDPR relevant 2018-04-19 16:31:57 +01:00
Chris Hill-Scott
b28e8691a6 Revert "Remove keyword args from call to create service"
This reverts commit bde696cf56.

The caching decorator supports keyword arguments now.
2018-04-19 14:01:45 +01:00
Chris Hill-Scott
cea7a027e3 Add caching of templates in Redis
A lot of the frequently-used pages in the admin app rely on the API to
get templates.

So this commit adds three new caches:
- a single template version (including a key without a version number,
  which is the current version)
- all the templates for a service
- all versions of a template

The first will be the most crucial for performance, but there’s not much
cost to adding the other two.
2018-04-19 13:58:40 +01:00
Chris Hill-Scott
6101e5da43 Rewrite cache decorator to reference args by name
`@cache.delete('user', 'user_id')` is easier to read and understand than
`@cache.delete('user', key_from_args=[1])`. This will become even more
apparent if we have to start doing stuff like `key_from_args=[1, 5]`,
which is a lot more opaque than just saying
`'service_id', 'template_id'`.

It does make the implementation a bit more complex, but I’m not too
worried about that because:
- the tests are solid
- it’s nicely encapsulated
2018-04-19 13:58:40 +01:00
Chris Hill-Scott
6c8fea1ee8 Remove splatting on get template methods
This `*params` argument seems to be copy/pasted boilerplate. It’s not
used by any consumers of this client, and makes it harder to write a
decorator for this function.
2018-04-19 13:58:39 +01:00
Chris Hill-Scott
a0d7658db1 Merge pull request #2028 from alphagov/remove-kwargs-create-service
Remove keyword args from call to create service
2018-04-19 13:58:12 +01:00
Chris Hill-Scott
bde696cf56 Remove keyword args from call to create service
The cache decorator doesn’t work with functions that use keyword
arguments (at the moment).
2018-04-19 13:54:14 +01:00
Chris Hill-Scott
6acde6e1f0 Merge pull request #2027 from alphagov/cache-invite
Delete caches when user accepts invite or creates service
2018-04-19 13:29:18 +01:00
Chris Hill-Scott
1c91e10d5d Clear user cache when deleting a service
The user JSON has a list of service IDs
2018-04-19 13:25:04 +01:00
Chris Hill-Scott
9a3f9b7273 Delete caches when user accepts invite
Accepting an invite changes:
- the `user_to_service` list of users returned by `GET /service/<id>`
- the `services` list return by `GET /user/<id>`

The latter change is causing the functional tests to fail.
2018-04-19 13:15:52 +01:00
Chris Hill-Scott
b849e214fd Merge pull request #2022 from alphagov/redis-cache-user
Cache `GET /user` response in Redis
2018-04-19 12:59:01 +01:00
Katie Smith
e93f719396 Link to new Python docs on Documentation page
Changed the Python link on the Documentation page to link to the new
Python docs (docs.notifications.service.gov.uk/python.html) instead of
the Python client GitHub repo.
2018-04-19 09:51:13 +01:00
Chris Hill-Scott
25061dd052 Merge pull request #2025 from alphagov/quis-patch-1
Add agreement signed by Calderdale
2018-04-18 15:28:24 +01:00
Chris Hill-Scott
8e34451c82 Add agreement signed by Calderdale 2018-04-18 15:05:55 +01:00
Chris Hill-Scott
eb9aed6d01 Cache GET /user response in Redis
In the same way, and for the same reasons that we’re caching the service
object.

Here’s a sample of the data returned by the API – so we should make sure
that any changes to this data invalidate the cache.

If we ever change a user’s phone number (for example) directly in the
database, then we will need to invalidate this cache manually.

```python
{  
   'data':{  
      'organisations':[  
         '4c707b81-4c6d-4d33-9376-17f0de6e0405'
      ],
      'logged_in_at':'2018-04-10T11:41:03.781990Z',
      'id':'2c45486e-177e-40b8-997d-5f4f81a461ca',
      'email_address':'test@example.gov.uk',
      'platform_admin':False,
      'password_changed_at':'2018-01-01 10:10:10.100000',
      'permissions':{  
         '42a9d4f2-1444-4e22-9133-52d9e406213f':[  
            'manage_api_keys',
            'send_letters',
            'manage_users',
            'manage_templates',
            'view_activity',
            'send_texts',
            'send_emails',
            'manage_settings'
         ],
         'a928eef8-0f25-41ca-b480-0447f29b2c20':[  
            'manage_users',
            'manage_templates',
            'manage_settings',
            'send_texts',
            'send_emails',
            'send_letters',
            'manage_api_keys',
            'view_activity'
         ],
      },
      'state':'active',
      'mobile_number':'07700900123',
      'failed_login_count':0,
      'name':'Example',
      'services':[  
         '6078a8c0-52f5-4c4f-b724-d7d1ff2d3884',
         '6afe3c1c-7fda-4d8d-aa8d-769c4bdf7803',
      ],
      'current_session_id':'fea2ade1-db0a-4c90-93e7-c64a877ce83e',
      'auth_type':'sms_auth'
   }
}
```
2018-04-18 13:27:11 +01:00
Chris Hill-Scott
777bfa2244 Merge pull request #2014 from alphagov/redis-spike-CHS
Use Redis to cache API calls in admin app
2018-04-18 13:26:12 +01:00
Chris Hill-Scott
2e999b5547 Merge pull request #1852 from alphagov/prototype-2
Add another prototyping app on PaaS
2018-04-12 16:58:28 +01:00
Chris Hill-Scott
eaf1534e9a Write manifests to disk instead of redirecting
Some time between version 6.32 and 6.34 of the Cloudfoundry CLI the
ability to redirect the output of a command into `cf push -f` was
broken.

The only alternative we can think of is writing the file to disk, doing
the deploy, and then deleting it.

We’re careful to write to a directory outside the current repo to avoid:
- including secrets in the deployed package
- accidentally checking the secrets into source control

`/tmp/` seems to be a good place to put it, since, even if the delete
doesn’t run, it will get cleaned up eventually (probably when the
machine next boots).

Right now this only applies to people deploying from their local
machines. At some point it will affect Jenkins too, but isn’t now. So
this commit only fixes the problem for the commands that developers run
locally.

fixup! Write manifests to disk instead of redirecting
2018-04-12 16:41:08 +01:00
Chris Hill-Scott
c0828a891b Create manifest-prototype-2-base.yml 2018-04-12 16:40:19 +01:00
Chris Hill-Scott
73163b9366 Merge pull request #2023 from alphagov/more-agreement-go-live-tweaks
More agreement go live tweaks
2018-04-12 14:47:27 +01:00