-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'release-0.2.0' into fix/daniel-fix-frontend-allocation-…
…options-1321
- Loading branch information
Showing
51 changed files
with
1,899 additions
and
379 deletions.
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
backend/lcfs/db/migrations/versions/2024-12-05-02-19_b69a33bbd135.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
"""Add notifications email to user_profile | ||
Revision ID: b69a33bbd135 | ||
Revises: 8491890dd688 | ||
Create Date: 2024-12-05 20:48:24.724112 | ||
""" | ||
|
||
import sqlalchemy as sa | ||
from alembic import op | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = "b69a33bbd135" | ||
down_revision = "8491890dd688" | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade() -> None: | ||
# Add notifications_email column to user_profile table | ||
op.add_column( | ||
"user_profile", | ||
sa.Column( | ||
"notifications_email", | ||
sa.String(length=255), | ||
nullable=True, | ||
comment="Email address used for notifications", | ||
), | ||
) | ||
|
||
|
||
def downgrade() -> None: | ||
# Remove notifications_email column from user_profile table | ||
op.drop_column("user_profile", "notifications_email") |
87 changes: 87 additions & 0 deletions
87
backend/lcfs/db/migrations/versions/2024-12-05-02-20_d4104af84f2b.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
"""Update Notification Types and remove data | ||
Revision ID: d4104af84f2b | ||
Revises: b69a33bbd135 | ||
Create Date: 2024-12-05 02:20:33.898150 | ||
""" | ||
|
||
import sqlalchemy as sa | ||
from alembic import op | ||
from sqlalchemy.dialects.postgresql import ENUM | ||
|
||
# Revision identifiers, used by Alembic. | ||
revision = "d4104af84f2b" | ||
down_revision = "b69a33bbd135" | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade(): | ||
# Remove the notification types added in the previous migration | ||
op.execute("DELETE FROM notification_type;") | ||
|
||
# Alter the `name` column in `notification_type` to be a VARCHAR | ||
with op.batch_alter_table("notification_type") as batch_op: | ||
batch_op.alter_column( | ||
"name", | ||
existing_type=ENUM( | ||
"TRANSFER_PARTNER_UPDATE", | ||
"TRANSFER_DIRECTOR_REVIEW", | ||
"INITIATIVE_APPROVED", | ||
"INITIATIVE_DA_REQUEST", | ||
"SUPPLEMENTAL_REQUESTED", | ||
"DIRECTOR_ASSESSMENT", | ||
name="notification_type_enum_v2", | ||
), | ||
type_=sa.String(length=255), | ||
existing_nullable=False, | ||
) | ||
|
||
# Drop the old enum types | ||
op.execute("DROP TYPE IF EXISTS notification_type_enum_v2;") | ||
|
||
|
||
def downgrade(): | ||
# Re-create the old enum type | ||
notification_type_enum_v2 = ENUM( | ||
"TRANSFER_PARTNER_UPDATE", | ||
"TRANSFER_DIRECTOR_REVIEW", | ||
"INITIATIVE_APPROVED", | ||
"INITIATIVE_DA_REQUEST", | ||
"SUPPLEMENTAL_REQUESTED", | ||
"DIRECTOR_ASSESSMENT", | ||
name="notification_type_enum_v2", | ||
) | ||
notification_type_enum_v2.create(op.get_bind(), checkfirst=False) | ||
|
||
# Alter the `name` column back to the old enum | ||
with op.batch_alter_table("notification_type") as batch_op: | ||
batch_op.alter_column( | ||
"name", | ||
type_=notification_type_enum_v2, | ||
existing_type=sa.String(length=255), | ||
postgresql_using="name::text::notification_type_enum_v2", | ||
existing_nullable=False, | ||
) | ||
|
||
# Re-insert the previous notification types | ||
op.execute( | ||
""" | ||
INSERT INTO notification_type (notification_type_id, name, description, email_content, create_user, update_user) | ||
VALUES | ||
(1, 'TRANSFER_PARTNER_UPDATE', 'Transfer partner update notification', 'Email content for transfer partner update', 'system', 'system'), | ||
(2, 'TRANSFER_DIRECTOR_REVIEW', 'Director review notification', 'Email content for director review', 'system', 'system'), | ||
(3, 'INITIATIVE_APPROVED', 'Initiative approved notification', 'Email content for initiative approval', 'system', 'system'), | ||
(4, 'INITIATIVE_DA_REQUEST', 'DA request notification', 'Email content for DA request', 'system', 'system'), | ||
(5, 'SUPPLEMENTAL_REQUESTED', 'Supplemental requested notification', 'Email content for supplemental request', 'system', 'system'), | ||
(6, 'DIRECTOR_ASSESSMENT', 'Director assessment notification', 'Email content for director assessment', 'system', 'system'); | ||
""" | ||
) | ||
|
||
# Reset the sequence for the id column | ||
op.execute( | ||
""" | ||
SELECT setval('notification_type_id_seq', (SELECT MAX(notification_type_id) FROM notification_type)); | ||
""" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,17 @@ | ||
import enum | ||
from lcfs.db.base import BaseModel, Auditable | ||
from sqlalchemy import Column, Integer, Enum, Text | ||
from sqlalchemy import Column, Integer, Text, String | ||
from sqlalchemy.orm import relationship | ||
|
||
|
||
class NotificationTypeEnum(enum.Enum): | ||
TRANSFER_PARTNER_UPDATE = "Transfer partner proposed, declined, rescinded, or signed" | ||
TRANSFER_DIRECTOR_REVIEW = "Director recorded/refused" | ||
INITIATIVE_APPROVED = "Director approved" | ||
INITIATIVE_DA_REQUEST = "DA request" | ||
SUPPLEMENTAL_REQUESTED = "Supplemental requested" | ||
DIRECTOR_ASSESSMENT = "Director assessment" | ||
|
||
|
||
class NotificationType(BaseModel, Auditable): | ||
__tablename__ = "notification_type" | ||
__table_args__ = {"comment": "Represents a Notification type"} | ||
|
||
notification_type_id = Column(Integer, primary_key=True, autoincrement=True) | ||
name = Column( | ||
Enum(NotificationTypeEnum, name="notification_type_enum", create_type=True), | ||
nullable=False, | ||
) | ||
name = Column(String(255), nullable=False) | ||
description = Column(Text, nullable=True) | ||
email_content = Column(Text, nullable=True) | ||
|
||
subscriptions = relationship("NotificationChannelSubscription", back_populates="notification_type") | ||
subscriptions = relationship( | ||
"NotificationChannelSubscription", back_populates="notification_type" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.