-
Notifications
You must be signed in to change notification settings - Fork 11
TO-291: Add notifications model #639
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
Open
almeidaraul
wants to merge
8
commits into
main
Choose a base branch
from
TO-291/add-notifications-table
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 4 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
4b66845
feat: add notifications table
almeidaraul 25314cd
chore: add copyright to migration
almeidaraul e9f6c8d
Merge branch 'main' into TO-291/add-notifications-table
almeidaraul d1186b1
fix: broken migration order
almeidaraul 1d33dd8
fix: drop type notificationtype on migration downgrade
almeidaraul bcc57a7
Merge branch 'main' into TO-291/add-notifications-table
almeidaraul 5386f9e
Merge branch 'main' into TO-291/add-notifications-table
almeidaraul c8f041a
fix: format
almeidaraul File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
55 changes: 55 additions & 0 deletions
55
backend/migrations/versions/2026_03_10_1618-983168a63271_add_notifications.py
This file contains hidden or 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,55 @@ | ||
| # Copyright 2026 Canonical Ltd. | ||
| # | ||
| # This program is free software: you can redistribute it and/or modify | ||
| # it under the terms of the GNU Affero General Public License version 3, as | ||
| # published by the Free Software Foundation. | ||
| # This program is distributed in the hope that it will be useful, | ||
| # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| # GNU Affero General Public License for more details. | ||
| # You should have received a copy of the GNU Affero General Public License | ||
| # along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
| # | ||
| # SPDX-FileCopyrightText: Copyright 2026 Canonical Ltd. | ||
| # SPDX-License-Identifier: AGPL-3.0-only | ||
|
|
||
| """Add notifications | ||
|
|
||
| Revision ID: 983168a63271 | ||
| Revises: 3514f071a2e5 | ||
| Create Date: 2026-03-10 16:18:40.152277+00:00 | ||
|
|
||
| """ | ||
| from alembic import op | ||
| import sqlalchemy as sa | ||
| from sqlalchemy.dialects import postgresql | ||
|
|
||
| # revision identifiers, used by Alembic. | ||
| revision = '983168a63271' | ||
| down_revision = '3514f071a2e5' | ||
| branch_labels = None | ||
| depends_on = None | ||
|
|
||
|
|
||
| def upgrade() -> None: | ||
| # ### commands auto generated by Alembic - please adjust! ### | ||
| op.create_table('notification', | ||
| sa.Column('user_id', sa.Integer(), nullable=False), | ||
| sa.Column('notification_type', sa.Enum('USER_ASSIGNED_ARTEFACT_REVIEW', 'USER_ASSIGNED_ENVIRONMENT_REVIEW', name='notificationtype'), nullable=False), | ||
| sa.Column('target_url', sa.String(), nullable=True), | ||
| sa.Column('dismissed_at', sa.DateTime(), nullable=True), | ||
| sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), | ||
| sa.Column('created_at', sa.DateTime(), nullable=False), | ||
| sa.Column('updated_at', sa.DateTime(), nullable=False), | ||
| sa.ForeignKeyConstraint(['user_id'], ['app_user.id'], name=op.f('notification_user_id_fkey'), ondelete='CASCADE'), | ||
| sa.PrimaryKeyConstraint('id', name=op.f('notification_pkey')) | ||
| ) | ||
| op.create_index(op.f('notification_user_id_ix'), 'notification', ['user_id'], unique=False) | ||
| # ### end Alembic commands ### | ||
|
|
||
|
|
||
| def downgrade() -> None: | ||
| # ### commands auto generated by Alembic - please adjust! ### | ||
| op.drop_index(op.f('notification_user_id_ix'), table_name='notification') | ||
| op.drop_table('notification') | ||
almeidaraul marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| # ### end Alembic commands ### | ||
This file contains hidden or 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,35 @@ | ||
| # Copyright 2024 Canonical Ltd. | ||
| # | ||
| # This program is free software: you can redistribute it and/or modify | ||
| # it under the terms of the GNU Affero General Public License version 3, as | ||
| # published by the Free Software Foundation. | ||
| # This program is distributed in the hope that it will be useful, | ||
| # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| # GNU Affero General Public License for more details. | ||
| # You should have received a copy of the GNU Affero General Public License | ||
| # along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
| # | ||
| # SPDX-FileCopyrightText: Copyright 2024 Canonical Ltd. | ||
| # SPDX-License-Identifier: AGPL-3.0-only | ||
|
|
||
| from datetime import datetime | ||
|
|
||
| from pydantic import BaseModel, ConfigDict | ||
|
|
||
| from test_observer.data_access.models_enums import NotificationType | ||
|
|
||
|
|
||
| class NotificationResponse(BaseModel): | ||
| model_config = ConfigDict(from_attributes=True) | ||
|
|
||
| id: int | ||
| user_id: int | ||
| notification_type: NotificationType | ||
| target_url: str | None | ||
| created_at: datetime | ||
| dismissed_at: datetime | None | ||
|
|
||
|
|
||
| class NotificationsResponse(BaseModel): | ||
| notifications: list[NotificationResponse] |
This file contains hidden or 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 hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.