Skip to content

Commit

Permalink
start removal of FF_TEMPLATE_CATEGORY (#1960)
Browse files Browse the repository at this point in the history
* start removal of FF_TEMPLATE_CATEGORY

* remove FF

* test(templates): update test to work without `FF_TEMPLATE_CATEGORY`

* chore(test_templates): rename variable

---------

Co-authored-by: Andrew Leith <[email protected]>
  • Loading branch information
jzbahrai and andrewleith authored Oct 2, 2024
1 parent 9916ce6 commit ec1aa29
Show file tree
Hide file tree
Showing 11 changed files with 224 additions and 453 deletions.
3 changes: 0 additions & 3 deletions app/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ class Config(object):
# FEATURE FLAGS
FF_NEW_BRANDING = env.bool("FF_NEW_BRANDING", False)
FF_SALESFORCE_CONTACT = env.bool("FF_SALESFORCE_CONTACT", True)
FF_TEMPLATE_CATEGORY = env.bool("FF_TEMPLATE_CATEGORY", False)
FF_TOU = env.bool("FF_TOU", False)

FREE_YEARLY_EMAIL_LIMIT = env.int("FREE_YEARLY_EMAIL_LIMIT", 10_000_000)
Expand Down Expand Up @@ -222,7 +221,6 @@ class Test(Development):
FF_ABTEST_SERVICE_ID = ""
FF_NEW_BRANDING = True
FF_TOU = True
FF_TEMPLATE_CATEGORY = True


class ProductionFF(Config):
Expand Down Expand Up @@ -256,7 +254,6 @@ class ProductionFF(Config):
FF_ABTEST_SERVICE_ID = ""
FF_NEW_BRANDING = True
FF_TOU = False
FF_TEMPLATE_CATEGORY = False


class Production(Config):
Expand Down
40 changes: 0 additions & 40 deletions app/main/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -797,46 +797,6 @@ class BaseTemplateForm(StripWhitespaceForm):
)


# TODO: Remove this class when FF_TEMPLATE_CATEGORY is removed
class SMSTemplateForm(BaseTemplateForm):
def validate_template_content(self, field):
OnlySMSCharacters()(None, field)

template_content = TextAreaField(
_l("Text message"),
validators=[
DataRequired(message=_l("This cannot be empty")),
NoCommasInPlaceHolders(),
],
)


# TODO: Remove this class when FF_TEMPLATE_CATEGORY is removed
class EmailTemplateForm(BaseTemplateForm):
subject = TextAreaField(_l("Subject line of the email"), validators=[DataRequired(message=_l("This cannot be empty"))])

template_content = TextAreaField(
_l("Email message"),
validators=[
DataRequired(message=_l("This cannot be empty")),
NoCommasInPlaceHolders(),
],
)


# TODO: Remove this class when FF_TEMPLATE_CATEGORY is removed
class LetterTemplateForm(EmailTemplateForm):
subject = TextAreaField("Main heading", validators=[DataRequired(message="This cannot be empty")])

template_content = TextAreaField(
"Body",
validators=[
DataRequired(message="This cannot be empty"),
NoCommasInPlaceHolders(),
],
)


class RequiredIf(InputRequired):
# a validator which makes a field required if
# another field is set and has a truthy value
Expand Down
69 changes: 23 additions & 46 deletions app/main/views/api_keys.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,11 @@
@main.route("/services/<service_id>/api")
@user_has_permissions("manage_api_keys")
def api_integration(service_id):
callbacks_link = ".api_callbacks" if current_service.has_permission(
"inbound_sms") else ".delivery_status_callback"
callbacks_link = ".api_callbacks" if current_service.has_permission("inbound_sms") else ".delivery_status_callback"
return render_template(
"views/api/index.html",
callbacks_link=callbacks_link,
api_notifications=notification_api_client.get_api_notifications_for_service(
service_id),
api_notifications=notification_api_client.get_api_notifications_for_service(service_id),
)


Expand Down Expand Up @@ -89,8 +87,7 @@ def create_api_key(service_id):
disabled_options, option_hints = [], {}
if current_service.trial_mode:
disabled_options = [KEY_TYPE_NORMAL]
option_hints[KEY_TYPE_NORMAL] = Markup(
_l("Not available because your service is in trial mode."))
option_hints[KEY_TYPE_NORMAL] = Markup(_l("Not available because your service is in trial mode."))
if current_service.has_permission("letter"):
option_hints[KEY_TYPE_TEAM] = ""
if form.validate_on_submit():
Expand Down Expand Up @@ -122,8 +119,7 @@ def revoke_api_key(service_id, key_id):
if request.method == "GET":
flash(
[
"{} ‘{}’?".format(
_l("Are you sure you want to revoke"), key_name),
"{} ‘{}’?".format(_l("Are you sure you want to revoke"), key_name),
_l("You will not be able to use this API key to connect to GC Notify"),
],
"revoke this API key",
Expand All @@ -141,11 +137,9 @@ def get_apis():
callback_api = None
inbound_api = None
if current_service.service_callback_api:
callback_api = service_api_client.get_service_callback_api(
current_service.id, current_service.service_callback_api[0])
callback_api = service_api_client.get_service_callback_api(current_service.id, current_service.service_callback_api[0])
if current_service.inbound_api:
inbound_api = service_api_client.get_service_inbound_api(
current_service.id, current_service.inbound_api[0])
inbound_api = service_api_client.get_service_inbound_api(current_service.id, current_service.inbound_api[0])

return (callback_api, inbound_api)

Expand All @@ -167,8 +161,7 @@ def api_callbacks(service_id):

return render_template(
"views/api/callbacks.html",
received_text_messages_callback=received_text_messages_callback[
"url"] if received_text_messages_callback else None,
received_text_messages_callback=received_text_messages_callback["url"] if received_text_messages_callback else None,
delivery_status_callback=delivery_status_callback["url"] if delivery_status_callback else None,
)

Expand All @@ -182,8 +175,7 @@ def get_delivery_status_callback_details():
@user_has_permissions("manage_api_keys")
def delete_delivery_status_callback(service_id):
delivery_status_callback = get_delivery_status_callback_details()
back_link = ".api_callbacks" if current_service.has_permission(
"inbound_sms") else ".api_integration"
back_link = ".api_callbacks" if current_service.has_permission("inbound_sms") else ".api_integration"
url_hint_txt = "Must start with https://"

if request.method == "POST":
Expand All @@ -193,23 +185,19 @@ def delete_delivery_status_callback(service_id):
delivery_status_callback["id"],
)

flash(_l("Your Callback configuration has been deleted."),
"default_with_tick")
flash(_l("Your Callback configuration has been deleted."), "default_with_tick")
return redirect(url_for(back_link, service_id=service_id))

flash(["{}".format(
_l("Are you sure you want to delete this callback configuration?"))], "delete")
flash(["{}".format(_l("Are you sure you want to delete this callback configuration?"))], "delete")

form = ServiceDeliveryStatusCallbackForm(
url=delivery_status_callback.get(
"url") if delivery_status_callback else "",
url=delivery_status_callback.get("url") if delivery_status_callback else "",
bearer_token=dummy_bearer_token if delivery_status_callback else "",
)

return render_template(
"views/api/callbacks/delivery-status-callback.html",
back_link=".api_callbacks" if current_service.has_permission(
"inbound_sms") else ".delivery_status_callback",
back_link=".api_callbacks" if current_service.has_permission("inbound_sms") else ".delivery_status_callback",
hint_text=url_hint_txt,
is_deleting=True,
form=form,
Expand All @@ -223,13 +211,11 @@ def delete_delivery_status_callback(service_id):
@user_has_permissions("manage_api_keys")
def delivery_status_callback(service_id):
delivery_status_callback = get_delivery_status_callback_details()
back_link = ".api_callbacks" if current_service.has_permission(
"inbound_sms") else ".api_integration"
back_link = ".api_callbacks" if current_service.has_permission("inbound_sms") else ".api_integration"
url_hint_txt = _l("Must start with https://")

form = ServiceDeliveryStatusCallbackForm(
url=delivery_status_callback.get(
"url") if delivery_status_callback else "",
url=delivery_status_callback.get("url") if delivery_status_callback else "",
bearer_token=dummy_bearer_token if delivery_status_callback else "",
)

Expand All @@ -244,8 +230,7 @@ def delivery_status_callback(service_id):
service_api_client.update_service_callback_api(
service_id,
url=form.url.data,
bearer_token=check_token_against_dummy_bearer(
form.bearer_token.data),
bearer_token=check_token_against_dummy_bearer(form.bearer_token.data),
user_id=current_user.id,
callback_api_id=delivery_status_callback.get("id"),
)
Expand Down Expand Up @@ -352,13 +337,11 @@ def get_received_text_messages_callback():
def received_text_messages_callback(service_id):
if not current_service.has_permission("inbound_sms"):
return redirect(url_for(".api_integration", service_id=service_id))
back_link = ".api_callbacks" if current_service.has_permission(
"inbound_sms") else ".api_integration"
back_link = ".api_callbacks" if current_service.has_permission("inbound_sms") else ".api_integration"

received_text_messages_callback = get_received_text_messages_callback()
form = ServiceReceiveMessagesCallbackForm(
url=received_text_messages_callback.get(
"url") if received_text_messages_callback else "",
url=received_text_messages_callback.get("url") if received_text_messages_callback else "",
bearer_token=dummy_bearer_token if received_text_messages_callback else "",
)
url_hint_txt = _l("Must start with https://")
Expand All @@ -373,8 +356,7 @@ def received_text_messages_callback(service_id):
service_api_client.update_service_inbound_api(
service_id,
url=form.url.data,
bearer_token=check_token_against_dummy_bearer(
form.bearer_token.data),
bearer_token=check_token_against_dummy_bearer(form.bearer_token.data),
user_id=current_user.id,
inbound_api_id=received_text_messages_callback.get("id"),
)
Expand Down Expand Up @@ -469,8 +451,7 @@ def received_text_messages_callback(service_id):
@user_has_permissions("manage_api_keys")
def delete_received_text_messages_callback(service_id):
received_text_messages_callback = get_received_text_messages_callback()
back_link = ".api_callbacks" if current_service.has_permission(
"inbound_sms") else ".api_integration"
back_link = ".api_callbacks" if current_service.has_permission("inbound_sms") else ".api_integration"
url_hint_txt = "Must start with https://"

if request.method == "POST":
Expand All @@ -480,23 +461,19 @@ def delete_received_text_messages_callback(service_id):
received_text_messages_callback["id"],
)

flash(_l("Your Callback configuration has been deleted."),
"default_with_tick")
flash(_l("Your Callback configuration has been deleted."), "default_with_tick")
return redirect(url_for(back_link, service_id=service_id))

flash(["{}".format(
_l("Are you sure you want to delete this callback configuration?"))], "delete")
flash(["{}".format(_l("Are you sure you want to delete this callback configuration?"))], "delete")

form = ServiceReceiveMessagesCallbackForm(
url=received_text_messages_callback.get(
"url") if delivery_status_callback else "",
url=received_text_messages_callback.get("url") if delivery_status_callback else "",
bearer_token=dummy_bearer_token if received_text_messages_callback else "",
)

return render_template(
"views/api/callbacks/delivery-status-callback.html",
back_link=".api_callbacks" if current_service.has_permission(
"inbound_sms") else ".delivery_status_callback",
back_link=".api_callbacks" if current_service.has_permission("inbound_sms") else ".delivery_status_callback",
hint_text=url_hint_txt,
is_deleting=True,
form=form,
Expand Down
Loading

0 comments on commit ec1aa29

Please sign in to comment.