-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Outlook: Allow custom reminder config (#183)
- Loading branch information
Showing
3 changed files
with
123 additions
and
19 deletions.
There are no files selected for viewing
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
55 changes: 55 additions & 0 deletions
55
outlook/indico_outlook/migrations/20241117_1113_da9deaa182a4_update_user_setting.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,55 @@ | ||
"""Update user setting | ||
Revision ID: da9deaa182a4 | ||
Revises: 6093a83228a7 | ||
Create Date: 2024-11-17 11:13:13.705549 | ||
""" | ||
|
||
from alembic import op | ||
|
||
|
||
# revision identifiers, used by Alembic. | ||
revision = 'da9deaa182a4' | ||
down_revision = '6093a83228a7' | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade(): | ||
# Rename status_overrides to overrides | ||
op.execute(''' | ||
UPDATE users.settings | ||
SET name = 'overrides' | ||
WHERE module = 'plugin_outlook' AND name = 'status_overrides' | ||
''') | ||
# Add the default settings | ||
op.execute(''' | ||
UPDATE users.settings | ||
SET value = ( | ||
SELECT jsonb_agg( | ||
elem || '{"reminder": true, "reminder_minutes": 15}' | ||
) | ||
FROM jsonb_array_elements(value) AS elem | ||
) | ||
WHERE module = 'plugin_outlook' AND name = 'overrides' | ||
''') | ||
|
||
|
||
def downgrade(): | ||
# Remove the default settings | ||
op.execute(''' | ||
UPDATE users.settings | ||
SET value = ( | ||
SELECT jsonb_agg( | ||
elem - 'reminder' - 'reminder_minutes' | ||
) | ||
FROM jsonb_array_elements(value) AS elem | ||
) | ||
WHERE module = 'plugin_outlook' AND name = 'overrides' | ||
''') | ||
# Rename the field back to status_overrides | ||
op.execute(''' | ||
UPDATE users.settings | ||
SET name = 'status_overrides' | ||
WHERE module = 'plugin_outlook' AND name = 'overrides' | ||
''') |
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