Add hamster tag management, reinstate tags during import, reorganise
code
This commit is contained in:
@ -1,4 +1,5 @@
|
||||
from datetime import datetime
|
||||
import pdb
|
||||
import requests
|
||||
import requests_cache
|
||||
import os
|
||||
@ -25,6 +26,7 @@ class KimaiAPI(object):
|
||||
self.customers_json = self.get("customers", {"visible": 3})
|
||||
self.projects_json = self.get("projects", {"visible": 3, "ignoreDates": 1})
|
||||
self.activities_json = self.get("activities", {"visible": 3})
|
||||
self.tags_json = self.get("tags/find?name=", {"visible": 3})
|
||||
self.user_json = self.get("users/me")
|
||||
|
||||
def get(self, endpoint, params=None):
|
||||
@ -145,6 +147,38 @@ class Activity(BaseAPI):
|
||||
if not none:
|
||||
raise NotFound()
|
||||
|
||||
@dataclass
|
||||
class Tag(BaseAPI):
|
||||
api: KimaiAPI = field(repr=False)
|
||||
id: int
|
||||
name: str
|
||||
visible: bool = field(default=True)
|
||||
|
||||
@staticmethod
|
||||
def list(api):
|
||||
return [
|
||||
Tag(
|
||||
api,
|
||||
t["id"],
|
||||
t["name"],
|
||||
t["visible"],
|
||||
)
|
||||
for t in api.tags_json
|
||||
]
|
||||
|
||||
@staticmethod
|
||||
def get_by_id(api, id, none=False):
|
||||
for t in api.tags_json:
|
||||
if t["id"] == id:
|
||||
return Tag(
|
||||
api,
|
||||
t["id"],
|
||||
t["name"],
|
||||
t["visible"],
|
||||
)
|
||||
if not none:
|
||||
raise NotFound()
|
||||
|
||||
|
||||
@dataclass
|
||||
class Timesheet(BaseAPI):
|
||||
|
Reference in New Issue
Block a user