Restructure citizen vote page + add vote deadline

Reorganize the citizen page (/commune/[slug]) for voters: full-width
interactive chart with "Population" zoom by default, separate auth and
vote sections, countdown timer for vote deadline.

Backend: add vote_deadline column to communes with Alembic migration.
Admin: add deadline configuration card with datetime-local input.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Yvv
2026-02-23 00:46:48 +01:00
parent 2af95ebcf1
commit 6caea1b809
7 changed files with 434 additions and 206 deletions

View File

@@ -0,0 +1,30 @@
"""add vote_deadline to communes
Revision ID: 0d7cc7e3efb9
Revises: 25f534648ea7
Create Date: 2026-02-23 00:37:23.451137
"""
from typing import Sequence, Union
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision: str = '0d7cc7e3efb9'
down_revision: Union[str, None] = '25f534648ea7'
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None
def upgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('communes', sa.Column('vote_deadline', sa.DateTime(), nullable=True))
# ### end Alembic commands ###
def downgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.drop_column('communes', 'vote_deadline')
# ### end Alembic commands ###

View File

@@ -29,6 +29,7 @@ class Commune(Base):
description = Column(Text, default="")
is_active = Column(Boolean, default=True)
created_at = Column(DateTime, default=datetime.utcnow)
vote_deadline = Column(DateTime, nullable=True)
tariff_params = relationship("TariffParams", back_populates="commune", uselist=False)
households = relationship("Household", back_populates="commune")

View File

@@ -67,6 +67,8 @@ async def update_commune(
commune.description = data.description
if data.is_active is not None:
commune.is_active = data.is_active
if data.vote_deadline is not None:
commune.vote_deadline = data.vote_deadline
await db.commit()
await db.refresh(commune)

View File

@@ -35,6 +35,7 @@ class CommuneUpdate(BaseModel):
name: str | None = None
description: str | None = None
is_active: bool | None = None
vote_deadline: datetime | None = None
class CommuneOut(BaseModel):
@@ -44,6 +45,7 @@ class CommuneOut(BaseModel):
description: str
is_active: bool
created_at: datetime
vote_deadline: datetime | None = None
model_config = {"from_attributes": True}