Replace sevice api client get template calls with Service methods

Instead of using the API client directly views are now calling one
of two Service model methods:

`get_template` is used for view actions, where the user should see
the template page even if they don't have access to the template
folder (since all templates are still inked from the dashboard or
the sent notifications pages).

`get_template_with_user_permission_or_403` will check if the user
has access to the template's folder first and return 403 otherwise.
This method is used for any endpoints that result in an action: editing
template attributes, deleting templates or sending messages.
This commit is contained in:
Alexey Bezhan
2019-03-19 16:25:44 +00:00
parent a30c9733b0
commit 35fb92c02c
5 changed files with 41 additions and 38 deletions

View File

@@ -835,7 +835,7 @@ def mock_get_template_versions(mocker, fake_uuid, user=None):
@pytest.fixture(scope='function')
def mock_get_service_template_with_placeholders(mocker):
def _get(service_id, template_id):
def _get(service_id, template_id, version=None):
template = template_json(
service_id, template_id, "Two week reminder", "sms", "((name)), Template <em>content</em> with & entity"
)
@@ -849,7 +849,7 @@ def mock_get_service_template_with_placeholders(mocker):
@pytest.fixture(scope='function')
def mock_get_service_template_with_placeholders_same_as_recipient(mocker):
def _get(service_id, template_id):
def _get(service_id, template_id, version=None):
template = template_json(
service_id, template_id, "Two week reminder", "sms", "((name)) ((date)) ((PHONENUMBER))"
)