some small fixes
This commit is contained in:
parent
c9e8571a85
commit
5a0c6abad5
@ -1,6 +1,6 @@
|
|||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
from peewee import fn, JOIN
|
from peewee import fn, JOIN
|
||||||
from .db import Task, Category, TaskStatus
|
from ..db import Task, Category, TaskStatus
|
||||||
|
|
||||||
|
|
||||||
def get_category_summary(num: int = 5) -> list[dict]:
|
def get_category_summary(num: int = 5) -> list[dict]:
|
||||||
@ -101,9 +101,7 @@ def get_recently_active(num: int = 5, category: str | None = None) -> list[dict]
|
|||||||
List of tasks ordered by last activity (updated_at)
|
List of tasks ordered by last activity (updated_at)
|
||||||
"""
|
"""
|
||||||
query = (
|
query = (
|
||||||
Task.select(Task, Category.name.alias("category_name"))
|
Task.select(Task, Category).join(Category, JOIN.LEFT_OUTER).where(~Task.deleted)
|
||||||
.join(Category, JOIN.LEFT_OUTER)
|
|
||||||
.where(~Task.deleted)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
if category:
|
if category:
|
||||||
@ -117,7 +115,7 @@ def get_recently_active(num: int = 5, category: str | None = None) -> list[dict]
|
|||||||
"text": task.text,
|
"text": task.text,
|
||||||
"status": task.status,
|
"status": task.status,
|
||||||
"type": task.type,
|
"type": task.type,
|
||||||
"category": task.category_name,
|
"category": task.category.name if task.category else None,
|
||||||
"due": task.due,
|
"due": task.due,
|
||||||
"updated_at": task.updated_at,
|
"updated_at": task.updated_at,
|
||||||
}
|
}
|
||||||
@ -172,7 +170,7 @@ def get_due_soon(
|
|||||||
"text": task.text,
|
"text": task.text,
|
||||||
"status": task.status,
|
"status": task.status,
|
||||||
"type": task.type,
|
"type": task.type,
|
||||||
"category": task.category_name,
|
"category": task.category.name if task.category else None,
|
||||||
"due": task.due,
|
"due": task.due,
|
||||||
"days_until_due": (task.due - now).days if task.due else None,
|
"days_until_due": (task.due - now).days if task.due else None,
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import json
|
import json
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from peewee import fn
|
from peewee import fn
|
||||||
from .db import db, Task, Category, TaskStatus, SavedSearch
|
from ..db import db, Task, Category, TaskStatus, SavedSearch
|
||||||
from peewee import Case, Value
|
from peewee import Case, Value
|
||||||
|
|
||||||
|
|
||||||
|
@ -27,16 +27,18 @@ class TableColumnConfig:
|
|||||||
display_name: str,
|
display_name: str,
|
||||||
*,
|
*,
|
||||||
default=None,
|
default=None,
|
||||||
enum=None,
|
|
||||||
enable_editor=False,
|
enable_editor=False,
|
||||||
|
enum=None,
|
||||||
|
filterable=True,
|
||||||
preprocessor=None,
|
preprocessor=None,
|
||||||
):
|
):
|
||||||
self.field = field
|
self.field = field
|
||||||
self.display_name = display_name
|
self.display_name = display_name
|
||||||
self.default = default
|
self.default = default
|
||||||
self.enum = enum
|
|
||||||
self.preprocessor = preprocessor or (lambda x: x)
|
|
||||||
self.enable_editor = enable_editor
|
self.enable_editor = enable_editor
|
||||||
|
self.enum = enum
|
||||||
|
self.filterable = filterable
|
||||||
|
self.preprocessor = preprocessor or (lambda x: x)
|
||||||
|
|
||||||
|
|
||||||
class TableEditor(App):
|
class TableEditor(App):
|
||||||
@ -285,7 +287,7 @@ class TableEditor(App):
|
|||||||
|
|
||||||
def action_start_filter(self):
|
def action_start_filter(self):
|
||||||
cconf = self._active_column_config()
|
cconf = self._active_column_config()
|
||||||
if cconf.filterable:
|
if not cconf.filterable:
|
||||||
return
|
return
|
||||||
cur_filter_val = self.filters.get(cconf.field) or ""
|
cur_filter_val = self.filters.get(cconf.field) or ""
|
||||||
self._show_input("filter", cur_filter_val)
|
self._show_input("filter", cur_filter_val)
|
||||||
|
Loading…
Reference in New Issue
Block a user