Add domain field in Relay Address model

Set possible options for domain fields and set default domain
This commit is contained in:
Se Yeon Kim 2021-07-29 12:00:52 -05:00
Родитель 9a98ad04f3
Коммит 94b06cfca1
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 3F96D66EFEF597CC
3 изменённых файлов: 12 добавлений и 0 удалений

Просмотреть файл

@ -8,6 +8,7 @@ SECRET_KEY=unsafe-secret-key-for-dev-envs
ADMIN_ENABLED=
DEBUG=True
DJANGO_INTERNAL_IPS=127.0.0.1, localhost
ADDITIONAL_DOMAINS="mozmail.com,"
SENTRY_DSN=""
SERVE_ADDON="private_relay.zip"
AWS_REGION="us-east-1"

Просмотреть файл

@ -10,6 +10,7 @@ from django.conf import settings
from django.contrib.auth.models import User
from django.db import models
from emails.utils import get_email_domain_from_settings
emails_config = apps.get_app_config('emails')
@ -19,6 +20,10 @@ BounceStatus = namedtuple('BounceStatus', 'paused type')
NOT_PREMIUM_USER_ERR_MSG = 'You must be a premium subscriber to {}.'
TRY_DIFFERENT_VALUE_ERR_MSG = '{} could not be created, try using a different value.'
DOMAIN_DEFAULT = get_email_domain_from_settings()
DOMAIN_CHOICES = [(item, item) for item in settings.ADDITIONAL_DOMAINS]
DOMAIN_CHOICES.append((DOMAIN_DEFAULT, DOMAIN_DEFAULT))
class Profile(models.Model):
user = models.ForeignKey(User, on_delete=models.CASCADE)
@ -193,6 +198,11 @@ class RelayAddress(models.Model):
address = models.CharField(
max_length=64, default=address_default, unique=True
)
domain = models.CharField(
choices=DOMAIN_CHOICES,
default=DOMAIN_DEFAULT,
max_length=64
)
enabled = models.BooleanField(default=True)
description = models.CharField(max_length=64, blank=True)
created_at = models.DateTimeField(auto_now_add=True, db_index=True)

Просмотреть файл

@ -230,6 +230,7 @@ TEMPLATES = [
},
]
ADDITIONAL_DOMAINS = config('ADDITIONAL_DOMAINS', '', cast=str).split(',')
MAX_NUM_FREE_ALIASES = config('MAX_NUM_FREE_ALIASES', 5, cast=int)
PREMIUM_ENABLED = config('PREMIUM_ENABLED', default=False, cast=bool)
PREMIUM_PROD_ID = config('PREMIUM_PROD_ID', '', cast=str)