Skip to content

Commit

Permalink
move customer address model into Sendmail app
Browse files Browse the repository at this point in the history
  • Loading branch information
jrief committed Dec 17, 2024
1 parent fff2102 commit a5ec805
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 38 deletions.
2 changes: 2 additions & 0 deletions demoapp/custom_user/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,6 @@ class CustomEmailAddress(AbstractEmailAddress, SwappableMetaMixin):
phone_number = models.CharField(max_length=20, blank=True, null=True)

class Meta:
app_label = 'sendmail'
db_table = 'custom_email_address'
verbose_name = 'Custom User'
68 changes: 31 additions & 37 deletions demoapp/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@
'NAME': os.getenv('DB_NAME', 'new_post_office'),
'USER': os.getenv('DB_USER', 'post_office'),
'PASSWORD': os.getenv('DB_PASSWORD','post_office'),
'HOST': os.getenv('DB_HOST','127.0.0.1'),
'HOST': os.getenv('DB_HOST','localhost'),
'PORT': os.getenv("DB_PORT", '5432'),
}

Expand Down Expand Up @@ -171,38 +171,34 @@
# EMAIL_HOST_PASSWORD = 'test'
#print(EMAIL_HOST, EMAIL_PORT, EMAIL_HOST_USER, EMAIL_HOST_PASSWORD)

TEMPLATES = [
{
'BACKEND': 'sendmail.template.backends.sendmail.SendMailTemplates',
'APP_DIRS': True,
'DIRS': [os.path.join(BASE_DIR / 'demoapp' / 'templates')],
'OPTIONS': {
'context_processors': [
'django.contrib.auth.context_processors.auth',
'django.template.context_processors.debug',
'django.template.context_processors.i18n',
'django.template.context_processors.media',
'django.template.context_processors.static',
'django.template.context_processors.tz',
'django.template.context_processors.request',
]
}
},
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
TEMPLATES = [{
'BACKEND': 'sendmail.template.backends.sendmail.SendMailTemplates',
'APP_DIRS': True,
'DIRS': [os.path.join(BASE_DIR / 'demoapp' / 'templates')],
'OPTIONS': {
'context_processors': [
'django.contrib.auth.context_processors.auth',
'django.template.context_processors.debug',
'django.template.context_processors.i18n',
'django.template.context_processors.media',
'django.template.context_processors.static',
'django.template.context_processors.tz',
'django.template.context_processors.request',
]
}
}, {
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},

]
}]

SENDMAIL = {
'TRACKING_ENABLED': True,
Expand Down Expand Up @@ -230,7 +226,7 @@
}
WSGI_APPLICATION = "demoapp.wsgi.application"
#EMAIL_ADDRESS_MODEL = 'sendmail.EmailAddress'
EMAIL_ADDRESS_MODEL = 'custom_user.CustomEmailAddress'
EMAIL_ADDRESS_MODEL = 'sendmail.CustomEmailAddress'
DATA_UPLOAD_MAX_NUMBER_FIELDS = 100000

# Database
Expand All @@ -241,9 +237,7 @@
# https://docs.djangoproject.com/en/3.0/ref/settings/#auth-password-validators

AUTH_PASSWORD_VALIDATORS = [
{
"NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator",
},
{"NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator",},
{"NAME": "django.contrib.auth.password_validation.MinimumLengthValidator", },
{"NAME": "django.contrib.auth.password_validation.CommonPasswordValidator", },
{"NAME": "django.contrib.auth.password_validation.NumericPasswordValidator", },
Expand Down Expand Up @@ -278,7 +272,7 @@
'JustifyRight', 'JustifyBlock'],
['Link', 'Unlink'],
['Image'],
['Format'] # Adding headers (e.g., Heading 1, Heading 2, etc.)
['Format'], # Adding headers (e.g., Heading 1, Heading 2, etc.)
],
'format_tags': 'p;h1;h2;h3;pre', # Define the available formats (headers and others)
}
Expand Down
2 changes: 1 addition & 1 deletion sendmail/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ def __init_subclass__(cls, **kwargs):
if not hasattr(cls, 'Meta'):
cls.Meta = type('Meta', (), {})

cls.Meta.swappable = get_email_address_setting()
cls.Meta.swappable = get_email_address_setting()

0 comments on commit a5ec805

Please sign in to comment.