mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-04 18:31:13 -05:00
Merge pull request #606 from GSA/notify-admin-861
notify-admin-861 add preferred timezone
This commit is contained in:
@@ -123,6 +123,9 @@ class User(db.Model):
|
|||||||
nullable=False,
|
nullable=False,
|
||||||
default=datetime.datetime.utcnow,
|
default=datetime.datetime.utcnow,
|
||||||
)
|
)
|
||||||
|
preferred_timezone = db.Column(
|
||||||
|
db.Text, nullable=True, index=False, unique=False, default="US/Eastern"
|
||||||
|
)
|
||||||
|
|
||||||
# either email auth or a mobile number must be provided
|
# either email auth or a mobile number must be provided
|
||||||
CheckConstraint(
|
CheckConstraint(
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ Revises: 0399_remove_research_mode
|
|||||||
Create Date: 2023-04-24 11:35:22.873930
|
Create Date: 2023-04-24 11:35:22.873930
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
import datetime
|
||||||
import os
|
import os
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
@@ -30,10 +31,18 @@ def upgrade():
|
|||||||
"password": password,
|
"password": password,
|
||||||
"mobile_number": "+12025555555",
|
"mobile_number": "+12025555555",
|
||||||
"state": "active",
|
"state": "active",
|
||||||
|
"created_at": datetime.datetime.utcnow(),
|
||||||
|
"password_changed_at": datetime.datetime.utcnow(),
|
||||||
|
"failed_login_count": 0,
|
||||||
|
"platform_admin": "f",
|
||||||
|
"email_access_validated_at": datetime.datetime.utcnow(),
|
||||||
}
|
}
|
||||||
user = User(**data)
|
conn = op.get_bind()
|
||||||
db.session.add(user)
|
insert_sql = """
|
||||||
db.session.commit()
|
insert into users (id, name, email_address, _password, mobile_number, state, created_at, password_changed_at, failed_login_count, platform_admin, email_access_validated_at)
|
||||||
|
values (:id, :name, :email_address, :password, :mobile_number, :state, :created_at, :password_changed_at, :failed_login_count, :platform_admin, :email_access_validated_at)
|
||||||
|
"""
|
||||||
|
conn.execute(sa.text(insert_sql), data)
|
||||||
|
|
||||||
|
|
||||||
def downgrade():
|
def downgrade():
|
||||||
|
|||||||
21
migrations/versions/0405_add_preferred_timezone.py
Normal file
21
migrations/versions/0405_add_preferred_timezone.py
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
"""
|
||||||
|
|
||||||
|
Revision ID: 0405_add_preferred_timezone
|
||||||
|
Revises: 0404_expire_invites
|
||||||
|
|
||||||
|
"""
|
||||||
|
from alembic import op
|
||||||
|
from flask import current_app
|
||||||
|
import sqlalchemy as sa
|
||||||
|
|
||||||
|
|
||||||
|
down_revision = "0404_expire_invites"
|
||||||
|
revision = "0405_add_preferred_timezone"
|
||||||
|
|
||||||
|
|
||||||
|
def upgrade():
|
||||||
|
op.execute("ALTER TABLE users ADD COLUMN preferred_timezone text")
|
||||||
|
|
||||||
|
|
||||||
|
def downgrade():
|
||||||
|
op.execute("ALTER TABLE users DROP COLUMN preferred_timezone text")
|
||||||
Reference in New Issue
Block a user