Commit Graph

38 Commits

Author SHA1 Message Date
Cliff Hill
afc1de61f6 Even more cleanup.
Signed-off-by: Cliff Hill <Clifford.hill@gsa.gov>
2024-02-28 12:58:22 -05:00
Cliff Hill
985ad27b3e Getting imports right to use app.enums
Signed-off-by: Cliff Hill <Clifford.hill@gsa.gov>
2024-02-28 12:43:32 -05:00
Cliff Hill
908d695b54 More cleanup.
Signed-off-by: Cliff Hill <Clifford.hill@gsa.gov>
2024-02-28 12:43:31 -05:00
Kenneth Kehl
1ecb747c6d reformat 2023-08-29 14:54:30 -07: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
Katie Smith
b440f3f904 Use Draft-07 and Draft7Validator everywhere
We were using the Draft4Validator in one place, so this updates it to
the Draft7Validator instead.

The schemas were mostly using draft 4 of the JSON schema, though there
were a couple of schemas that were already of version 7. This updates
them all to version 7, which is the latest version fully supported by
the jsonschema Python package. There are some breaking changes in the
newer version of the schema, but I could not see anywhere would these
affect us. Some of these schemas were not valid in version 4, but are
now valid in version 7 because `"required": []` was not valid in earlier
versions.
2022-04-14 14:46:10 +01:00
Ben Thorner
a91fde2fda Run auto-correct on app/ and tests/ 2021-03-12 11:45:45 +00:00
Leo Hemsted
0282a76bf7 rename template.serialize to serialize_for_v2
make it clear that this is for the public api, and we shouldn't add
fields to it without considering impacts

also add the broadcast_messages relationship on service and template to
the exclude from the marshmallow schemas, so it's not included elsewhere
2020-07-06 16:42:31 +01:00
Katie Smith
98a69684c5 Update get_template_by_id_response & post_template_preview_response schemas
To check the format of postage. Neither of these two schemas are used
for validating - they seem to be added for reference.
2020-06-19 08:59:27 +01:00
Chris Hill-Scott
5ddb5a75da Use new properties of utils Templates
We’ve added some new properties to the templates in utils that we can
use instead of doing weird things like
`WithSubjectTemplate.__str__(another_instance)`
2020-04-15 16:40:42 +01:00
Chris Hill-Scott
054cd16d02 Ensure correct object renders V2 template preview
The `body` field of the ‘preview a template’ endpoint should contain the
content of the template with the placeholders replaced.

It should not be rendered into a plain text email, which does stuff like
normalising newlines (so `\r\n` becomes `\n`). However the object that
the `create_post_template_preview_response` function receives is an
instance of `PlainTextEmailTemplate`. So we can’t just call `str()` on
it. Instead we need to call the `__str__` method of
`WithSubjectTemplate` which gives us the result we want.

We were already doing this the right way in the V1 endpoint[1] but
forgot to do it here too.

1. 0108749daa/app/template/rest.py (L181-L184)
2020-04-07 17:09:59 +01:00
Chris Hill-Scott
025ac3ea89 Use same template to validate and send notification
To be absolutely sure that we can send a message we should also validate
it using the same template class that we use to render it.
2020-04-07 10:41:16 +01:00
Rebecca Law
6b09075779 Fix poorly written sentence 2019-11-22 11:02:22 +00:00
Rebecca Law
5d6886242b Check that the request payload data is valid json.
By adding `force=True` to request.get_json() the mime type is ignore. If the data is not valid json the method will return a `BadRequestError` we catch that and throw our own error with a clear error message "Invalid JSON supplied in POST data".
If the json is valid return the json data or an empty dict if None is passed in.

This PR improves the error messages if the json is invalid, previously, the error message was "None object type" message which is not very helpful.
2019-11-21 15:23:11 +00:00
Leo Hemsted
c78a5d8536 Merge pull request #2662 from alphagov/utils-bump
Utils bump
2019-11-21 15:23:11 +00:00
Chris Hill-Scott
aab36157a5 Test for HTML response in the schema
Because we test for the other properties in the schema.

Also sets `additionalProperties` to `False` so we’re forced to update
the schemas if we make similar changes in the future. This means
removing `created_by` from the test data because it’s not returned by
the real response.
2019-02-08 13:10:42 +00:00
Chris Hill-Scott
f185dbecbe Return rendered HTML when previewing a template
If you’re trying to show what a Notify email will look like in your
caseworking system all the API gives you at the moment is raw markdown
(with the placeholders replaced).

This isn’t that useful if your caseworkers have no idea what markdown
is. If we also give teams the HTML then they can embed this in their
systems, and the people using those systems will be able to see how
headings, bulleted lists, etc. look.
2019-02-07 17:43:46 +00:00
Pea Tyczynska
1b30e86707 Update v2 template schema to include postage 2018-12-21 16:37:52 +00:00
Chris Hill-Scott
04e41e3147 Return template name in public API
The use for the public template API is for building caseworking systems
or similar, where you might need a list of templates to pick from (ie
instead of using the Notify web interface to pick from and send a
message).

Right now our API isn’t returning the template name as part of the
response. The name is a useful, human-friendly way of identifying a
template.

This commit changes the response to include the name.

Some clients will need updating before this can be useful.
2017-08-15 14:46:30 +01:00
Leo Hemsted
da02ffa32f ensure template history serializes using template serialize fn 2017-08-09 12:24:35 +01:00
Martyn Inglis
0e38259cb4 Remove all DAO get service calls, replaced with reference to new service object in context. 2017-05-05 15:23:06 +01:00
Ken Tsang
a5e514c356 Refactored to use template response as template 2017-04-19 10:51:12 +01:00
Ken Tsang
89e244ccd2 First commit 2017-04-19 10:51:12 +01:00
Ken Tsang
f5da3574b5 Add get all templates schema 2017-04-19 10:51:12 +01:00
Ken Tsang
ccd25382ea Refactored post template 2017-04-11 16:37:30 +01:00
Ken Tsang
7c0aeca66e Removed unused imports 2017-04-11 16:19:43 +01:00
Ken Tsang
06ec7a59a6 Refactored code to personalise subject 2017-04-11 16:19:43 +01:00
Ken Tsang
eba88b08c5 Removed URI from preview response 2017-04-11 16:19:43 +01:00
Ken Tsang
dfaf38269b Refactored get template 2017-03-23 15:02:21 +00:00
Ken Tsang
50db538df7 Updated schema to remove redundant 'content' 2017-03-23 11:50:15 +00:00
Ken Tsang
22239deb90 Removed redundant try block 2017-03-22 14:01:04 +00:00
Ken Tsang
8e5266e89b Refactor and fix auth errors 2017-03-22 10:54:15 +00:00
Ken Tsang
b81d789307 Add preview endpoint and tests 2017-03-22 10:11:31 +00:00
Ken Tsang
fad67e1bdd Added schemas + tests & updated get template tests 2017-03-22 10:10:05 +00:00
Ken Tsang
ea8a3754a0 Updated schema to handle null updated_at 2017-03-15 15:48:28 +00:00
Ken Tsang
7558a7661a Updated schema description 2017-03-15 09:19:56 +00:00
Ken Tsang
a596a1bb87 Refactored tests and get template endpoint 2017-03-14 17:51:30 +00:00
Ken Tsang
9e4b1b2bfc Add schemas, endpoints and supporting tests 2017-03-14 15:40:38 +00:00