Skip to content

Commit

Permalink
Support creating notes from CLI
Browse files Browse the repository at this point in the history
* `terka note sprint` will create a note for a given sprint_id
  • Loading branch information
AndreyMarkinPPC committed Jan 31, 2024
1 parent c5e7b67 commit a28c9ca
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 12 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Key features:

To install `terka` run the following command:

`pip install terka`
`pip install terka[all]`
> install the latest development version with `pip install -e git+https://github.com/AndreyMarkinPPC/terka.git#egg=terka[all]`
It will make `terka` command available in your shell.
Expand Down
18 changes: 13 additions & 5 deletions terka/domain/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ def format_date(attributes: dict, date_attribute: str):
@dataclass
class Note(Command):
id: int
name: str
text: str
created_by: int | None = None


@dataclass
Expand Down Expand Up @@ -104,11 +106,6 @@ class Start(Command):
...


@dataclass
class Create(Command):
...


@dataclass
class List(Command):
...
Expand Down Expand Up @@ -322,6 +319,11 @@ class ListProject(List):
...


@dataclass
class NoteProject(Note):
...


@dataclass
class GetTask(Get):
...
Expand Down Expand Up @@ -396,6 +398,11 @@ class ListSprint(List):
...


@dataclass
class NoteSprint(Note):
...


# EPIC
@dataclass
class CreateEpic(Command):
Expand Down Expand Up @@ -503,6 +510,7 @@ class CreateWorkspace(Command):
class DeleteWorkspace(Delete):
...


@dataclass
class ListWorkspace(List):
...
Expand Down
23 changes: 17 additions & 6 deletions terka/presentations/text_ui/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -607,10 +607,15 @@ def compose(self) -> ComposeResult:
variant="success",
classes="new_entity")
table = DataTable(id="project_notes_table")
for column in ("id", "text"):
for column in ("id", "date", "name"):
table.add_column(column, key=f"note_{column}")
for note in self.entity.notes:
table.add_row(str(note.id), note.name, key=note.id)
for note in sorted(self.entity.notes,
key=lambda x: x.date,
reverse=True):
table.add_row(str(note.id),
note.date.strftime("%Y-%m-%d"),
note.name,
key=note.id)
yield table
with TabPane("Time", id="time"):
plotext = PlotextPlot(classes="plotext")
Expand Down Expand Up @@ -795,9 +800,15 @@ def compose(self) -> ComposeResult:
yield table
with TabPane("Notes", id="notes"):
table = DataTable(id="sprint_notes_table")
table.add_columns("id", "text")
for task in self.entity.notes:
table.add_row(str(task.id), task.name)
for column in ("id", "date", "name"):
table.add_column(column, key=f"note_{column}")
for note in sorted(self.entity.notes,
key=lambda x: x.date,
reverse=True):
table.add_row(str(note.id),
note.date.strftime("%Y-%m-%d"),
note.name,
key=note.id)
yield table
with TabPane("Time", id="time"):
plotext = PlotextPlot(classes="plotext")
Expand Down
16 changes: 16 additions & 0 deletions terka/service_layer/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,22 @@ def list(cmd: commands.ListSprint,
bus.printer.console.print_sprint(
sprints, printer.PrintOptions.from_kwargs(**context))

@register(cmd=commands.NoteSprint)
def note(cmd: commands.NoteSprint,
bus: "messagebus.MessageBus",
context: dict = {}) -> int:
if not cmd:
cmd, context = templates.create_command_from_editor(
entities.notes.SprintNote, type(cmd))
with bus.uow as uow:
cmd = convert_user(cmd, bus, "created_by")
note = entities.note.SprintNote(**asdict(cmd))
uow.tasks.add(note)
uow.commit()
note_id = note.id
bus.printer.console.print_new_object(note)
return note_id


class SprintEventHandlers:

Expand Down

0 comments on commit a28c9ca

Please sign in to comment.