Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
"""Add assignment due_date and checkpoint_enabled columns.

Revision ID: 2a45f5cb8e25
Revises: b91594c0e379
"""

import sqlalchemy as sa
from alembic import op

revision = "2a45f5cb8e25"
down_revision = "b91594c0e379"


def upgrade() -> None:
op.add_column("assignment", sa.Column("due_date", sa.DateTime(), nullable=True))
op.add_column(
"assignment",
sa.Column(
"checkpoint_enabled",
sa.Boolean(),
server_default=sa.false(),
nullable=False,
),
)


def downgrade() -> None:
op.drop_column("assignment", "checkpoint_enabled")
op.drop_column("assignment", "due_date")
12 changes: 12 additions & 0 deletions lms/models/assignment.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from datetime import datetime
from enum import StrEnum

import sqlalchemy as sa
Expand Down Expand Up @@ -146,6 +147,17 @@ class Assignment(CreatedUpdatedMixin, Base):
)
auto_grading_config = relationship("AutoGradingConfig")

due_date: Mapped[datetime | None] = mapped_column()
"""The due date for this assignment; NULL if not set."""

checkpoint_enabled: Mapped[bool] = mapped_column(
sa.Boolean(),
default=False,
server_default=sa.sql.expression.false(),
nullable=False,
)
"""Whether this assignment has at least one checkpoint enabled."""

__table_args__ = (
sa.UniqueConstraint("resource_link_id", "tool_consumer_instance_guid"),
sa.Index(
Expand Down
1 change: 1 addition & 0 deletions tests/factories/assignment.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
document_url=Faker("uri"),
extra={},
title=Sequence(lambda n: f"Assignment {n}"),
checkpoint_enabled=False,
)


Expand Down