Commit Graph

356 Commits

Author SHA1 Message Date
Kenneth Kehl
ed3a356ad1 merge from main and fix some tests 2024-01-19 08:58:24 -08:00
Kenneth Kehl
567dd390b4 fix personalisation 2024-01-18 10:03:35 -08:00
Kenneth Kehl
c13ed73d23 substitute phone numbers back in when sending data to reports 2024-01-17 09:04:04 -08:00
Carlo Costino
5ae2335c82 Update failing test; include blackened files
Signed-off-by: Carlo Costino <carlo.costino@gsa.gov>
2023-12-06 11:11:00 -05:00
Carlo Costino
f72922ffb1 Remove unused variable
This changeset follows up PR #636 to remove a variable no longer used in the go live email template.

Signed-off-by: Carlo Costino <carlo.costino@gsa.gov>
2023-12-06 10:13:27 -05:00
Andrew Shumway
d0368695db Revert "Added flag to remove default sender from user list" 2023-11-06 11:49:17 -07:00
Andrew Shumway
9444310d4b Fix linting/imports 2023-11-02 16:21:02 -04:00
Andrew Shumway
32dca0f5e0 Add notification history and notification to count 2023-11-02 16:21:02 -04:00
Andrew Shumway
db7aa969cd Added api endpoint for count 2023-11-02 16:21:00 -04:00
Andrew Shumway
c247891c97 Add initial steps to call api for count 2023-11-02 16:18:02 -04:00
Andrew Shumway
c5e1452419 Update app/service/rest.py
Co-authored-by: Carlo Costino <ccostino@users.noreply.github.com>
2023-10-17 13:49:12 -06:00
Andrew Shumway
c7f11133d3 Added another flag in appropriate test 2023-10-16 15:02:52 -06:00
Andrew Shumway
e0522393df Added flag to remove default sender from user list 2023-10-15 16:28:25 -06:00
stvnrlly
8bfc64ebf9 insert total_message_limit into service creation 2023-09-06 12:26:37 -04:00
Kenneth Kehl
1ecb747c6d reformat 2023-08-29 14:54:30 -07:00
Kenneth Kehl
5a350560d7 notify-api-433b remove research mode 2023-08-25 12:09:00 -07:00
Kenneth Kehl
6fa4c05adf fix flake8 2023-07-21 10:42:17 -07:00
Kenneth Kehl
4940d5e93b notify-api-332 rename organisation 2023-07-10 11:06:29 -07:00
Kenneth Kehl
37e790f19f merge from main 2023-06-19 07:56:10 -07:00
Kenneth Kehl
e4a98dfcc2 cleanup, get rid of print statements, etc. 2023-06-15 10:45:03 -07:00
Kenneth Kehl
8db16f9410 fix tests 2023-06-15 08:23:00 -07:00
Kenneth Kehl
9f9e0a6ad8 notify-136 change financial year starting in april to calendar year (#278)
Co-authored-by: Kenneth Kehl <@kkehl@flexion.us>
2023-06-14 16:19:11 -04:00
Kenneth Kehl
e7196afde1 fix the inline display for Failed on the dashboard 2023-06-14 07:37:38 -07:00
Kenneth Kehl
008c3a8d68 initial 2023-06-13 12:57:51 -07:00
Kenneth Kehl
db0d829238 notify-281 fix time-sensitive tests 2023-05-31 17:52:16 -07:00
Kenneth Kehl
08c1ad75c8 notify-260 remove server-side timezone handling 2023-05-10 08:39:50 -07:00
Ryan Ahearn
e07b596857 Remove contact list db, dao, and s3 code 2023-04-12 15:01:24 -04:00
Steven Reilly
ff4190a8eb Remove letters-related code (#175)
This deletes a big ol' chunk of code related to letters. It's not everything—there are still a few things that might be tied to sms/email—but it's the the heart of letters function. SMS and email function should be untouched by this.

Areas affected:

- Things obviously about letters
- PDF tasks, used for precompiling letters
- Virus scanning, used for those PDFs
- FTP, used to send letters to the printer
- Postage stuff
2023-03-02 20:20:31 -05:00
stvnrlly
213f699c99 time adjustments in tests 2022-11-14 14:23:54 -05:00
stvnrlly
b50cb4712f tz utility swap and many test updates 2022-11-10 12:33:25 -05:00
stvnrlly
57f4df8ed1 remove broadcast-related code, except migrations 2022-10-04 15:28:27 +00:00
Katie Smith
8ae2b0bb31 Replace how .dump is called
As with `.load`, only data is now returned instead of a tuple.
2022-05-25 11:35:44 +01:00
Katie Smith
bd4f74b359 Replace how .load is called
https://marshmallow.readthedocs.io/en/stable/upgrading.html#schemas-are-always-strict

`.load` doesn't return a `(data, errors)` tuple any more - only data is
returned. A `ValidationError` is raised if validation fails. The code
now relies on the `marshmallow_validation_error` error handler to handle
errors instead of having to raise an `InvalidRequest`. This has no
effect on the response that is returned (a test has been modified to
check).

Also added a new `password` field to the `UserSchema` so that we don't
have to specially check for password errors in the `.create_user` endpoint
- we can let marshmallow handle them.
2022-05-25 11:35:44 +01:00
Chris Hill-Scott
a4347a5165 Remove endpoints for checking name uniqueness
The code which called these endpoints was removed:
- for services in https://github.com/alphagov/notifications-admin/pull/4084/files
- for organisations in https://github.com/alphagov/notifications-admin/pull/4128/files

Therefore these endpoints are no longer needed.
2022-01-13 17:12:40 +00:00
Katie Smith
0b7410818e Allow get_all_notifications_for_service to accept POST requests
We want admin to send a POST request to this route if the data contains
a message recipient (a phone number or email address) so that this does
not show in the logs. This changes the route to accept both GET and POST
requests.
2022-01-04 14:04:03 +00:00
David McDonald
7d8eed8228 Optimise queries run for creating pagination links
We have been running in to the problem in
pallets/flask-sqlalchemy#518 where
our page loads very slow when viewing a single page of notifications
for a service in the admin app. Tracing this back and using SQL
explain analyze I can see that getting the notifications takes about
a second but the second query to count how many notifications there
are (to work out if there is a next page of pagination) can take up
to 100 seconds.

As suggested in that issue, we do the pagination ourselves.
Our pagination doesn't need us to know exactly how many notifications
there are, just whether there are any on the next page and that can
be done without running the slow query to count how many
notifications in total by using `count_pages=False`.

This commit is analagous to
c68d1a2f23

The only difference is that in that case, the pagination links are
used to show prev and/or next links in the admin app. In this case,
the pagination links are only used to see if there is a page 2, and
if there is, say that we are only showing the first 50 results.
2021-12-10 17:47:27 +00:00
David McDonald
edadeb9131 Use get_prev_next_pagination_links when searching by to field
The only change in behaviour is that we are no longer including a
`last` pagination link.

This is OK because the frontend doesnt use it, just the prev and
next links as per
https://github.com/alphagov/notifications-admin/blob/master/app/main/views/jobs.py#L248
2021-12-10 12:29:55 +00:00
David McDonald
ec6ed3958c Move get_prev_next_pagination_links to utils
This will mean it can later be reused whereever we want
2021-12-10 12:26:57 +00:00
David McDonald
e8dd136678 Document area that may be doing pagination links when not needed 2021-12-03 17:32:40 +00:00
David McDonald
c68d1a2f23 Optimise queries run for creating pagination links
We have been running in to the problem in
https://github.com/pallets/flask-sqlalchemy/issues/518 where
our page loads very slow when viewing a single page of notifications
for a service in the admin app. Tracing this back and using SQL
explain analyze I can see that getting the notifications takes about
a second but the second query to count how many notifications there
are (to work out if there is a next page of pagination) can take up
to 100 seconds.

As suggested in that issue, we do the pagination ourselves.
Our pagination doesn't need us to know exactly how many notifications
there are, just whether there are any on the next page and that can
be done without running the slow query to count how many
notifications in total by using `count_pages=False`.
2021-12-03 17:32:39 +00:00
David McDonald
989ef9c21a Remove last and total keys from pagination links
These don't appear to be used anywhere in the admin app and this
route is only used by the admin app. Therefore it is safe to remove
them.

We remove them because the calculate the total number of notifications
or the final page number of results can be particularly slow for
services with many many notifications, for example 100 seconds
for a service with 500k notifications sent in the past 7 days.

Given neither are being used, this will give us the potential in
the next commit to reduce the number of slow queries and improve
page load times.

Note, I've kept the scope small by only introducing the new
pagination function for this one endpoint but there could be scope
in future to get all pagination using the next function if
appropriate.
2021-12-03 17:26:49 +00:00
Pea Tyczynska
0c8dd247f9 Show separate error for when user tries to cancel letter
that is already cancelled vs when it is too late to
cancel letter vs when we don't know what's the cause
of failure.

This is so we could show useful error messages to the users
and also for better debugging.
2021-07-29 11:32:49 +01:00
Katie Smith
fc0b9736eb Remove user permissions if service becomes a broadcast service
The "normal" service permissions and broadcast service permissions are
going to be different with no overlap. This means that if you were
viewing the team members page, there might be permissions in the
database that are not visible on the frontend if a service has changed
type. For example, someone could have the 'manage_api_keys' permission,
which would not show up on the team members page of a broadcast service.
To avoid people having permissions which aren't visible in admin, we now
remove all permissions from users when their service is converted to a
broadcast service.

Permisions for invited users are also removed.

It's not possible to convert a broadcast service to a normal service, so
we don't need to cover for this scenario.
2021-07-07 16:13:35 +01:00
Katie Smith
0f42b4dbec Fix the endpoint for the monthly status report
This wasn't working - the error given when trying to access it was
`TypeError: Object of type 'Row' is not JSON serializable` when we tried
to serialize a SQLAlchemy Row.

I haven't looked too far into what has changed to stop this from
working, but have just changed the endpoint to return a nested list instead.
2021-06-23 16:03:58 +01:00
Rebecca Law
d4009ffc52 Rename database management functions.
Rename @transactional to @autocommit.
Rename nested_transaction to tranaction.
2021-04-19 10:56:00 +01:00
Rebecca Law
93908bacda New strategy for transaction management.
Introduce a contextmanger function to handle exceptions and nested
transactions. Using the nested_transaction will start a
nested transaction with `db.session.begin_nested`, once the nested
transaction is complete the commit will happen.
`@transactional` has been updated to commit unless in a nested
transaction.
2021-04-14 07:04:17 +01:00
Rebecca Law
cf35135605 Adding @nested_transactional for transactions that require more than one
db update/insert.

Using a savepoint for the multiple transactions allows us to rollback if
there is an error when executing the second db transaction.
However, this does add a bit of complexity. Developers need to manage
the db session when calling multiple nested tranactions.

Unit tests have been added to test this functionality and some end to
end tests have been done to make sure all transactions are rollback if
there is an exception while executing the transaction.
2021-04-14 07:03:57 +01:00
Rebecca Law
9a03e579d6 When a service is created add the default annual billing for the service.
This will need to be merged before https://github.com/alphagov/notifications-admin/pull/3855, it will be that until the admin PR is merged the annual billing will be set twice, but that's not an issue.
2021-04-14 07:03:57 +01:00
Ben Thorner
a91fde2fda Run auto-correct on app/ and tests/ 2021-03-12 11:45:45 +00:00
David McDonald
6fcda6debb Make set_as_broadcast_service use a single DB commit
We don't want things in a half state if there is an error during the
method. Therefore, we move it all into a single function that is wrapped
in a transaction.

Note, we copy the approach of
https://github.com/alphagov/notifications-api/blob/master/app/dao/services_dao.py#L293
by having a single new dao function that does all the DB work.
2021-02-16 10:31:11 +00:00