diff --git a/app/main/forms.py b/app/main/forms.py index e13b12132..b92c09eec 100644 --- a/app/main/forms.py +++ b/app/main/forms.py @@ -192,13 +192,7 @@ class TwoFactorCode(StringField): ] def __call__(self, **kwargs): - return super().__call__( - type="text", - inputmode="numeric", - autocomplete="one-time-code", - pattern="[0-9]*", - **kwargs, - ) + return super().__call__(type="text", inputmode="numeric", autocomplete="one-time-code", pattern="[0-9]*", **kwargs) class ForgivingIntegerField(StringField): @@ -646,8 +640,7 @@ class CreateServiceStepNameForm(StripWhitespaceForm): class CreateServiceStepCombinedOrganisationForm(StripWhitespaceForm): parent_organisation_name = StringField( - _l("Select your department or organisation"), - validators=[DataRequired(_l("Choose name from drop-down menu"))], + _l("Select your department or organisation"), validators=[DataRequired(_l("Choose name from drop-down menu"))] ) child_organisation_name = StringField( @@ -659,10 +652,7 @@ class CreateServiceStepCombinedOrganisationForm(StripWhitespaceForm): class CreateServiceStepOtherOrganisationForm(StripWhitespaceForm): other_organisation_name = StringField( _l("Enter name of your group"), - validators=[ - DataRequired(message=_l("Enter name to continue")), - Length(max=500), - ], + validators=[DataRequired(message=_l("Enter name to continue")), Length(max=500)], ) @@ -755,10 +745,7 @@ class EmailMessageLimit(StripWhitespaceForm): class SMSMessageLimit(StripWhitespaceForm): message_limit = IntegerField( _l("Daily text message limit"), - validators=[ - DataRequired(message=_l("This cannot be empty")), - validators.NumberRange(min=1), - ], + validators=[DataRequired(message=_l("This cannot be empty")), validators.NumberRange(min=1)], ) @@ -850,14 +837,10 @@ def __call__(self, form, field): class BaseTemplateFormWithCategory(BaseTemplateForm): - template_category_id = RadioField( - _l("Select category"), - validators=[DataRequired(message=_l("This cannot be empty"))], - ) + template_category_id = RadioField(_l("Select category"), validators=[DataRequired(message=_l("This cannot be empty"))]) template_category_other = StringField( - _l("Describe category"), - validators=[RequiredIf("template_category_id", DefaultTemplateCategories.LOW.value)], + _l("Describe category"), validators=[RequiredIf("template_category_id", DefaultTemplateCategories.LOW.value)] ) @@ -875,10 +858,7 @@ def validate_template_content(self, field): class EmailTemplateFormWithCategory(BaseTemplateFormWithCategory): - subject = TextAreaField( - _l("Subject line of the email"), - validators=[DataRequired(message=_l("This cannot be empty"))], - ) + subject = TextAreaField(_l("Subject line of the email"), validators=[DataRequired(message=_l("This cannot be empty"))]) template_content = TextAreaField( _l("Email content"), @@ -989,10 +969,7 @@ def __init__(self, existing_keys, *args, **kwargs): key_name = StringField( "Description of key", - validators=[ - DataRequired(message=_l("You need to give the key a name")), - Length(max=255), - ], + validators=[DataRequired(message=_l("You need to give the key a name")), Length(max=255)], ) def validate_key_name(self, key_name): @@ -1033,10 +1010,7 @@ class ContactNotify(StripWhitespaceForm): class ContactMessageStep(ContactNotify): message = TextAreaField( _l("Message"), - validators=[ - DataRequired(message=_l("You need to enter something if you want to contact us")), - Length(max=2000), - ], + validators=[DataRequired(message=_l("You need to enter something if you want to contact us")), Length(max=2000)], ) @@ -1624,10 +1598,7 @@ def __init__(self, *args, **kwargs): class AddEmailRecipientsForm(Form): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) - self.what_type.choices = [ - ("many_recipients", _l("Many recipients")), - ("one_recipient", _l("One recipient")), - ] + self.what_type.choices = [("many_recipients", _l("Many recipients")), ("one_recipient", _l("One recipient"))] what_type = RadioField("") placeholder_value = email_address(_l("Email address of recipient"), gov_user=False) @@ -1636,10 +1607,7 @@ def __init__(self, *args, **kwargs): class AddSMSRecipientsForm(Form): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) - self.what_type.choices = [ - ("many_recipients", _l("Many recipients")), - ("one_recipient", _l("One recipient")), - ] + self.what_type.choices = [("many_recipients", _l("Many recipients")), ("one_recipient", _l("One recipient"))] what_type = RadioField("") placeholder_value = international_phone_number(_l("Phone number of recipient")) @@ -1923,18 +1891,9 @@ class BrandingRequestForm(StripWhitespaceForm): file (FileField_wtf): Field for uploading the logo file. """ - name = StringField( - label=_l("Name of logo"), - validators=[DataRequired(message=_l("Enter the name of the logo"))], - ) - alt_text_en = StringField( - label=_l("English"), - validators=[DataRequired(message=_l("This cannot be empty"))], - ) - alt_text_fr = StringField( - label=_l("French"), - validators=[DataRequired(message=_l("This cannot be empty"))], - ) + name = StringField(label=_l("Name of logo"), validators=[DataRequired(message=_l("Enter the name of the logo"))]) + alt_text_en = StringField(label=_l("English"), validators=[DataRequired(message=_l("This cannot be empty"))]) + alt_text_fr = StringField(label=_l("French"), validators=[DataRequired(message=_l("This cannot be empty"))]) file = FileField_wtf( label=_l("Prepare your logo"), validators=[ @@ -1950,8 +1909,7 @@ class TemplateCategoryForm(StripWhitespaceForm): description_fr = StringField("FR") hidden = RadioField(_l("Hide category"), choices=[("True", _l("Hide")), ("False", _l("Show"))]) sms_sending_vehicle = RadioField( - _l("Sending method for text messages"), - choices=[("long_code", _l("Long code")), ("short_code", _l("Short code"))], + _l("Sending method for text messages"), choices=[("long_code", _l("Long code")), ("short_code", _l("Short code"))] ) email_process_type = RadioField( diff --git a/app/main/views/service_settings.py b/app/main/views/service_settings.py index d2433de3d..902a089f3 100644 --- a/app/main/views/service_settings.py +++ b/app/main/views/service_settings.py @@ -262,7 +262,7 @@ def use_case(service_id): display_org_question = not current_service.organisation_notes or not current_app.config["FF_SALESFORCE_CONTACT"] steps = [ { - "form": (GoLiveAboutServiceForm if display_org_question else GoLiveAboutServiceFormNoOrg), + "form": GoLiveAboutServiceForm if display_org_question else GoLiveAboutServiceFormNoOrg, "current_step": DEFAULT_STEP, "previous_step": None, "next_step": "about-notifications", @@ -271,7 +271,7 @@ def use_case(service_id): "back_link": url_for("main.request_to_go_live", service_id=current_service.id), }, { - "form": (GoLiveAboutNotificationsForm if display_org_question else GoLiveAboutNotificationsFormNoOrg), + "form": GoLiveAboutNotificationsForm if display_org_question else GoLiveAboutNotificationsFormNoOrg, "current_step": "about-notifications", "previous_step": DEFAULT_STEP, "next_step": None, @@ -398,10 +398,7 @@ def service_switch_live(service_id): ) -@main.route( - "/services//service-settings/set-sensitive-service", - methods=["GET", "POST"], -) +@main.route("/services//service-settings/set-sensitive-service", methods=["GET", "POST"]) @user_is_platform_admin def set_sensitive_service(service_id): title = _("Set sensitive service") @@ -708,7 +705,7 @@ def service_edit_email_reply_to(service_id, reply_to_email_id): current_service.id, reply_to_email_id=reply_to_email_id, email_address=form.email_address.data, - is_default=(True if reply_to_email_address["is_default"] else form.is_default.data), + is_default=True if reply_to_email_address["is_default"] else form.is_default.data, ) return redirect(url_for(".service_email_reply_to", service_id=service_id)) try: @@ -726,17 +723,14 @@ def service_edit_email_reply_to(service_id, reply_to_email_id): ".service_verify_reply_to_address", service_id=service_id, notification_id=notification_id, - is_default=(True if reply_to_email_address["is_default"] else form.is_default.data), + is_default=True if reply_to_email_address["is_default"] else form.is_default.data, replace=reply_to_email_id, ) ) if reply_to_email_address and request.endpoint == "main.service_confirm_delete_email_reply_to": if not reply_to_email_address["is_default"]: - flash( - _("Are you sure you want to delete this reply-to email address?"), - "delete", - ) + flash(_("Are you sure you want to delete this reply-to email address?"), "delete") elif current_service.count_email_reply_to_addresses == 1: flash(_("You're about to delete your default reply-to address."), "delete") elif current_service.email_reply_to_addresses and current_service.count_email_reply_to_addresses > 1: @@ -923,7 +917,7 @@ def service_add_letter_contact(service_id): new_letter_contact = service_api_client.add_letter_contact( current_service.id, contact_block=form.letter_contact_block.data.replace("\r", "") or None, - is_default=(first_contact_block if first_contact_block else form.is_default.data), + is_default=first_contact_block if first_contact_block else form.is_default.data, ) if from_template: service_api_client.update_service_template_sender( @@ -989,10 +983,7 @@ def service_make_blank_default_letter_contact(service_id): return redirect(url_for(".service_letter_contact_details", service_id=service_id)) -@main.route( - "/services//service-settings/letter-contact//delete", - methods=["POST"], -) +@main.route("/services//service-settings/letter-contact//delete", methods=["POST"]) @user_has_permissions("manage_service") def service_delete_letter_contact(service_id, letter_contact_id): service_api_client.delete_letter_contact( @@ -1117,17 +1108,10 @@ def set_message_limit(service_id): flash(_("An email has been sent to service users"), "default_with_tick") return redirect(url_for(".service_settings", service_id=service_id)) - return render_template( - "views/service-settings/set-message-limit.html", - form=form, - heading=_("Daily email limit"), - ) + return render_template("views/service-settings/set-message-limit.html", form=form, heading=_("Daily email limit")) -@main.route( - "/services//service-settings/set-sms-message-limit", - methods=["GET", "POST"], -) +@main.route("/services//service-settings/set-sms-message-limit", methods=["GET", "POST"]) @user_is_platform_admin def set_sms_message_limit(service_id): form = SMSMessageLimit(message_limit=current_service.sms_daily_limit) @@ -1145,10 +1129,7 @@ def set_sms_message_limit(service_id): ) -@main.route( - "/service//service_settings/set-sms-annual-limit", - methods=["GET", "POST"], -) +@main.route("/service//service_settings/set-sms-annual-limit", methods=["GET", "POST"]) @user_is_platform_admin @requires_feature("FF_ANNUAL_LIMIT") # TODO: FF_ANNUAL_LIMIT removal def set_sms_annual_limit(service_id): @@ -1167,10 +1148,7 @@ def set_sms_annual_limit(service_id): ) -@main.route( - "/service//service_settings/set-email-annual.html", - methods=["GET", "POST"], -) +@main.route("/service//service_settings/set-email-annual.html", methods=["GET", "POST"]) @user_is_platform_admin @requires_feature("FF_ANNUAL_LIMIT") # TODO: FF_ANNUAL_LIMIT removal def set_email_annual_limit(service_id): @@ -1189,10 +1167,7 @@ def set_email_annual_limit(service_id): ) -@main.route( - "/services//service-settings/set-free-sms-allowance", - methods=["GET", "POST"], -) +@main.route("/services//service-settings/set-free-sms-allowance", methods=["GET", "POST"]) @user_is_platform_admin def set_free_sms_allowance(service_id): form = FreeSMSAllowance(free_sms_allowance=current_service.free_sms_fragment_limit) @@ -1401,10 +1376,7 @@ def _get_current_branding(): else: branding_image_path = "https://{}/{}".format(cdn_url, current_service.email_branding["logo"]) - return { - "branding_image_path": branding_image_path, - "branding_name": current_service.email_branding_name, - } + return {"branding_image_path": branding_image_path, "branding_name": current_service.email_branding_name} branding = _get_current_branding() diff --git a/app/models/service.py b/app/models/service.py index d76482afd..9edf352f8 100644 --- a/app/models/service.py +++ b/app/models/service.py @@ -75,12 +75,7 @@ def update_count_as_live(self, count_as_live): return service_api_client.update_count_as_live(self.id, count_as_live=count_as_live) def update_status(self, live, message_limit, sms_daily_limit): - return service_api_client.update_status( - self.id, - live=live, - message_limit=message_limit, - sms_daily_limit=sms_daily_limit, - ) + return service_api_client.update_status(self.id, live=live, message_limit=message_limit, sms_daily_limit=sms_daily_limit) def force_permission(self, permission, on=False): permissions, permission = set(self.permissions), {permission} diff --git a/app/navigation.py b/app/navigation.py index e0dd9724b..0a0e6ca81 100644 --- a/app/navigation.py +++ b/app/navigation.py @@ -19,11 +19,7 @@ def endpoints_with_navigation(self): @property def endpoints_without_navigation(self): - return tuple("main.{}".format(endpoint) for endpoint in self.exclude) + ( - "static", - "status.show_status", - "status.debug", - ) + return tuple("main.{}".format(endpoint) for endpoint in self.exclude) + ("static", "status.show_status", "status.debug") def is_selected(self, navigation_item): if request.endpoint in self.mapping[navigation_item]: