Skip to content

Commit

Permalink
Add service setting to change annual limits for platform admins
Browse files Browse the repository at this point in the history
  • Loading branch information
whabanks committed Oct 22, 2024
1 parent 1d8c95d commit 10e3a28
Show file tree
Hide file tree
Showing 11 changed files with 300 additions and 34 deletions.
10 changes: 10 additions & 0 deletions app/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ class Config(object):
# FEATURE FLAGS
FF_SALESFORCE_CONTACT = env.bool("FF_SALESFORCE_CONTACT", True)
FF_RTL = env.bool("FF_RTL", True)
FF_ANNUAL_LIMIT = env.bool("FF_ANNUAL_LIMIT", True)

FREE_YEARLY_EMAIL_LIMIT = env.int("FREE_YEARLY_EMAIL_LIMIT", 10_000_000)
FREE_YEARLY_SMS_LIMIT = env.int("FREE_YEARLY_SMS_LIMIT", 25_000)
Expand Down Expand Up @@ -187,6 +188,7 @@ class Development(Config):
SESSION_PROTECTION = None
SYSTEM_STATUS_URL = "https://localhost:3000"
NO_BRANDING_ID = "0af93cf1-2c49-485f-878f-f3e662e651ef"
FF_ANNUAL_LIMIT = True


class Test(Development):
Expand Down Expand Up @@ -239,6 +241,13 @@ class ProductionFF(Config):
NO_BRANDING_ID = "0af93cf1-2c49-485f-878f-f3e662e651ef"

FF_RTL = False
FF_SPIKE_SMS_DAILY_LIMIT = True
FF_SMS_PARTS_UI = False
FF_BOUNCE_RATE_V1 = True
FF_BOUNCE_RATE_V15 = True
FF_BOUNCE_RATE_BACKEND = True
FF_ABTEST_SERVICE_ID = ""
FF_ANNUAL_LIMIT = False


class Production(Config):
Expand All @@ -255,6 +264,7 @@ class Staging(Production):
NOTIFY_LOG_LEVEL = "INFO"
SYSTEM_STATUS_URL = "https://status.staging.notification.cdssandbox.xyz"
NO_BRANDING_ID = "0af93cf1-2c49-485f-878f-f3e662e651ef"
FF_ANNUAL_LIMIT = True


class Scratch(Production):
Expand Down
92 changes: 77 additions & 15 deletions app/main/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,13 @@ 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):
Expand Down Expand Up @@ -640,7 +646,8 @@ 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(
Expand All @@ -652,7 +659,10 @@ 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),
],
)


Expand Down Expand Up @@ -745,7 +755,30 @@ 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),
],
)


class SMSAnnualMessageLimit(StripWhitespaceForm):
message_limit = IntegerField(
_l("Annual text message limit"),
validators=[
DataRequired(message=_l("This cannot be empty")),
validators.NumberRange(min=1),
],
)


class EmailAnnualMessageLimit(StripWhitespaceForm):
message_limit = IntegerField(
_l("Annual email message limit"),
validators=[
DataRequired(message=_l("This cannot be empty")),
validators.NumberRange(min=1),
],
)


Expand Down Expand Up @@ -817,10 +850,14 @@ 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)],
)


Expand All @@ -838,7 +875,10 @@ 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"),
Expand Down Expand Up @@ -949,7 +989,10 @@ 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):
Expand Down Expand Up @@ -990,7 +1033,10 @@ 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),
],
)


Expand Down Expand Up @@ -1578,7 +1624,10 @@ 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)
Expand All @@ -1587,7 +1636,10 @@ 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"))
Expand Down Expand Up @@ -1871,9 +1923,18 @@ 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=[
Expand All @@ -1889,7 +1950,8 @@ 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(
Expand Down
Loading

0 comments on commit 10e3a28

Please sign in to comment.