Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/deseng692 and deseng671: Updated video widget, made crucial changes to authoring loaders and actions, added columns to engagement and widget_video tables. #2592

Merged
merged 6 commits into from
Sep 20, 2024
13 changes: 13 additions & 0 deletions CHANGELOG.MD
Original file line number Diff line number Diff line change
@@ -1,4 +1,17 @@
## September 18, 2024

- **Feature** New Video Widget front end [🎟️ DESENG-692](https://citz-gdx.atlassian.net/browse/DESENG-692)
- Implemented Figma design
- Created custom layover bar for videos that shows video provider and has a custom logo
- Transcripts will not be implemented at this time

- Summary page in authoring section [🎟️ DESENG-671](https://citz-gdx.atlassian.net/browse/DESENG-671)
- Streamlined data loaders and actions to account for page changes
- Updated data structure so that summary data is pulled from engagement table
- Added 'description_title' column to engagement table

## September 12, 2024

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sure to also document the new work you did for the Summary section :)

- **Feature** New Summary page in authoring section [🎟️ DESENG-671](https://citz-gdx.atlassian.net/browse/DESENG-671)
- Fetches values
- Saves values to database
Expand Down
2 changes: 2 additions & 0 deletions docs/MET_database_ERD.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ erDiagram
integer id PK
string name
string description
string description_title
timestamp start_date
timestamp end_date
integer status_id FK "The id from engagement status"
Expand Down Expand Up @@ -123,6 +124,7 @@ erDiagram
integer widget_id FK "The id from widget"
integer engagement_id FK "The id from engagement"
string video_url
string title
string description
timestamp created_date
timestamp updated_date
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
"""added title column to widget_video table.

Revision ID: 9c1743047332
Revises: e706db763790
Create Date: 2024-09-16 13:09:41.765003

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = '9c1743047332'
down_revision = 'e706db763790'
branch_labels = None
depends_on = None


def upgrade():
op.add_column('widget_translation', sa.Column('video_title', sa.Text(), nullable=True))
op.add_column('widget_video', sa.Column('title', sa.Text(), nullable=True))


def downgrade():
op.drop_column('widget_translation', 'video_title')
op.drop_column('widget_video', 'title')
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
"""Added description_title column to engagement table.

Revision ID: df693f5ddaf9
Revises: 9c1743047332
Create Date: 2024-09-18 15:33:39.791300

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = 'df693f5ddaf9'
down_revision = '9c1743047332'
branch_labels = None
depends_on = None


def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('engagement_translation', sa.Column('description_title', sa.String(length=255), nullable=True))
op.add_column('engagement', sa.Column('description_title', sa.String(length=255), nullable=True))
# ### end Alembic commands ###


def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_column('engagement_translation', 'description_title')
op.drop_column('engagement', 'description_title')
# ### end Alembic commands ###
2 changes: 2 additions & 0 deletions met-api/src/met_api/models/engagement.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class Engagement(BaseModel):
name = db.Column(db.String(50))
description = db.Column(db.Text, unique=False, nullable=False)
rich_description = db.Column(JSON, unique=False, nullable=False)
description_title = db.Column(db.String(255), unique=False, nullable=False)
start_date = db.Column(db.DateTime)
end_date = db.Column(db.DateTime)
status_id = db.Column(db.Integer, ForeignKey(
Expand Down Expand Up @@ -131,6 +132,7 @@ def update_engagement(cls, engagement: EngagementSchema) -> Engagement:
'name': engagement.get('name', None),
'description': engagement.get('description', None),
'rich_description': engagement.get('rich_description', None),
'description_title': engagement.get('description_title', None),
'start_date': engagement.get('start_date', None),
'end_date': engagement.get('end_date', None),
'status_id': engagement.get('status_id', None),
Expand Down
1 change: 1 addition & 0 deletions met-api/src/met_api/models/engagement_translation.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class EngagementTranslation(BaseModel):
name = db.Column(db.String(50))
description = db.Column(db.Text())
rich_description = db.Column(JSON, unique=False, nullable=True)
description_title = db.Column(db.String(255))
content = db.Column(db.Text())
rich_content = db.Column(JSON, unique=False, nullable=True)
consent_message = db.Column(JSON, unique=False, nullable=True)
Expand Down
2 changes: 2 additions & 0 deletions met-api/src/met_api/models/widget_translation.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class WidgetTranslation(BaseModel): # pylint: disable=too-few-public-methods
poll_title = db.Column(db.String(255))
poll_description = db.Column(db.String(2048))
video_url = db.Column(db.String(255))
video_title = db.Column(db.Text(255))
video_description = db.Column(db.Text())

@classmethod
Expand Down Expand Up @@ -62,6 +63,7 @@ def __create_new_widget_translation_entity(translation):
poll_title=translation.get('poll_title', None),
poll_description=translation.get('poll_description', None),
video_url=translation.get('video_url', None),
video_title=translation.get('video_title', None),
video_description=translation.get('video_description', None),
)

Expand Down
1 change: 1 addition & 0 deletions met-api/src/met_api/models/widget_video.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class WidgetVideo(BaseModel): # pylint: disable=too-few-public-methods, too-man
widget_id = db.Column(db.Integer, ForeignKey('widget.id', ondelete='CASCADE'), nullable=True)
engagement_id = db.Column(db.Integer, ForeignKey('engagement.id', ondelete='CASCADE'), nullable=True)
video_url = db.Column(db.String(255), nullable=False)
title = db.Column(db.String(255), nullable=True)
description = db.Column(db.Text())

@classmethod
Expand Down
1 change: 1 addition & 0 deletions met-api/src/met_api/schemas/engagement.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class Meta: # pylint: disable=too-few-public-methods
name = fields.Str(data_key='name', required=True, validate=validate.Length(min=1, error='Name cannot be blank'))
description = fields.Str(data_key='description')
rich_description = fields.Str(data_key='rich_description')
description_title = fields.Str(data_key='description_title')
start_date = fields.Date(data_key='start_date', required=True)
end_date = fields.Date(data_key='end_date', required=True)
status_id = fields.Int(data_key='status_id')
Expand Down
1 change: 1 addition & 0 deletions met-api/src/met_api/schemas/engagement_translation.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class Meta: # pylint: disable=too-few-public-methods
name = fields.Str(data_key='name')
description = fields.Str(data_key='description')
rich_description = fields.Str(data_key='rich_description')
description_title = fields.Str(data_key='description_title')
content = fields.Str(data_key='content')
rich_content = fields.Str(data_key='rich_content')
consent_message = fields.Str(data_key='consent_message')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@
"subscribe_item_id": 1,
"description": "Subscription description in Spanish",
"rich_description": "Rich text subscription description in Spanish",
"description_title": "Description title in Spanish.",
"call_to_action_text": "Subscribe Now",
"pre_populate" : false
"pre_populate": false
},
{
"language_id": 2,
Expand Down Expand Up @@ -47,6 +48,12 @@
"title": "Rich Description",
"description": "A more detailed and formatted translation of the subscribe item."
},
"description_title": {
"$id": "#/properties/description_title",
"type": "string",
"title": "Description Title",
"description": "A title that displays above your engagement description."
},
"call_to_action_text": {
"$id": "#/properties/call_to_action_text",
"type": "string",
Expand Down
40 changes: 24 additions & 16 deletions met-api/src/met_api/schemas/schemas/video_widget_update.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,33 @@
"default": {},
"examples": [
{
"description": "A video widget description",
"video_url": "https://www.youtube.com"
"description": "A video widget description",
"title": "A video widget title",
"video_url": "https://www.youtube.com"
}
],
"required": [],
"properties": {
"description": {
"$id": "#/properties/description",
"type": "string",
"title": "Video description",
"description": "The description of this video.",
"examples": ["A video widget description"]
},
"video_url": {
"$id": "#/properties/video_url",
"type": "string",
"title": "Video url",
"description": "The url link to this video.",
"examples": ["https://www.youtube.com"]
}
"description": {
"$id": "#/properties/description",
"type": "string",
"title": "Video description",
"description": "The description of this video.",
"examples": ["A video widget description"]
},
"title": {
"$id": "#/properties/title",
"type": "string",
"title": "Video title",
"description": "The title of this video.",
"examples": ["A video widget title"]
},
"video_url": {
"$id": "#/properties/video_url",
"type": "string",
"title": "Video url",
"description": "The url link to this video.",
"examples": ["https://www.youtube.com"]
}
}
}
1 change: 1 addition & 0 deletions met-api/src/met_api/schemas/widget_translation.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ class Meta: # pylint: disable=too-few-public-methods
poll_title = fields.Str(data_key='poll_title')
poll_description = fields.Str(data_key='poll_description')
video_url = fields.Str(data_key='video_url')
video_title = fields.Str(data_key='video_title')
video_description = fields.Str(data_key='video_description')
2 changes: 1 addition & 1 deletion met-api/src/met_api/schemas/widget_video.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ class Meta: # pylint: disable=too-few-public-methods
"""Videos all of the Widget Video fields to a default schema."""

model = WidgetVideoModel
fields = ('id', 'widget_id', 'engagement_id', 'video_url', 'description')
fields = ('id', 'widget_id', 'engagement_id', 'video_url', 'title', 'description')
1 change: 1 addition & 0 deletions met-api/src/met_api/services/engagement_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ def _create_engagement_model(engagement_data: dict) -> EngagementModel:
name=engagement_data.get('name', None),
description=engagement_data.get('description', None),
rich_description=engagement_data.get('rich_description', None),
description_title=engagement_data.get('description_title', None),
start_date=engagement_data.get('start_date', None),
end_date=engagement_data.get('end_date', None),
status_id=Status.Draft.value,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ def _get_default_language_values(engagement, content, translation_data):
translation_data['name'] = engagement.name
translation_data['description'] = engagement.description
translation_data['rich_description'] = engagement.rich_description
translation_data['description_title'] = engagement.description_title
translation_data['content'] = content.text_content
translation_data['rich_content'] = content.json_content
translation_data['consent_message'] = engagement.consent_message
Expand Down
1 change: 1 addition & 0 deletions met-api/src/met_api/services/widget_translation_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ def _get_default_language_values(widget, translation_data):
widget_video = WidgetVideoModel.get_video(widget_id)
if widget_video:
translation_data['video_url'] = widget_video[0].video_url
translation_data['video_title'] = widget_video[0].title
translation_data['video_description'] = widget_video[0].description

return translation_data
1 change: 1 addition & 0 deletions met-api/src/met_api/services/widget_video_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ def _create_video_model(widget_id, video_data: dict):
video_model.widget_id = widget_id
video_model.engagement_id = video_data.get('engagement_id')
video_model.video_url = video_data.get('video_url')
video_model.title = video_data.get('title')
video_model.description = video_data.get('description')
video_model.flush()
return video_model
2 changes: 2 additions & 0 deletions met-api/tests/unit/api/test_widget_video.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ def test_patch_video(client, jwt, session,
headers = factory_auth_header(jwt=jwt, claims=claims)

video_edits = {
'title': fake.text(max_nb_chars=20),
'description': fake.text(max_nb_chars=20),
'video_url': fake.url(),
}
Expand All @@ -136,6 +137,7 @@ def test_patch_video(client, jwt, session,
content_type=ContentType.JSON.value
)
assert rv.status_code == HTTPStatus.OK
assert rv.json[0].get('title') == video_edits.get('title')
assert rv.json[0].get('description') == video_edits.get('description')

with patch.object(WidgetVideoService, 'update_video',
Expand Down
7 changes: 6 additions & 1 deletion met-api/tests/utilities/factory_scenarios.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,8 @@ class TestEngagementInfo(dict, Enum):
'content': 'Content Sample',
'rich_content': '"{\"blocks\":[{\"key\":\"fclgj\",\"text\":\"Rich Content Sample\",\
\"type\":\"unstyled\",\"depth\":0,\
\"inlineStyleRanges\":[],\"entityRanges\":[],\"data\":{}}],\"entityMap\":{}}"'
\"inlineStyleRanges\":[],\"entityRanges\":[],\"data\":{}}],\"entityMap\":{}}"',
'description_title': 'My Test Description Title',
}

engagement_draft = {
Expand All @@ -210,6 +211,7 @@ class TestEngagementInfo(dict, Enum):
'rich_description': '"{\"blocks\":[{\"key\":\"2ku94\",\"text\":\"Rich Description Sample\",\
\"type\":\"unstyled\",\
\"depth\":0,\"inlineStyleRanges\":[],\"entityRanges\":[],\"data\":{}}],\"entityMap\":{}}"',
'description_title': 'My Test Description Title',
'content': 'Content Sample',
'rich_content': '"{\"blocks\":[{\"key\":\"fclgj\",\"text\":\"Rich Content Sample\",\
\"type\":\"unstyled\",\"depth\":0,\
Expand All @@ -229,6 +231,7 @@ class TestEngagementInfo(dict, Enum):
'rich_description': '"{\"blocks\":[{\"key\":\"2ku94\",\"text\":\"Rich Description Sample\",\
\"type\":\"unstyled\",\
\"depth\":0,\"inlineStyleRanges\":[],\"entityRanges\":[],\"data\":{}}],\"entityMap\":{}}"',
'description_title': 'My Test Description Title',
'content': 'Content Sample',
'rich_content': '"{\"blocks\":[{\"key\":\"fclgj\",\"text\":\"Rich Content Sample\",\
\"type\":\"unstyled\",\"depth\":0,\
Expand Down Expand Up @@ -256,6 +259,7 @@ class TestEngagementInfo(dict, Enum):
'rich_description': '"{\"blocks\":[{\"key\":\"2ku94\",\"text\":\"Rich Description Sample\",\
\"type\":\"unstyled\",\
\"depth\":0,\"inlineStyleRanges\":[],\"entityRanges\":[],\"data\":{}}],\"entityMap\":{}}"',
'description_title': 'My Test Description Title',
}


Expand Down Expand Up @@ -991,6 +995,7 @@ class TestEngagementTranslationInfo(dict, Enum):
'rich_content': '"{\"blocks\":[{\"key\":\"fclgj\",\"text\":\"Rich Content Sample\",\
\"type\":\"unstyled\",\"depth\":0,\
\"inlineStyleRanges\":[],\"entityRanges\":[],\"data\":{}}],\"entityMap\":{}}"',
'description_title': 'My Test Description Title',
}


Expand Down
2 changes: 2 additions & 0 deletions met-api/tests/utilities/factory_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ def factory_engagement_model(eng_info: dict = TestEngagementInfo.engagement1, na
name=name if name else fake.name(),
description=eng_info.get('description'),
rich_description=eng_info.get('rich_description'),
description_title=eng_info.get('description_title'),
created_by=eng_info.get('created_by'),
updated_by=eng_info.get('updated_by'),
status_id=status if status else eng_info.get('status'),
Expand Down Expand Up @@ -525,6 +526,7 @@ def factory_video_model(video_info: dict = TestWidgetVideo.video1):
"""Produce a comment model."""
video = WidgetVideoModel(
video_url=video_info.get('video_url'),
title=video_info.get('title'),
description=video_info.get('description'),
widget_id=video_info.get('widget_id'),
engagement_id=video_info.get('engagement_id'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export const engagementCreateAction: ActionFunction = async ({ request }) => {
is_internal: formData.get('is_internal') === 'true',
description: '',
rich_description: '',
description_title: '',
content: '',
rich_content: '',
});
Expand Down
Loading
Loading