Talk about trial mode on API keys page

When you make a ‘normal’ API key it won’t work as described until your
serivce is live.

We should make this clear at the point at which you choose this key.
This commit is contained in:
Chris Hill-Scott
2016-08-10 16:49:25 +01:00
parent 981777a72a
commit e82cb21ecc
3 changed files with 11 additions and 6 deletions

View File

@@ -295,11 +295,6 @@ class CreateKeyForm(Form):
key_type = RadioField(
'What should Notify do when you use this key?',
choices=[
(KEY_TYPE_NORMAL, 'Send messages to anyone'),
(KEY_TYPE_TEST, 'Simulate sending messages to anyone'),
(KEY_TYPE_TEAM, 'Only send messages to members of your team')
],
validators=[
DataRequired()
]

View File

@@ -2,8 +2,9 @@ from flask import request, render_template, redirect, url_for, flash
from flask_login import login_required
from app.main import main
from app.main.forms import CreateKeyForm
from app import api_key_api_client
from app import api_key_api_client, current_service
from app.utils import user_has_permissions
from app.notify_client.api_key_api_client import KEY_TYPE_NORMAL, KEY_TYPE_TEST, KEY_TYPE_TEAM
@main.route("/services/<service_id>/api-keys")
@@ -24,6 +25,13 @@ def create_api_key(service_id):
key['name'] for key in api_key_api_client.get_api_keys(service_id=service_id)['apiKeys']
]
form = CreateKeyForm(key_names)
form.key_type.choices = [
(KEY_TYPE_NORMAL, 'Send messages to anyone{}'.format(
', once this service is not in trial mode' if current_service['restricted'] else ''
)),
(KEY_TYPE_TEST, 'Simulate sending messages to anyone'),
(KEY_TYPE_TEAM, 'Only send messages to members of your team')
]
if form.validate_on_submit():
secret = api_key_api_client.create_api_key(
service_id=service_id,

View File

@@ -12,6 +12,7 @@ def test_return_validation_error_when_key_name_exists(app_):
with app_.test_request_context():
form = CreateKeyForm(_get_names(),
formdata=MultiDict([('key_name', 'Some key')]))
form.key_type.choices = [('a', 'a'), ('b', 'b')]
form.validate()
assert form.errors['key_name'] == ['A key with this name already exists']
@@ -28,5 +29,6 @@ def test_return_validation_error_when_key_type_not_chosen(app_, key_type, expect
form = CreateKeyForm(
[],
formdata=MultiDict([('key_name', 'Some key'), ('key_type', key_type)]))
form.key_type.choices = [('a', 'a'), ('b', 'b')]
form.validate()
assert form.errors['key_type'] == [expected_error]