Commit Graph

6748 Commits

Author SHA1 Message Date
Chris Hill-Scott
684d4f7782 Refactor setting value on letter branding form
WTForms lets you pre-populate a form’s value by passing it in as an
argument to the constructor.

This will be good for us because it will let us access that value in
the constructor later on.
2018-11-06 13:00:30 +00:00
Chris Hill-Scott
72ddd107ef Merge pull request #2450 from alphagov/httpretty-no-more
Remove httpretty dependency
2018-11-06 12:59:32 +00:00
Chris Hill-Scott
1c9e42f85d Remove update_with_properties method
It’s more Pythonic, and better abstracted from the underlying API to
use keyword arguments instead.
2018-11-05 17:56:11 +00:00
Chris Hill-Scott
b3a7210baf Stop passing SMS sender when updating permissions
This is a redundant argument which no longer seems to be used by
anything.
2018-11-05 17:16:31 +00:00
Chris Hill-Scott
48b0d4194e Use model to toggle research mode
Just a nice bit of encapsulation, rather than passing `current_service`
through to a method on `current_service`.
2018-11-05 17:15:52 +00:00
Chris Hill-Scott
318f846630 Move service permission handle inside the model
These helper functions for modifying a service permission were just
floating around loose in the view code.

A much better home for them is on the model. This will also make it
easy to reuse them in other views if we ever need to.
2018-11-05 17:15:52 +00:00
Chris Hill-Scott
a69551b2cb Use model to update service properties
We have a lot of places in settings where we update something by passing
in the `service_id`. `current_service` already knows about `service_id`,
so it’s cleaner to encapsulate these updates inside the model.
2018-11-05 17:15:52 +00:00
Chris Hill-Scott
e6181637be Remove httpretty dependency
We don’t use it for anything.

Even the [commit that introduced it](494e49ee45) didn’t seem to actually use it.

Closes #2446
2018-11-05 15:52:05 +00:00
Chris Hill-Scott
ebea503968 Reduce logging noise in traceback output
When running tests locally Pytest returns a lot of captured logging info.

This is redundant because Pytest also captures stdout.

This commit effectively disables logging output when running tests by
setting the log level to higher than anything a real logging call would
ever emit.

The logging output is still captured by stdout, so nothing is lost here,
we’re just reducing duplication.
2018-11-05 15:45:12 +00:00
Chris Hill-Scott
c1bcfff895 Add link to .NET documentation 2018-11-05 15:17:12 +00:00
Chris Hill-Scott
3993e2cf28 Link to tech docs format for PHP and Node
They’re live 🎉 

One more to go…
2018-11-05 14:49:29 +00:00
Chris Hill-Scott
2286c19aa5 Merge pull request #2447 from alphagov/test
Mark agreement signed by Test Valley council
2018-11-05 11:10:55 +00:00
Chris Hill-Scott
e66be538ac Mark agreement signed by Test Valley council 2018-11-05 10:44:36 +00:00
pyup-bot
1bcaad2c71 Update pytest from 3.9.3 to 3.10.0 2018-11-04 16:58:25 +00:00
Chris Hill-Scott
ebe90d396e Merge pull request #2442 from alphagov/show-all-pages-notification
Show all letter pages on the notification page
2018-11-02 14:35:39 +00:00
Chris Hill-Scott
39c51dd994 Show all letter pages on the notification page
Sometimes a long placeholder can push stuff onto a new page, so we need
to take the personalisation into account when counting pages.
2018-11-02 14:30:18 +00:00
Chris Hill-Scott
549e48de49 Merge pull request #2434 from alphagov/send-one-off-letter
Let people send one-off letters from the admin app
2018-11-02 09:33:04 +00:00
Chris Hill-Scott
cf04d2fe92 Merge pull request #2439 from alphagov/fix-white-corner-cell-spreadsheet
Make the corner of the spreadsheet grey again
2018-11-01 16:13:57 +00:00
Chris Hill-Scott
1319de4b21 Make the corner of the spreadsheet grey again
It was being overriden to white by the scrollable table code.
2018-11-01 16:03:16 +00:00
Chris Hill-Scott
92aa144bf2 Merge pull request #2438 from alphagov/scrollable-spreadsheet
Make the example spreadsheet scroll horizontally
2018-11-01 15:53:00 +00:00
Chris Hill-Scott
6c746787c2 Merge pull request #2437 from alphagov/css-checkerboard
Put pattern behind logo images
2018-11-01 15:52:52 +00:00
Chris Hill-Scott
54bd321504 Make the example spreadsheet scroll horizontally
This replicates how we let large spreadsheets scroll horizontally.

Pro: this looks nicer and is more usable

Con: the code for this feels a bit fragile, especially the calling of
`.maintainWidth` twice, ie as many times as a it takes to get stuff to
render properly.
2018-11-01 15:31:14 +00:00
Chris Hill-Scott
8200514461 Fix double error border 2018-11-01 14:45:12 +00:00
Chris Hill-Scott
b7b5c844a7 Put pattern behind logo images
So that white on transparent images are visible.
2018-11-01 13:51:02 +00:00
Chris Hill-Scott
d6b785d3fa Style ‘Download PDF’ link 2018-10-31 14:29:38 +00:00
Chris Hill-Scott
1675e6c8d2 Show error banner for one off letter in trial mode
In trial mode you can’t send letters. But it’s still useful to be able
to build up a letter to see how it work.

Best place to put this error is before someone tries to send a letter
for real.
2018-10-31 14:25:49 +00:00
Chris Hill-Scott
a79dfd1d6e Always show download link for PDF
This feature is useful for people to try the letter thing out and see
how it feels, maybe print one on their own printer before incurring
cost.
2018-10-31 14:22:27 +00:00
Chris Hill-Scott
3a62946ecd Let people send one off letters
We didn’t used to allow this because it wasn’t really possible with the
old DVLA set up and we didn’t think there’s a need.

We think it’s possible now because, even though it’s cumbersome, it’s
better than the manual process.
2018-10-31 12:19:19 +00:00
Chris Hill-Scott
086b83d65b Merge pull request #2431 from alphagov/grid-invite
Fix misaligned elements on invite page
2018-10-31 10:09:12 +00:00
Chris Hill-Scott
9589bdb89c Merge pull request #2432 from alphagov/set-letter-pricing
Update pricing on page where you turn letters on
2018-10-31 10:08:59 +00:00
Chris Hill-Scott
1a87126bb3 Update pricing on page where you turn letters on
It didn’t match the new rates for 1st class.
2018-10-31 10:02:12 +00:00
Chris Hill-Scott
bf13ea021f Fix misaligned elements on invite page
This page doesn’t need a grid any more (everything goes full width).
2018-10-31 09:59:03 +00:00
Chris Hill-Scott
d26ddb48a7 Merge pull request #2423 from alphagov/make-service-model-wrap-more-things
Move more things from the view layer to the service model
2018-10-31 09:39:19 +00:00
Chris Hill-Scott
dea1ffa569 Merge pull request #2424 from alphagov/templates-page-spacing
Make spacing tighter on templates page
2018-10-31 09:39:00 +00:00
Chris Hill-Scott
dda37b6538 Remove unimplemented methods on service model
During the migration from the model inhereting from a `dict` to being a
plain object it was useful to have these exceptions raised for quicker
debugging.

Now that all the code which relied on these methods has gone it’s OK
to remove them (attempts to call them will fall through to Python’s
native exception handling).
2018-10-30 15:12:01 +00:00
Chris Hill-Scott
67534f838d Don’t allow use of .get() on service model
Making people use a property is a sure way to make sure they’re spelling
the name of the property correctly, and allows us to easily swap out
properties that call through to the underlying JSON, and properties
which are implemented as methods.

The API should always return something in the JSON for a property, even
if it’s just `None`.
2018-10-30 15:09:54 +00:00
Chris Hill-Scott
1e2608d2e0 Refactor settings page to use service model
There’s a lot of code in service settings which:
- talks to the API directly through the clients
- passes that information through to the Jinja template

By encapsulating this logic in the service model:
- the Jinja template can access the data directly
- the logic can be reused across multiple methods
2018-10-30 15:07:52 +00:00
Chris Hill-Scott
526f2d7900 Use service model for the copy page
The view here is rebuilding a pseudo-service object. Now that service
objects have templates it’s cleaner to use the actual service object.

Requires a small change to the `templates_by_type` method so that it can
filter by one or many template types (a user should be able to copy any
template whose type is enabled for their service, and the service
they’re copying from).
2018-10-30 15:05:47 +00:00
Chris Hill-Scott
7d57c73411 Import clients from own files, not from app.py
Being able to import things at the top level is much cleaner.
2018-10-30 15:03:42 +00:00
Chris Hill-Scott
e04b2b5631 Split models to prevent circular imports
This commit is the first step to disentangling the models from the API
clients. With the models in the same folder as the API clients it makes
it hard to import the API clients within the model without getting a
circular import.

After this commit the user API clients still has this problem, but at
least the service API client doesn’t.
2018-10-30 15:01:36 +00:00
Chris Hill-Scott
9e798506c5 Initialise clients outside the app
This avoids the annoying problem where you can’t import a client unless
the app has already been initialised.
2018-10-30 14:59:24 +00:00
Chris Hill-Scott
2bf2103cce Re-sort order in which clients are initialised
This separates the non-API clients from the API clients.
2018-10-30 14:57:16 +00:00
Chris Hill-Scott
e1197c54a5 Don’t allow indexing on service model
Making people use a property is a sure way to make sure they’re spelling
the name of the property correctly, and allows us to easily swap out
properties that call through to the underlying JSON, and properties
which are implemented as methods.
2018-10-30 14:55:01 +00:00
Chris Hill-Scott
780b9bb715 Use cached property from werkzeug.utils
This means we can have a method on the service model which hits the API
(or Redis) but can be called multiple times (within the context of a
request) without making multiple network requests.

It does this by storing the results of the method on the object’s
internal `__dict__` the first time the method is called.
2018-10-30 14:55:01 +00:00
Chris Hill-Scott
b48305c50d Don’t have service model inherit from dict
Inheriting from `dict` has some unexpected side effects that don’t
happen with plain object. The one we want to avoid right now is that
a dict doesn’t seem to implement `__dict__` in a normal way, which
is required by `werkzeug.utils.cached_property`.
2018-10-30 14:55:00 +00:00
Chris Hill-Scott
1e6b79a546 Put templates on service model
We do a lot of logic around choosing which templates to show. This logic
is all inside one view method.

It makes it cleaner to break this logic up into functions. But this
would mean passing around variables from one function to another.
Putting these methods onto a class (the service model) means that
there’s a place to store this data (rather than having to pass it around
a lot).

Making this code more manageable is important so that when we have
templates and folders it’s easy to encapsulate the logic around
combining the two.
2018-10-30 14:55:00 +00:00
Chris Hill-Scott
d69e8b50cd Only initialised service model once per request
`_get_current_service` is a function which gets called every time
`current_service` is referenced in a view method or Jinja template.

Because the service model was getting initialised inside this function
it was being reconstructed many times in one request. On the service
settings page, for example, it was getting initialised 43 times, adding
about 200ms to the response time.

This commit moves its initialisation to the point where we’re getting
the data from the API, which only happens once per request.
2018-10-30 14:55:00 +00:00
Katie Smith
1ffcbf5e91 Add test for the notifications page when there are failed notifications
We already have tests for the
/services/<service_id>/notifications/<notification_type> page, but these
were not testing the page when there were failed notifications, so this
adds a test for the page in this situation.
2018-10-30 13:15:31 +00:00
Chris Hill-Scott
3caaf74c4a Split paragraph into two
There was an awkward line break in this text, and the line length was
too long because there was no grid on the page.

Splitting it into two paragraphs makes it:
- read nicer
- avoids any awkward line breaks
2018-10-30 13:11:50 +00:00
Chris Hill-Scott
b727a50c13 Don’t have copy API key button jump around
It’s annoying that this button moves after you click on it. It’s
happening because the API key is wrapping onto multiple lines.

This commit fixes the height of the container so that it doesn’t reflow
when it has less content in it.

Uses a bit of flexbox to vertically centre the text.
2018-10-30 13:10:19 +00:00