mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-05-13 16:17:01 +02:00
Add migration and documentation
This commit is contained in:
parent
6ad2546a40
commit
cbf1a24b4e
3 changed files with 47 additions and 1 deletions
|
@ -405,3 +405,11 @@ This function is triggered by the post_save event on the User model, designed to
|
||||||
1. For New Users: Upon the creation of a new user, it checks for an existing `Contact` by email. If no matching contact is found, it creates a new Contact using the user's details from Login.gov. If a matching contact is found, it associates this contact with the user. In cases where multiple contacts with the same email exist, it logs a warning and associates the first contact found.
|
1. For New Users: Upon the creation of a new user, it checks for an existing `Contact` by email. If no matching contact is found, it creates a new Contact using the user's details from Login.gov. If a matching contact is found, it associates this contact with the user. In cases where multiple contacts with the same email exist, it logs a warning and associates the first contact found.
|
||||||
|
|
||||||
2. For Existing Users: For users logging in subsequent times, the function ensures that any updates from Login.gov are applied to the associated User record. However, it does not alter any existing Contact records.
|
2. For Existing Users: For users logging in subsequent times, the function ensures that any updates from Login.gov are applied to the associated User record. However, it does not alter any existing Contact records.
|
||||||
|
|
||||||
|
## Disable email sending (toggling the disable_email_sending switch)
|
||||||
|
Feature switches are booleans that behave like environment variables that you can toggle through the DB.
|
||||||
|
This switch globally disables our email sending feature. Using it is as simple as checking a box.
|
||||||
|
1. On the app, navigate to `\admin`.
|
||||||
|
2. Under models, click `Waffle switches`.
|
||||||
|
3. Click the `disable_email_sending` record. This should exist by default, if not - create one with that name.
|
||||||
|
4. (Important) Enable the checkbox for the field `Active`. This field overrides all other settings
|
37
src/registrar/migrations/0097_create_groups_v13.py
Normal file
37
src/registrar/migrations/0097_create_groups_v13.py
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
# This migration creates the create_full_access_group and create_cisa_analyst_group groups
|
||||||
|
# It is dependent on 0079 (which populates federal agencies)
|
||||||
|
# If permissions on the groups need changing, edit CISA_ANALYST_GROUP_PERMISSIONS
|
||||||
|
# in the user_group model then:
|
||||||
|
# [NOT RECOMMENDED]
|
||||||
|
# step 1: docker-compose exec app ./manage.py migrate --fake registrar 0035_contenttypes_permissions
|
||||||
|
# step 2: docker-compose exec app ./manage.py migrate registrar 0036_create_groups
|
||||||
|
# step 3: fake run the latest migration in the migrations list
|
||||||
|
# [RECOMMENDED]
|
||||||
|
# Alternatively:
|
||||||
|
# step 1: duplicate the migration that loads data
|
||||||
|
# step 2: docker-compose exec app ./manage.py migrate
|
||||||
|
|
||||||
|
from django.db import migrations
|
||||||
|
from registrar.models import UserGroup
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
|
|
||||||
|
# For linting: RunPython expects a function reference,
|
||||||
|
# so let's give it one
|
||||||
|
def create_groups(apps, schema_editor) -> Any:
|
||||||
|
UserGroup.create_cisa_analyst_group(apps, schema_editor)
|
||||||
|
UserGroup.create_full_access_group(apps, schema_editor)
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
dependencies = [
|
||||||
|
("registrar", "0096_waffleswitch"),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.RunPython(
|
||||||
|
create_groups,
|
||||||
|
reverse_code=migrations.RunPython.noop,
|
||||||
|
atomic=True,
|
||||||
|
),
|
||||||
|
]
|
|
@ -9,6 +9,7 @@ from email.mime.application import MIMEApplication
|
||||||
from email.mime.multipart import MIMEMultipart
|
from email.mime.multipart import MIMEMultipart
|
||||||
from email.mime.text import MIMEText
|
from email.mime.text import MIMEText
|
||||||
from waffle import switch_is_active
|
from waffle import switch_is_active
|
||||||
|
from django.conf import settings
|
||||||
|
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
@ -34,7 +35,7 @@ def send_templated_email(
|
||||||
context as Django's HTML templates. context gives additional information
|
context as Django's HTML templates. context gives additional information
|
||||||
that the template may use.
|
that the template may use.
|
||||||
"""
|
"""
|
||||||
if switch_is_active("disable_email_sending"):
|
if switch_is_active("disable_email_sending") and not settings.IS_PRODUCTION:
|
||||||
raise EmailSendingError("Could not send email. Email sending is disabled due to switch 'disable_email_sending'.")
|
raise EmailSendingError("Could not send email. Email sending is disabled due to switch 'disable_email_sending'.")
|
||||||
|
|
||||||
logger.info(f"An email was sent! Template name: {template_name} to {to_address}")
|
logger.info(f"An email was sent! Template name: {template_name} to {to_address}")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue