| @@ -25,14 +25,13 @@ def fromisoformat(datestr): | |||
| else: | |||
| return None | |||
| ##@class TodoProject | |||
| ## | |||
| # @class TodoProject | |||
| # @brief functions to load a single or all projects and has methods to check the state of the project | |||
| class TodoProject: | |||
| ''' Common class for api calls''' | |||
| ##@brief constructor of class | |||
| # tries to load api-token from apikey-file. | |||
| # @param project String with project name or integer with project_id | |||
| ##@brief constructor of class | |||
| # tries to load api-token from apikey-file. | |||
| # @param project String with project name or integer with project_id | |||
| def __init__(self,project=None): | |||
| fh_api = open("apikey","r") | |||
| self.apikey = fh_api.read() | |||
| @@ -49,20 +48,26 @@ class TodoProject: | |||
| self.project == None | |||
| self.items = TodoItemList(None,self.api) | |||
| ##@brief synchronize data from Todoist with the api object. | |||
| # @return response of server | |||
| ##@brief synchronize data from Todoist with the api object. | |||
| # @return response of server | |||
| def sync(self): | |||
| return self.api.sync() | |||
| ##@brief verify if there are atleast three tasks scheduled for today. | |||
| # @param tasklimit Number of tasks required. if not met notification will be given. | |||
| def checktaskstoday(self,tasklimit): | |||
| numOfItems = len(self.items.itemsForDay()) | |||
| if numOfItems < tasklimit: | |||
| self.sendnotification("TASKS","Not enough Tasks Scheduled for today!\n" + "Only " + str(numOfItems) + " of " + str(tasklimit) + " tasks set!" ) | |||
| def checkTasksWithoutNotes(self,date=date.today()): | |||
| ##@brief verify if all tasks that are closed also have notes attached. | |||
| # A notification is send by this function if there are tasks that do not meet this condition. | |||
| # @sa TodoProject::openTasksWithoutNotes | |||
| def checkTasksWithoutNotes(self): | |||
| if len(self.items.itemsClosedWithoutNotes())>0: | |||
| self.sendnotification("TASKS","There are tasks without a log.") | |||
| ##@brief verify if all tasks that are closed also have notes attached. | |||
| def checkTasksOverDue(self): | |||
| _overdueItems = len(self.items.itemsOverDue()) | |||
| if _overdueItems==1: | |||
| @@ -70,6 +75,8 @@ class TodoProject: | |||
| elif _overdueItems>1: | |||
| self.sendnotification("TASKS","There are " + str(_overdueItems) + " tasks over due!") | |||
| ##@brief reopen all tasks that are closed but do not have notes attached. | |||
| # @sa TodoProject::checkTasksWithoutNotes | |||
| def openTasksWithoutNotes(self): | |||
| for item in self.items.itemsClosedWithoutNotes(): | |||
| item_handle = item.api.items.get_by_id(item.id) | |||
| @@ -77,6 +84,10 @@ class TodoProject: | |||
| self.api.commit() | |||
| ##@brief Show a notification on Linux desktop | |||
| # Uses Gio-2.0 package to make a notification | |||
| # @param title string with title of the notification | |||
| # @param body string with the body text of the notification | |||
| def sendnotification(self,title,body): | |||
| Application = Gio.Application.new("todoist.tasks", Gio.ApplicationFlags.FLAGS_NONE) | |||
| Application.register() | |||