Loading alembic/versions/6c174457829c_add_taigauserstoryprovider.py 0 → 100644 +35 −0 Changes for alembic/versions/6c174457829c_add_taigauserstoryprovider.py: 35 added lines, 0 removed lines. Original line number Diff line number Diff line """Add TaigaUserStoryProvider Revision ID: 6c174457829c Revises: 2a60cb3fb390 Create Date: 2024-06-03 18:50:22.330381 """ from typing import Sequence, Union from alembic import op import sqlalchemy as sa from portal.model import Uuid # revision identifiers, used by Alembic. revision: str = "6c174457829c" down_revision: Union[str, None] = "d3889051d9e7" branch_labels: Union[str, Sequence[str], None] = None depends_on: Union[str, Sequence[str], None] = None def upgrade() -> None: op.create_table( "taiga_user_story_provider", sa.Column("url", sa.String(), nullable=False), sa.Column("authorization", sa.String(), nullable=False), sa.Column("uuid", Uuid(), nullable=False), sa.PrimaryKeyConstraint("uuid"), ) def downgrade() -> None: op.drop_table("taiga_user_story_provider") portal/api/__init__.py +1 −0 Changes for portal/api/__init__.py: 1 added line, 0 removed lines. Original line number Diff line number Diff line Loading @@ -2,3 +2,4 @@ from .blueprint import bp from .auth import * from .rest import * from .version import * from .agenda import * portal/api/agenda.py 0 → 100644 +17 −0 Changes for portal/api/agenda.py: 17 added lines, 0 removed lines. Original line number Diff line number Diff line from portal.model import TaigaUserStoryProvider from .blueprint import bp @bp.get("/agendas/-/items") def the_agenda_items(): tasks = TaigaUserStoryProvider.get_the_one().fetch_user_stories() item_names = [ "Tagesordnung", "Gremienberichte", *(task["subject"] for task in tasks), "Sonstiges", ] return [{"name": name} for name in item_names] portal/model/TaigaUserStoryProvider.py 0 → 100644 +29 −0 Changes for portal/model/TaigaUserStoryProvider.py: 29 added lines, 0 removed lines. Original line number Diff line number Diff line from sqlalchemy.orm import Mapped from typing import Any, Self import requests from portal.model.Base import Base class TaigaUserStoryProvider(Base): """ Fetches a list of "user stories" (i.e., tasks) from the project management tool Taiga. """ url: Mapped[str] authorization: Mapped[str] def fetch_user_stories(self) -> list[dict[str, Any]]: return requests.get(self.url, headers={"Authorization": self.authorization}).json() @classmethod def get_the_one(cls) -> Self: instances = cls.get_all() if len(instances) != 1: raise ValueError( f"Expected there to be exactly 1 instance of {cls.__name__}, but there were {len(instances)}" ) return instances[0] portal/model/__init__.py +1 −0 Changes for portal/model/__init__.py: 1 added line, 0 removed lines. Original line number Diff line number Diff line Loading @@ -6,3 +6,4 @@ from .User import User from .Uuid import Uuid from .Key import Key from .UtcDateTime import UtcDateTime from .TaigaUserStoryProvider import TaigaUserStoryProvider Loading
alembic/versions/6c174457829c_add_taigauserstoryprovider.py 0 → 100644 +35 −0 Changes for alembic/versions/6c174457829c_add_taigauserstoryprovider.py: 35 added lines, 0 removed lines. Original line number Diff line number Diff line """Add TaigaUserStoryProvider Revision ID: 6c174457829c Revises: 2a60cb3fb390 Create Date: 2024-06-03 18:50:22.330381 """ from typing import Sequence, Union from alembic import op import sqlalchemy as sa from portal.model import Uuid # revision identifiers, used by Alembic. revision: str = "6c174457829c" down_revision: Union[str, None] = "d3889051d9e7" branch_labels: Union[str, Sequence[str], None] = None depends_on: Union[str, Sequence[str], None] = None def upgrade() -> None: op.create_table( "taiga_user_story_provider", sa.Column("url", sa.String(), nullable=False), sa.Column("authorization", sa.String(), nullable=False), sa.Column("uuid", Uuid(), nullable=False), sa.PrimaryKeyConstraint("uuid"), ) def downgrade() -> None: op.drop_table("taiga_user_story_provider")
portal/api/__init__.py +1 −0 Changes for portal/api/__init__.py: 1 added line, 0 removed lines. Original line number Diff line number Diff line Loading @@ -2,3 +2,4 @@ from .blueprint import bp from .auth import * from .rest import * from .version import * from .agenda import *
portal/api/agenda.py 0 → 100644 +17 −0 Changes for portal/api/agenda.py: 17 added lines, 0 removed lines. Original line number Diff line number Diff line from portal.model import TaigaUserStoryProvider from .blueprint import bp @bp.get("/agendas/-/items") def the_agenda_items(): tasks = TaigaUserStoryProvider.get_the_one().fetch_user_stories() item_names = [ "Tagesordnung", "Gremienberichte", *(task["subject"] for task in tasks), "Sonstiges", ] return [{"name": name} for name in item_names]
portal/model/TaigaUserStoryProvider.py 0 → 100644 +29 −0 Changes for portal/model/TaigaUserStoryProvider.py: 29 added lines, 0 removed lines. Original line number Diff line number Diff line from sqlalchemy.orm import Mapped from typing import Any, Self import requests from portal.model.Base import Base class TaigaUserStoryProvider(Base): """ Fetches a list of "user stories" (i.e., tasks) from the project management tool Taiga. """ url: Mapped[str] authorization: Mapped[str] def fetch_user_stories(self) -> list[dict[str, Any]]: return requests.get(self.url, headers={"Authorization": self.authorization}).json() @classmethod def get_the_one(cls) -> Self: instances = cls.get_all() if len(instances) != 1: raise ValueError( f"Expected there to be exactly 1 instance of {cls.__name__}, but there were {len(instances)}" ) return instances[0]
portal/model/__init__.py +1 −0 Changes for portal/model/__init__.py: 1 added line, 0 removed lines. Original line number Diff line number Diff line Loading @@ -6,3 +6,4 @@ from .User import User from .Uuid import Uuid from .Key import Key from .UtcDateTime import UtcDateTime from .TaigaUserStoryProvider import TaigaUserStoryProvider