Spaces:
Sleeping
Sleeping
File size: 1,140 Bytes
7952f32 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | """Domain models for the task manager."""
from __future__ import annotations
from datetime import date
from typing import Optional
class Task:
"""A single task in the task manager."""
def __init__(
self,
title: str,
priority: str,
tags: list[str],
due_date: Optional[date] = None,
) -> None:
self.title = title
self.priority = priority # expected: "low" | "medium" | "high"
self.tags = tags
self.due_date = due_date
self.done = False
def complete(self) -> None:
"""Mark this task as done."""
self.done = True
def to_dict(self) -> dict:
return {
"title": self.title,
"priority": self.priority,
"tags": self.tags,
"done": self.done,
"due_date": str(self.due_date) if self.due_date else None,
}
class User:
"""A user who owns tasks."""
def __init__(self, username: str, email: str) -> None:
self.username = username
self.email = email
def display(self) -> str:
return f"{self.username} <{self.email}>"
|