home
·
contact
·
privacy
projects
/
plomtask
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Add Day.comment field.
[plomtask]
/
plomtask
/
days.py
diff --git
a/plomtask/days.py
b/plomtask/days.py
index d64b34b6bc69c01fd6d6a17437bbc90f357d301a..ba466b52c792f81029a94f4bc9fcc21718dd500b 100644
(file)
--- a/
plomtask/days.py
+++ b/
plomtask/days.py
@@
-19,11
+19,12
@@
def date_valid(date: str):
class Day:
"""Individual days defined by their dates."""
class Day:
"""Individual days defined by their dates."""
- def __init__(self, date: str):
+ def __init__(self, date: str
, comment: str = ''
):
self.date = date
self.datetime = date_valid(self.date)
if not self.datetime:
raise HandledException(f'Given date of wrong format: {self.date}')
self.date = date
self.datetime = date_valid(self.date)
if not self.datetime:
raise HandledException(f'Given date of wrong format: {self.date}')
+ self.comment = comment
def __eq__(self, other: object):
return isinstance(other, self.__class__) and self.date == other.date
def __eq__(self, other: object):
return isinstance(other, self.__class__) and self.date == other.date
@@
-34,7
+35,7
@@
class Day:
@classmethod
def from_table_row(cls, row: Row):
"""Make new Day from database row."""
@classmethod
def from_table_row(cls, row: Row):
"""Make new Day from database row."""
- return cls(row[0])
+ return cls(row[0]
, row[1]
)
@classmethod
def all(cls, db_conn: DatabaseConnection,
@classmethod
def all(cls, db_conn: DatabaseConnection,
@@
-63,4
+64,5
@@
class Day:
def save(self, db_conn: DatabaseConnection):
"""Add (or re-write) self to database."""
def save(self, db_conn: DatabaseConnection):
"""Add (or re-write) self to database."""
- db_conn.exec('REPLACE INTO days VALUES (?)', (self.date,))
+ db_conn.exec('REPLACE INTO days VALUES (?, ?)',
+ (self.date, self.comment))