Skip to content

Commit

Permalink
ADD column for optionally disabling notifications for assignments
Browse files Browse the repository at this point in the history
  • Loading branch information
wabscale committed Aug 31, 2022
1 parent b66a9dc commit 01f5038
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
3 changes: 2 additions & 1 deletion api/anubis/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class User(db.Model):
id = default_id()

# Fields
netid: str = Column(String(length=128), unique=True)
netid: str = Column(String(length=128), unique=True, nullable=False)
github_username = Column(Text(length=2 ** 14), index=True)
name = Column(Text(length=2 ** 14))
is_superuser: bool = Column(Boolean, nullable=False, default=False)
Expand Down Expand Up @@ -219,6 +219,7 @@ class Assignment(db.Model):
accept_late: bool = Column(Boolean, default=True)
hide_due_date: bool = Column(Boolean, default=False)
questions_assigned: bool = Column(Boolean, default=False)
email_notifications_enabled: bool = Column(Boolean, default=True, nullable=False)

# Autograde
pipeline_image = Column(Text(length=2 ** 14), nullable=True, index=True)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
"""ADD assignment email enable
Revision ID: d5de41411043
Revises: 4f7efe8d8177
Create Date: 2022-08-31 17:56:55.711499
"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import mysql

# revision identifiers, used by Alembic.
revision = "d5de41411043"
down_revision = "4f7efe8d8177"
branch_labels = None
depends_on = None


def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column(
"assignment",
sa.Column(
"email_notifications_enabled", sa.Boolean(),
),
)
conn = op.get_bind()
conn.execute('UPDATE `assignment` SET `email_notifications_enabled` = 1;')
op.alter_column('assignment', 'email_notifications_enabled', type_=sa.Boolean(), nullable=False)
# ### end Alembic commands ###


def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_column("assignment", "email_notifications_enabled")
# ### end Alembic commands ###

0 comments on commit 01f5038

Please sign in to comment.