Skip to content

Commit

Permalink
Merge branch 'main' into feature/deseng668
Browse files Browse the repository at this point in the history
  • Loading branch information
jareth-whitney committed Sep 3, 2024
2 parents 0702a23 + 69524c5 commit d0cc4f7
Show file tree
Hide file tree
Showing 57 changed files with 565 additions and 1,737 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/met-web-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:

strategy:
matrix:
node-version: [16.x]
node-version: [20.x]

steps:
- uses: actions/checkout@v3
Expand Down
23 changes: 18 additions & 5 deletions CHANGELOG.MD
Original file line number Diff line number Diff line change
@@ -1,13 +1,26 @@
## September 3, 2024
- **Feature** New authoring content section [🎟️ DESENG-668](https://citz-gdx.atlassian.net/browse/DESENG-668)
- Added skeletons

## August 23, 2024
- **Feature** New authoring content section [🎟️ DESENG-668](https://citz-gdx.atlassian.net/browse/DESENG-668)
- Implemented authoring side nav
- Implemented authoring bottom nav
- Implemented authoring section context
- Still working on skeletons
- Added skeletons for the required sections

## August 28, 2024

- **Bugfix** Fix keyboard focus being trapped on buttons on authoring page [🎟️ DESENG-687](https://citz-gdx.atlassian.net/browse/DESENG-687)

## August 27, 2024

- **Task** Upgrade to Node v20 [🎟️ DESENG-682](https://citz-gdx.atlassian.net/browse/DESENG-682)
- Upgraded deployment / CI configs to reference Node v20

## August 22, 2024

- **Task** Merge engagement summary content and custom content [🎟️ DESENG-676](https://citz-gdx.atlassian.net/browse/DESENG-676)
- Combine the text and rich content fields from redundant types SummaryContent and CustomContent and store them in
the existing EngagementContent table
- Update the API to handle the new content structure
- Todo: Update the frontend to properly leverage the new content structure and allow editing of the simplified content type

## August 21, 2024

Expand Down
24 changes: 24 additions & 0 deletions met-api/migrations/versions/42641011576a_.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
"""Merge revision heads
Revision ID: 42641011576a
Revises: c2a384ddfe6a, bd493dbd9e0e
Create Date: 2024-08-22 17:53:24.806016
"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = '42641011576a'
down_revision = ('c2a384ddfe6a', 'bd493dbd9e0e')
branch_labels = None
depends_on = None


def upgrade():
pass


def downgrade():
pass
112 changes: 112 additions & 0 deletions met-api/migrations/versions/bd493dbd9e0e_merge_engagement_content.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
"""Merge the engagement_summary_content and engagement_custom_content tables into the engagement_content table
Revision ID: bd493dbd9e0e
Revises: 901a6724bca2
Create Date: 2024-08-21 10:06:44.377763
"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql
from sqlalchemy.sql import table, column
import sqlalchemy as sa

# revision identifiers, used by Alembic.
revision = 'bd493dbd9e0e'
down_revision = '901a6724bca2'
branch_labels = None
depends_on = None


def upgrade():
# Create new columns in the engagement_content table
op.add_column('engagement_content', sa.Column('text_content', sa.Text(), nullable=True))
op.add_column('engagement_content', sa.Column('json_content', sa.JSON(), nullable=True))

# Reference the existing tables

engagement_content = table('engagement_content',
column('id', sa.Integer),
column('text_content', sa.Text),
column('json_content', sa.JSON)
)

engagement_summary_content = table('engagement_summary_content',
column('engagement_content_id', sa.Integer),
column('content', sa.Text),
column('rich_content', sa.JSON)
)

engagement_custom_content = table('engagement_custom_content',
column('engagement_content_id', sa.Integer),
column('custom_text_content', sa.Text),
column('custom_json_content', sa.JSON)
)

# Copy data from the old tables to the new columns in engagement_content
op.execute(
engagement_content.update()
.where(engagement_content.c.id == engagement_summary_content.c.engagement_content_id)
.values({
'text_content': engagement_summary_content.c.content,
'json_content': engagement_summary_content.c.rich_content
})
)

op.execute(
engagement_content.update()
.where(engagement_content.c.id == engagement_custom_content.c.engagement_content_id)
.values({
'text_content': engagement_custom_content.c.custom_text_content,
'json_content': engagement_custom_content.c.custom_json_content
})
)

# Drop old tables
op.drop_table('engagement_custom_content')
op.drop_table('engagement_summary_content')

# Drop the content_type column and icon name as they're no longer needed
op.drop_column('engagement_content', 'content_type')
op.drop_column('engagement_content', 'icon_name')


def downgrade():
# Recreate the old tables
op.create_table('engagement_summary_content',
sa.Column('created_date', postgresql.TIMESTAMP(), autoincrement=False, nullable=False),
sa.Column('updated_date', postgresql.TIMESTAMP(), autoincrement=False, nullable=True),
sa.Column('id', sa.INTEGER(), autoincrement=True, nullable=False),
sa.Column('content', sa.TEXT(), autoincrement=False, nullable=False),
sa.Column('rich_content', postgresql.JSON(astext_type=sa.Text()), autoincrement=False, nullable=False),
sa.Column('engagement_content_id', sa.INTEGER(), autoincrement=False, nullable=True),
sa.Column('engagement_id', sa.INTEGER(), autoincrement=False, nullable=True),
sa.Column('created_by', sa.VARCHAR(length=50), autoincrement=False, nullable=True),
sa.Column('updated_by', sa.VARCHAR(length=50), autoincrement=False, nullable=True),
sa.ForeignKeyConstraint(['engagement_content_id'], ['engagement_content.id'], name='engagement_summary_content_engagement_content_id_fkey', ondelete='CASCADE'),
sa.ForeignKeyConstraint(['engagement_id'], ['engagement.id'], name='engagement_summary_content_engagement_id_fkey', ondelete='CASCADE'),
sa.PrimaryKeyConstraint('id', name='engagement_summary_content_pkey')
)

op.create_table('engagement_custom_content',
sa.Column('created_date', postgresql.TIMESTAMP(), autoincrement=False, nullable=False),
sa.Column('updated_date', postgresql.TIMESTAMP(), autoincrement=False, nullable=True),
sa.Column('id', sa.INTEGER(), autoincrement=True, nullable=False),
sa.Column('custom_text_content', sa.TEXT(), autoincrement=False, nullable=True),
sa.Column('custom_json_content', postgresql.JSON(astext_type=sa.Text()), autoincrement=False, nullable=True),
sa.Column('engagement_content_id', sa.INTEGER(), autoincrement=False, nullable=True),
sa.Column('engagement_id', sa.INTEGER(), autoincrement=False, nullable=True),
sa.Column('created_by', sa.VARCHAR(length=50), autoincrement=False, nullable=True),
sa.Column('updated_by', sa.VARCHAR(length=50), autoincrement=False, nullable=True),
sa.ForeignKeyConstraint(['engagement_content_id'], ['engagement_content.id'], name='engagement_custom_content_engagement_content_id_fkey', ondelete='CASCADE'),
sa.ForeignKeyConstraint(['engagement_id'], ['engagement.id'], name='engagement_custom_content_engagement_id_fkey', ondelete='CASCADE'),
sa.PrimaryKeyConstraint('id', name='engagement_custom_content_pkey')
)

# Drop new columns in engagement_content table
op.drop_column('engagement_content', 'json_content')
op.drop_column('engagement_content', 'text_content')

# Re-add the content_type and icon_name columns
op.add_column('engagement_content', sa.Column('icon_name', sa.Text(), autoincrement=False, nullable=True))
op.add_column('engagement_content', sa.Column('content_type', postgresql.ENUM('Summary', 'Custom', name='engagementcontenttype'), autoincrement=False))
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@
from sqlalchemy import text
from sqlalchemy.dialects import postgresql

from met_api.constants.engagement_content_type import EngagementContentType
from met_api.utils.enums import ContentTitle

# revision identifiers, used by Alembic.
revision = 'e2625b0d07ab'
down_revision = '37176ea4708d'
Expand Down Expand Up @@ -90,9 +87,9 @@ def upgrade():
"""
),
{
'title': ContentTitle.DEFAULT.value,
'icon_name': ContentTitle.DEFAULT_ICON.value,
'content_type': EngagementContentType(1).name,
'title': "Summary",
'icon_name': "n/a",
'content_type': "n/a",
'engagement_id': eng_id,
},
)
Expand Down
33 changes: 0 additions & 33 deletions met-api/src/met_api/constants/engagement_content_type.py

This file was deleted.

2 changes: 0 additions & 2 deletions met-api/src/met_api/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
from .engagement_status import EngagementStatus
from .engagement_status_block import EngagementStatusBlock
from .engagement_settings import EngagementSettingsModel
from .engagement_custom_content import EngagementCustom
from .engagement_summary_content import EngagementSummary
from .event_item import EventItem
from .subscribe_item import SubscribeItem
from .feedback import Feedback
Expand Down
16 changes: 7 additions & 9 deletions met-api/src/met_api/models/engagement_content.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
from typing import Optional

from sqlalchemy.sql.schema import ForeignKey
from met_api.constants.engagement_content_type import EngagementContentType

from .base_model import BaseModel
from .db import db
Expand All @@ -21,24 +20,23 @@ class EngagementContent(BaseModel):
__tablename__ = 'engagement_content'
id = db.Column(db.Integer, primary_key=True, autoincrement=True)
title = db.Column(db.String(50), unique=False, nullable=False)
icon_name = db.Column(db.Text, unique=False, nullable=True)
content_type = db.Column(db.Enum(EngagementContentType), nullable=False,
default=EngagementContentType.Summary)
text_content = db.Column(db.Text, unique=False, nullable=True)
json_content = db.Column(db.JSON, unique=False, nullable=True)
engagement_id = db.Column(db.Integer, ForeignKey('engagement.id', ondelete='CASCADE'))
sort_index = db.Column(db.Integer, nullable=False, default=1)
is_internal = db.Column(db.Boolean, nullable=False)

@classmethod
def get_contents_by_engagement_id(cls, engagement_id):
"""Get contents by engagement id."""
def find_by_engagement_id(cls, engagement_id):
"""Get content by engagement id."""
return db.session.query(EngagementContent)\
.filter(EngagementContent.engagement_id == engagement_id)\
.order_by(EngagementContent.sort_index.asc())\
.all()

@classmethod
def update_engagement_contents(cls, update_mappings: list) -> None:
"""Update contents."""
def bulk_update_engagement_content(cls, update_mappings: list) -> None:
"""Update content."""
db.session.bulk_update_mappings(EngagementContent, update_mappings)
db.session.commit()

Expand All @@ -49,7 +47,7 @@ def save_engagement_content(cls, content: list) -> None:

@classmethod
def remove_engagement_content(cls, engagement_id, engagement_content_id,) -> EngagementContent:
"""Remove engagement content from engagement."""
"""Remove content from an engagement."""
engagement_content = EngagementContent.query.filter_by(id=engagement_content_id,
engagement_id=engagement_id).delete()
db.session.commit()
Expand Down
47 changes: 0 additions & 47 deletions met-api/src/met_api/models/engagement_custom_content.py

This file was deleted.

55 changes: 0 additions & 55 deletions met-api/src/met_api/models/engagement_summary_content.py

This file was deleted.

Loading

0 comments on commit d0cc4f7

Please sign in to comment.