Commit Graph

171 Commits

Author SHA1 Message Date
Leo Hemsted
d6de5508ca make sure static subdir 404s correctly
before each request, we put the current service on the flask session,
except for with the static folder, cos it's not needed.... except, if
we 404, then we return the 404 template, which checks if you're logged
in or not to display different nav bar items. This was crashing when
current_service wasn't set, so we now set it.

also cleaned up some imports and stuff in test files
2017-05-04 11:28:45 +01:00
Leo Hemsted
cf125d0a14 add sent as a new status
functions as delivered - shows up in delievered column, contributes
to delivered stats etc.
2017-04-27 16:17:10 +01:00
Ken Tsang
e5a377edd8 Add letter jobs page, client and test 2017-04-11 10:59:50 +01:00
Chris Hill-Scott
8df01f7f3f Fix future ‘last edited’ date
The `format_datetime_relative` filter is only used by the scheduling
stuff, which only deals with dates in the future.

When used on dates in the past (more than 1 day ago) it gets confused
and defaults to ‘tomorrow’.

The `format_delta` method does a similar thing, but works for past and
future dates.

Users can still click through to the next page to see the exact date and
time of the edits.
2017-04-06 11:20:47 +01:00
Leo Hemsted
a037cd53c8 move formatted_list to utils 2017-04-04 09:35:16 +01:00
Rebecca Law
f26c8e3ce1 Fix format_notification_status to handle the letter status.
Not sure what temp and perm failure should look like so I left them for now.
2017-03-20 16:25:07 +00:00
Chris Hill-Scott
536d091d85 Fix HTML showing up on the breaking change page
41fa158635 added a proper Jinja filter
for formatting lists, which was better than the previous macro-based
solution.

It didn’t, however, account for HTML properly. It  did the default Jinja
thing of escaping everything. Since we render lists of placeholders
by putting HTML before and after each item, this didn’t work (the HTML
got escaped and appeared on the page).

So this commit does the escaping of HTML outside Jinja, in the
user-submitted bits of the input only, then passes the whole thing
through as a `Markup` instance which doesn’t get escaped by Jinja.
2017-03-06 13:17:36 +00:00
Chris Hill-Scott
f54689a2b7 Merge pull request #1168 from alphagov/contact-letter-block
add letter_contact_block edit fields
2017-03-06 11:11:54 +00:00
Leo Hemsted
5c3588445e add letter_contact_block edit fields
no actual template functionality yet - just the ability for services
that have letters enabled to edit a 10 line block that will go on the
top right hand side of their letters with contact information
2017-03-03 16:18:59 +00:00
Leo Hemsted
9fda5d1847 remove remember_me cookie and related code 2017-02-27 15:18:18 +00:00
Leo Hemsted
f14a836baa check users' session id.
when a user enters their 2FA code, the API will store a random UUID
against them in the database - this code is then stored on the cookie
on the front end.

At the beginning of each authenticated request, we do the following
steps:
  * Retrieve the user's cookie, and get the user_id from it
  * Request that user's details from the database
  * populate current_user with the DB model
  * run the login_required decorator, which calls
    current_user.is_authenticated

is_authenticated now also checks that the database model matches the
cookie for session_id. The potential states and meanings are as follows:

 database | cookie | meaning
----------+--------+---------
 None     | None   | New user, or system just been deployed.
          |        | Redirect to start page.
----------+--------+---------
 'abc'    | None   | New browser (or cleared cookies). Redirect to
          |        | start page.
----------+--------+---------
 None     | 'abc'  | Invalid state (cookie is set from user obj, so
          |        | would only happen if DB is cleared)
----------+--------+---------
 'abc'    | 'abc'  | Same browser. Business as usual
----------+--------+---------
 'abc'    | 'def'  | Different browser in cookie - db has been changed
          |        | since then. Redirect to start
2017-02-22 17:31:13 +00:00
Leo Hemsted
c25fff9032 add tests for formatted_list 2017-02-17 10:39:52 +00:00
Leo Hemsted
41fa158635 error when users put non-GSM chars in a sms template
additionally, this moves the formatted_list jinja macro into a python
function, so that it can be called from the form validator
2017-02-17 10:39:52 +00:00
Chris Hill-Scott
97b02edbf9 Add introducer video to the product page
It’s always been the plan to put this video on the product page. Just
getting round to it now.

Watch the video here: https://www.youtube.com/watch?v=i2a2jiwYTd4

Uses the CSS developed by the service manual team, taken from here:
a5c613f07b/source/stylesheets/modules/_responsive-embed.scss
2017-01-23 16:25:11 +00:00
Leo Hemsted
88b848a4a3 bump utils to 13.1.0
brings in changes to allow logging json to sdout on cloudfoundry boxes
2017-01-17 11:44:42 +00:00
bandesz
10950bb8a6 Run on Paas 2017-01-17 11:44:42 +00:00
Imdad Ahad
59c7bc2e6f Refactor get notifications streaming including formatting 2017-01-13 11:35:27 +00:00
Chris Hill-Scott
810b613bc2 Remove nl2br Jinja filter
This was used when the code for previewing SMS templates lived in the
admin. ⌘F seems to suggest it’s not used anywhere else.
2016-12-20 11:10:38 +00:00
Martyn Inglis
994032a76f Switched off session protection
Many departments are reporting being logged out during usage of the app
This may be because they present differing IP addresses to Notify on different requests due to outbound proxies and so on
Swicthing session protection to None means and IP change won't log a user out.
2016-12-14 14:07:08 +00:00
Rebecca Law
0417fa3534 Remove unused import 2016-12-07 14:12:12 +00:00
Rebecca Law
4b5e4d2864 Added a new 400.html error page, this error page will only be used when we get an HTTPError from the api.
This was done to solve the problem of invitations expiring and the user getting a 500 error message, which says to try again.
2016-12-07 14:00:03 +00:00
Martyn Inglis
0bc48897f3 Adds statsd to the application
- statsd client from utils
- adds to logger an get same method based reporting as we do for the API.
2016-12-01 17:21:06 +00:00
Martyn Inglis
1384d2a61c Adds the request-id middleware to the admin app
- adds a request-id to each request and passes that through to the response
- this is picked up by the loggers and used to tie log events to a request
2016-11-30 16:59:47 +00:00
Chris Hill-Scott
274b2893f7 Merge pull request #979 from alphagov/4-days-scheduled
Allow a job to be scheduled any time in next 4 days
2016-11-03 10:24:07 +01:00
Chris Hill-Scott
4b0d8ec636 Use days of week, not month for scheduled jobs
Friday at 4pm is easier to understand than 14 October at 4pm, especially
when the UI you’ve used to choose this time has talked about days of the
week.
2016-10-31 09:14:05 +00:00
Leo Hemsted
f039397533 make letters error if user not logged in
also added tests for the various hiding logic points

also added new logged_in_client in conftest - so you dont need to
patch all those stupid API calls for get user and get service
2016-10-27 16:46:51 +01:00
Leo Hemsted
3058a7122e log exceptions in the admin app
(we weren't previously logging anything on error!)
2016-10-19 11:54:51 +01:00
Leo Hemsted
bd07aa97a7 remove monotonic as a dependency
"On Python 3.3 or newer, monotonic will be an alias of time.monotonic from the standard library"
2016-10-19 10:39:22 +01:00
Chris Hill-Scott
1fccc524a1 Remove documentation pages
These are out of date now and potentially misleading.

Adds a new error page for HTTP `410 GONE`. Looks like the 404 page, but
returns the appropriate error code to be a good web citizen.
2016-10-10 15:58:11 +01:00
Chris Hill-Scott
e095d6024c Revert "Remove Google Analytics"
This reverts commit f31170f5a2.
2016-10-05 10:55:04 +01:00
Chris Hill-Scott
f31170f5a2 Remove Google Analytics
Reverts https://github.com/alphagov/notifications-admin/pull/306

We’re not looking at the data from Analytics, so shouldn’t be collecting
it just in case.

<sup>Brought to you by the fun police.</sup>
2016-09-30 09:23:00 +01:00
Chris Hill-Scott
48891babc4 Add log of notifications to API integration page
Now that we’ve removed simulated notifications from the dashboard and
activity pages they’re not visible anywhere in the app.

While they should’t be visible to non-technical users, developers have
a real need for Notify to confirm that their code is doing what they
expect. This is needed especially when they’re just getting started with
Notify.

There’s no way of seeing this info from the API either, because a key
can only get notifications created with a key of that type.

It doesn’t make sense to make this a ‘mode’ of the dashboard or activity
because the information about notifications that developers need is
also different. So this commit adds up to 50 of the most recent
notifications sent via the API to the page that developers use as their
‘home’ page.

This also lets us explain the 7 days thing to developers via the
empty slate state of this area of the page.
2016-09-29 09:28:04 +01:00
Chris Hill-Scott
3e42042156 Add a page to manage a service’s whitelist
Services who are in alpha or building prototypes need a way of sending
to any email address or phone number without having to sign the MOU.

This commit adds a page where they can whitelist up to 5 email addresses
and 5 phone numbers.

It uses the ‘list entry’ UI pattern from the Digital Marketplace
frontend toolkit [1] [2] [3].

I had to do some modification:
- of the Javascript, to make it work with the GOV.UK Module pattern
- of the template to make it work with WTForms
- of the content security policy, because the list entry pattern uses
  Hogan[1], which needs to use `eval()` (this should be fine if we’re
  only allowing it for scripts that we serve)
- of our SASS lint config, to allow browser-targeting mixins to come
  after normal rules (so that they can override them)

This commit also adds a new form class to validate and populate the two
whitelists. The validation is fairly rudimentary at the moment, and
doesn’t highlight which item in the list has the error, but it’s
probably good enough.

The list can only be updated all-at-once, this is how it’s possible to
remove items from the list without having to make multiple `POST`
requests.

1. 434ad30791/toolkit/templates/forms/list-entry.html
2. 434ad30791/toolkit/scss/forms/_list-entry.scss
3. 434ad30791/toolkit/javascripts/list-entry.js
4. http://twitter.github.io/hogan.js/
2016-09-29 09:27:38 +01:00
Chris Hill-Scott
e9d230b9a4 Always show created time for sending state
When a notification is in `created` or `sending` the thing you care
about is how long it’s been sitting there.
2016-09-13 10:37:38 +01:00
Chris Hill-Scott
17d5af1a6e Show delivery time even for failed notifications
We reckon it’s probably still useful.
2016-09-13 10:37:38 +01:00
Chris Hill-Scott
2d7ed4d34f Fix overlapping text on tables of notifications
This commit changes the tables of notifications from 3 columns to two
columns. This is so the text has more room, so it doesn’t start
overlapping.

It also makes sure that if the recipient gets really long that it will
be cut off with an ellipsis, rather than overlapping…

I hypothesize that if a notification fails you probably don’t care when
it failed, just that it failed.
2016-09-13 10:37:38 +01:00
Chris Hill-Scott
3d8d160d3e Always use 12h times
The GOV.UK content style guide says:

> - 5:30pm (not 1730hrs)
> - midnight (not 00:00)
> - midday (not 12 noon, noon or 12pm)

This commit changes all times to be 12h not 24h, and adds a special case
for when a time is exactly 12:00am or 12:00pm.
2016-08-31 16:58:34 +01:00
Leo Hemsted
b983f020ff remove old statistics_api_client
now unused - replaced mock fn with detailed_services too
2016-08-24 16:26:08 +01:00
Leo Hemsted
fc14a800b5 remove print 2016-08-16 14:55:23 +01:00
Leo Hemsted
fb510d2522 only set organisation on GET and add allowed fields to service client
we were overwriting it before validating the form for POST, so lost info
2016-08-12 12:37:18 +01:00
Chris Hill-Scott
6b5e64479a Add a page to set organisation and branding option
Platform admin only.

Adds radio buttons to choose one of:
- three hard-coded branding options
- organisations from a list provided by the API
2016-08-12 10:31:43 +01:00
Chris Hill-Scott
45ae43d987 Include ‘created’ in ‘sending’ bucket
The difference between created and sending isn’t something a user should
have to care about. So this commit:
- counts created and sending as the same thing
- displays and notifications which have a status of created as sending
2016-08-05 10:59:49 +01:00
Martyn Inglis
47b8955a9a Fix import order so that configs work 2016-07-29 10:21:58 +01:00
Martyn Inglis
37167473b3 New property for environment 2016-07-29 10:21:26 +01:00
Martyn Inglis
4222027184 Updated config to be string based not class based and removed old style live/staging files. 2016-07-29 10:21:26 +01:00
Leo Hemsted
6ff77c995e add tests for service_api_client 2016-07-21 17:32:28 +01:00
Leo Hemsted
4451a8634d add detailed flag to GET service api client
returns current (past 7 days) notification stats as well as service info
2016-07-20 14:12:22 +01:00
Leo Hemsted
743a9d05d1 Merge pull request #794 from alphagov/refactior
Rename api_client to service_api_client
2016-07-19 13:26:34 +01:00
Leo Hemsted
1cd2841c17 rename api_client to service_api_client 2016-07-15 15:23:23 +01:00
Chris Hill-Scott
d380eaf060 Allow images to be served from live domain
Currently images in our email template are hardcoded to be served from
the live domain[1].

In order for the admin app, running locally or in preview/staging, to be
able to load these images when previewing an email template, the CSP
headers need to allow this domain.

Also splits the header string up using string literal concatenation[2]
so that it’s easier to read.

1. https://notifications.service.gov.uk
2. https://docs.python.org/3/reference/lexical_analysis.html#string-literal-concatenation
2016-07-12 16:46:46 +01:00