-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add API endpoint to GET user templates
- Add service to fetch all user templates plus global templates - Add schema
- Loading branch information
Showing
3 changed files
with
36 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,19 @@ | ||
from typing import List | ||
from sqlalchemy import or_ | ||
|
||
from services.main import AppService | ||
from models.timelog import TaskType | ||
from models.timelog import TaskType, Template | ||
|
||
|
||
class TaskTypeService(AppService): | ||
def get_items(self) -> List[TaskType]: | ||
task_types = self.db.query(TaskType).all() or [] | ||
return task_types | ||
|
||
|
||
class TemplateService(AppService): | ||
def get_user_templates(self, user_id: int) -> List[Template]: | ||
templates = ( | ||
self.db.query(Template).filter(or_(Template.user_id == user_id, Template.is_global is True)).all() or [] | ||
) | ||
return templates |