Commit Graph

151 Commits

Author SHA1 Message Date
Pea Tyczynska
dcc590ec96 Cancelled notifications do not show as failures on dashboard stats
Also update tests after we no longer show cancelled letters
2019-01-10 15:27:04 +00:00
Alexey Bezhan
29bed8ba55 Add Service.get_templates method with filters by type and folder
With the addition of template folders we need to filter templates
based on a combination of type and parent folder ID.

This replaces the existing `templates_by_type` method with
`get_templates`, which supports both type and parent folder filters,
avoiding a need to create specific methods for each use case.

We still need the templates property to exist in some way in order
to cache it, but it needs to be clear that it's different from
`.get_templates`. One option was to make it "private" (i.e. `_templates`),
and always use `.get_templates` in the rest of the code, but this requires
adding "include all folders" to `.get_templates`, which doesn't have an
obvious interface since `parent_folder_id=None` already means "top-level
only".

This will probably come up again when we need to look into adding
templates from nested folders into the page for live search, but
for now renaming `Service.templates` to `.all_templates` makes it
clear what the property contains.
2018-11-06 13:13:13 +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
bbb4b87cac Show count of cancelled letters on dashboard 2018-10-29 11:51:43 +00:00
Chris Hill-Scott
c551ce9a42 Show jobs in basic view
There are some teams who send jobs on a daily/weekly basis. They have
team members who only use Notify for this purpose. So they would
probably benefit from basic view, because they don’t need to see the
dashboard.

This commit:
- adds a new item (uploaded files) to the basic view navigation for
  teams that have sent at least one job
- makes the job pages visible to basic view users

I think we should do this now, rather than as a later enhancement to
basic view. We only have one chance to announce the feature, so teams
who do send jobs may otherwise discount it as not useful for them and
the opportunity to have them use it is lost.
2018-08-01 10:45:02 +01:00
Chris Hill-Scott
036923c382 Make a service model and use for permissions
Having the service floating about as JSON is a bit flakey. Could easily
introduce a mistake where you mistype the name of a key and silently
get `None`.

Also means doing awkward things like `if 'permission' in
current_service['permissions']`, whereas for users we can do the
much cleaner `user.has_permission()`.

So this commit:
- introduces a model
- adds a `.has_permission` method similar to the one we have for users
2018-07-30 14:56:36 +01:00
Chris Hill-Scott
da49635cd0 Merge pull request #2083 from alphagov/bold-template
Make precompiled template name bold
2018-05-17 15:31:48 +01:00
Leo Hemsted
8864901690 add id to big received messages box 2018-05-16 12:31:54 +01:00
Chris Hill-Scott
2de17bd415 Make precompiled template name bold
To match template link.
2018-05-15 13:06:36 +01:00
chrisw
1d32c766e8 remove X messages from Y users msg 2018-04-04 15:43:07 +01:00
chrisw
f5c467e4ff add pagination to inbox page 2018-04-04 15:41:17 +01:00
Chris Waszczuk
6153389e01 Revert "add pagination to inbox page" 2018-04-04 14:18:03 +01:00
Chris Waszczuk
628d8ac5a8 Merge pull request #1985 from alphagov/add-pagination-to-inbox-page
add pagination to inbox page
2018-04-04 13:15:29 +01:00
chrisw
50661faac0 add pagination to inbox page 2018-04-03 12:12:30 +01:00
Rebecca Law
0d23c87599 In an attempts to reduce the traffice this pull request changes the interval the ajax calls to 5 seconds from 2 seconds for the dashboad page. 2018-03-29 15:42:19 +01:00
Chris Hill-Scott
9435f69a6e Remove warning banner from dashboard (and app)
We have teams who are using the dashboard every day, and being
confronted with this alarming yellow banner. There’s no action they need
to do since they’re only looking at the messages sent.

So this commit removes that banner from the dashboard. It also removes
the CSS and HTML for it from the app entirely because this is the last
remaining place we were using this style of banner.
2018-03-12 16:04:27 +00:00
kentsanggds
d11fafdf0d Merge pull request #1926 from alphagov/ken-remove-link-from-preview-precompiled
Remove link from preview precompiled view and dashboard
2018-03-08 15:28:47 +00:00
Ken Tsang
1d5f8ce15e Remove template link from precompiled letters from dashboard 2018-03-07 23:13:36 +00:00
Leo Hemsted
3afc193624 remove any_ from has_permissions
we branch on any_ to either say "require ALL these permissions" or
"require ANY of these permissions". But we only ever call the decorator
with one permission, or with any_=True, so it's unnecessary
2018-03-06 13:08:07 +00:00
Leo Hemsted
4a08cf81e7 remove admin_override from all has_permissions usage
as previously pointed out, it's not used anywhere.
2018-03-06 13:08:07 +00:00
Leo Hemsted
3ae815528c add restrict_admin_usage arg to admin_override
rather than allow admins to do everything specifically, we should
only block them from things we conciously don't want them to do.
This is "Don't let platform admins send letters from services they're
not in". Everything else the platform admins can do.

This is step one, adding a restrict_admin_usage flag, and setting that
for those restricted endpoints around creating api keys, uploading CSVs
and sending one-off messages.

Also, this commit separates the two use cases for permissions:
* user.has_permission for access control
* user.has_permission_for_service for user info - this is used for
  showing checkboxes on the manage-users page for example

With this, we can remove the admin_override flag from the permission
decorator.
2018-03-06 13:08:06 +00:00
Leo Hemsted
09824078dd remove all instances of db style permissions
lots of renaming of send_texts/emails/letters to send_messages, and
manage_settings/users to manage_service
2018-03-06 13:08:06 +00:00
Chris Waszczuk
c2136b0ffb Merge pull request #1768 from gov-cjwaszczuk/add-letters-to-monthly-messages-sent
Include letters on monthly messages sent
2018-02-07 10:52:52 +00:00
chrisw
82302626ad Include letters on monthly messages sent 2018-01-30 12:08:46 +00:00
Chris Hill-Scott
d9a63c07a9 Refactor user permissions to use args, not list
This makes the interface a bit cleaner and less verbose.
2018-01-16 11:22:57 +00:00
Chris Hill-Scott
a604ed60b6 Remove value of download attribute on links
We should standardise on <a download> rather than
<a download="download"> everywhere. The value of the download attribute
tells the browser what filename to use, but is overridden by the
Content-Disposition HTTP header. Since it’s not being used, we should
remove it for the sake of disambiguation.
2018-01-02 16:52:17 +00:00
Richard Chapman
1681b17fab Disabled the template_history endpoint
- Removed the code for the template_history endpoint and replaced with a
redirect to the new page so that anyone is forwarded on
- Updated the template to point to the new template_usage page
2017-11-24 14:36:36 +00:00
Chris Hill-Scott
1412933356 Make dashboard totals smaller if numbers are big
Numbers over a billion overflow the two column layout. Numbers over one
hundred thousand overflow the three column layout.

This commit makes the type size smaller in these cases, so that the
numbers still fit in the boxes.
2017-11-09 17:50:19 +00:00
Chris Hill-Scott
c9b2211bd3 Let users download a CSV of inbound messages
In user research, we’ve seen users copy/pasting the contents of the
inbound SMS page into a spreadsheet, in order to keep a record of the
messages they receive. They even went as far as to write a macro which
fixed the errors caused by copying and pasting.

It would be much easier if we just gave them the data already in a
spreadsheet format. Which is what this commit does.

One caveat is that, because spreadsheets can contain executable code (ie
formulas), and because we’re populating the spreadsheet with
user-submitted data (albeit via SMS) we need to be careful about
injection attacks.

The details of how these attacks work are detailed here (interesting
reading): http://georgemauer.net/2017/10/07/csv-injection.html

The mitigation is to not allow characters which initialise a formula
at the start of the cell.
2017-10-18 10:27:37 +01:00
chrisw
43395bc9d9 Added letters info to service / admin dashboard & activity page 2017-10-03 10:28:34 +01:00
Chris Hill-Scott
7e097e887e Make sure empty inbox also show the correct number
…since it’s divorced from the SMS sender now.
2017-08-24 13:57:12 +01:00
Chris Hill-Scott
d51ffe6b39 Use yellow warning banner for permissions message
The green bordered banner feels too much like ‘success’ or
‘confirmation’. Doesn’t feel like it’s something which just gives you
the status of a thing, or here’s a thing you should be aware of.
2017-07-27 11:52:54 +01:00
Chris Hill-Scott
5f6351762a Make inbox page update using AJAX
Fairly self-explanatory. Uses the same pattern of breaking things up
into functions as the jobs page.
2017-07-12 17:10:27 +01:00
Rebecca Law
1b1839ad30 The yearly usage section on the dashboard page takes too log as a result services with large yearly stats are timing out.
As a short term fix we have taken the yearly stats off the dashboard.

There is a plan to create permanent statistic tables to warehouse the data.
2017-07-03 11:35:55 +01:00
Chris Hill-Scott
9f20ea4b7e Revert "Merge pull request #1336 from alphagov/revert-show-notifications"
This reverts commit 7e354ff341, reversing
changes made to 6f3bcff32f.
2017-06-30 14:01:18 +01:00
kentsanggds
8202c44202 Merge pull request #1335 from alphagov/ken-use-new-service-permissions
Use new service permissions
2017-06-27 11:27:12 +01:00
Chris Hill-Scott
b450a349a3 Revert "Merge pull request #1328 from alphagov/notification-page-reworked"
This reverts commit 1797162248, reversing
changes made to 95b4d9eb31.
2017-06-23 15:56:25 +01:00
Ken Tsang
bcc45ede9c Refactored code for new service permissions 2017-06-23 14:27:41 +01:00
Chris Hill-Scott
010886e5be Make clickable areas bigger on tables with links
Generally, bigger click areas are better[1], as long as they don’t cause
ambiguity or accidental clicks.

This commit expands the clickable area of tables where the left-hand
column is a link to include the meta information under the link.

We can’t make the whole row clickable, because sometimes we have links
in the right hand column which go to a different place

This commit also removes the CSS for `.spark-bar-label`, because these
elements are visually identical to `file-list`s now.

1. https://en.wikipedia.org/wiki/Fitts%27s_law
2017-06-21 17:57:21 +01:00
Chris Hill-Scott
b8cc0de44e Use file list pattern for notifications
Most of our tables are now lists which have:
- a thing you click on
- some secondary info about that thing underneath
- some extra numbers/status on the right hand side

Since these are so similar, they should share the same pattern, which
this commit does (using the `file-list` pattern).

Visually this means:
- the secondary text on the inbox becomes grey not black, for
  consistency
- the status bit of the notifications tables bottom align like the
  status of messages in the inbox

These both seem like OK changes to make for the sake of consistency.
2017-06-21 17:57:20 +01:00
Chris Hill-Scott
f6d8e55579 Add two-way messaging view
> Once an inbound message has been received, there should be a way to
> see the other messages in the system from the same service to the same
> number. Both in and outbound. Nice inbox/whatsapp stylee view or some
> such. This way the context of the reply is understood.
>
> Initially will only see the outbound template, not the actual message,
> but we’re going to change this for the rest (soon), so that you can
> always see the full message for all outbound.
2017-06-10 12:03:10 +01:00
minglis
183c324f9a Merge pull request #1309 from alphagov/reinstate-new-rate-api
Reinstate new rate api
2017-06-08 14:07:33 +01:00
Martyn Inglis
784be721f4 Merge branch 'master' into reinstate-new-rate-api
Conflicts:
	app/main/views/dashboard.py
2017-06-07 14:44:27 +01:00
Chris Hill-Scott
313f669690 Roll up messages in inbox
The inbox should work a bit like the one on your phone. You shouldn’t
see all the messages, but the latest one from each of your ‘contacts’
only.
2017-06-06 15:15:36 +01:00
Chris Hill-Scott
67137f5570 Fix timestamp of latest inbound text on dashboard
Key was misnamed.
2017-06-06 12:44:59 +01:00
Chris Hill-Scott
85105fd6cd Only show inbound stuff if service has permission
Only services that have inbound SMS turned on should be able to see the
dashboard and ‘Received messages’ page.

There’s probably a cleaner way (decorator) of doing this permissions
stuff, but I think it can wait until we ship this.
2017-06-05 15:52:30 +01:00
Chris Hill-Scott
95e613c3f9 Clarify that big numbers mean ‘sent’
Since we now have inbound and outbound messages we should be clear about
which the counts refer to.
2017-06-05 15:51:30 +01:00
Chris Hill-Scott
e373296bd9 Show inbound messages on the dashboard
This commit adds two things:

a section on the dashboard to show how many inbound messages the
service has received in the last 7 days, and how recently an inbound
message has been received
---

Doesn’t show the contents of any messages, just like how the rest of the
dashboard is an aggregation, never individual messages.

a page to show all the inbound messages the service has received in
the last 7 days
---

This shows the first line of the message. Eventually this will link
through to a ‘conversation’ page, where a service can see all the
messages it’s received from a given phone number.
2017-06-05 15:42:36 +01:00
Martyn Inglis
0dbd3fa10d Revert "Merge pull request #1288 from alphagov/add-new-rate-logic"
This reverts commit adbff63d1f, reversing
changes made to 80f0b4b2a2.
2017-06-02 10:41:42 +01:00
Martyn Inglis
52326539d6 Wire in the new API method that calculates the total cost and total billable units.
- Used on dashboard to calculate free tier/cost
- Update tests to mock new method
- Two new tests to check output on dashboard page
2017-05-24 10:35:52 +01:00