mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-18 13:39:41 -04:00
added organizationtype to enum
This commit is contained in:
17
app/enums.py
17
app/enums.py
@@ -36,7 +36,9 @@ class NotificationStatus(StrEnum):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def requested_statuses(cls):
|
def requested_statuses(cls):
|
||||||
return cls.sending_statuses() + cls.delivered_statuses() + cls.failure_statuses()
|
return (
|
||||||
|
cls.sending_statuses() + cls.delivered_statuses() + cls.failure_statuses()
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class NotificationType(StrEnum):
|
class NotificationType(StrEnum):
|
||||||
@@ -44,6 +46,12 @@ class NotificationType(StrEnum):
|
|||||||
SMS = "sms"
|
SMS = "sms"
|
||||||
|
|
||||||
|
|
||||||
|
class OrganizationType(StrEnum):
|
||||||
|
FEDERAL = "federal"
|
||||||
|
STATE = "state"
|
||||||
|
OTHER = "other"
|
||||||
|
|
||||||
|
|
||||||
class ApiKeyType(StrEnum):
|
class ApiKeyType(StrEnum):
|
||||||
NORMAL = "normal"
|
NORMAL = "normal"
|
||||||
TEAM = "team"
|
TEAM = "team"
|
||||||
@@ -80,10 +88,3 @@ class VerificationStatus(StrEnum):
|
|||||||
class AuthType(StrEnum):
|
class AuthType(StrEnum):
|
||||||
EMAIL_AUTH = "email_auth"
|
EMAIL_AUTH = "email_auth"
|
||||||
SMS_AUTH = "sms_auth"
|
SMS_AUTH = "sms_auth"
|
||||||
|
|
||||||
|
|
||||||
# TODO:
|
|
||||||
# class UserRole(StrEnum):
|
|
||||||
# ADMIN = "admin"
|
|
||||||
# USER = "user"
|
|
||||||
# GUEST = "guest"
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ from flask import current_app, redirect, render_template, session, url_for
|
|||||||
from flask_login import current_user
|
from flask_login import current_user
|
||||||
|
|
||||||
from app import service_api_client
|
from app import service_api_client
|
||||||
|
from app.enums import OrganizationType
|
||||||
from app.formatters import email_safe
|
from app.formatters import email_safe
|
||||||
from app.main import main
|
from app.main import main
|
||||||
from app.main.forms import CreateServiceForm
|
from app.main.forms import CreateServiceForm
|
||||||
@@ -46,7 +47,7 @@ def _create_example_template(service_id):
|
|||||||
def add_service():
|
def add_service():
|
||||||
default_organization_type = current_user.default_organization_type
|
default_organization_type = current_user.default_organization_type
|
||||||
if default_organization_type is None:
|
if default_organization_type is None:
|
||||||
default_organization_type = "federal"
|
default_organization_type = OrganizationType.FEDERAL
|
||||||
form = CreateServiceForm(
|
form = CreateServiceForm(
|
||||||
# This value is currently not useful but if it is not set it will result in a bug
|
# This value is currently not useful but if it is not set it will result in a bug
|
||||||
organization_type=default_organization_type
|
organization_type=default_organization_type
|
||||||
|
|||||||
@@ -2,14 +2,15 @@ from collections import OrderedDict
|
|||||||
|
|
||||||
from werkzeug.utils import cached_property
|
from werkzeug.utils import cached_property
|
||||||
|
|
||||||
|
from app.enums import OrganizationType
|
||||||
from app.models import JSONModel, ModelList, SerialisedModelCollection, SortByNameMixin
|
from app.models import JSONModel, ModelList, SerialisedModelCollection, SortByNameMixin
|
||||||
from app.notify_client.organizations_api_client import organizations_client
|
from app.notify_client.organizations_api_client import organizations_client
|
||||||
|
|
||||||
|
|
||||||
class Organization(JSONModel, SortByNameMixin):
|
class Organization(JSONModel, SortByNameMixin):
|
||||||
TYPE_FEDERAL = "federal"
|
TYPE_FEDERAL = OrganizationType.FEDERAL
|
||||||
TYPE_STATE = "state"
|
TYPE_STATE = OrganizationType.STATE
|
||||||
TYPE_OTHER = "other"
|
TYPE_OTHER = OrganizationType.OTHER
|
||||||
|
|
||||||
TYPE_LABELS = OrderedDict(
|
TYPE_LABELS = OrderedDict(
|
||||||
[
|
[
|
||||||
|
|||||||
@@ -322,7 +322,7 @@ class Service(JSONModel, SortByNameMixin):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def shouldnt_use_govuk_as_sms_sender(self):
|
def shouldnt_use_govuk_as_sms_sender(self):
|
||||||
return self.organization_type != Organization.TYPE_CENTRAL
|
return self.organization_type != Organization.TYPE_FEDERAL
|
||||||
|
|
||||||
@cached_property
|
@cached_property
|
||||||
def sms_senders(self):
|
def sms_senders(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user