Commit Graph

61 Commits

Author SHA1 Message Date
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
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