REPR_OUTPUT_SIZE = 10
PENDING = 'pending'
COMPLETED = 'completed'
+DELETED = 'deleted'
+WAITING = 'waiting'
+RECURRING = 'recurring'
logger = logging.getLogger(__name__)
def pending(self):
return self['status'] == six.text_type('pending')
+ @property
+ def recurring(self):
+ return self['status'] == six.text_type('recurring')
+
@property
def active(self):
return self['start'] is not None
def delete(self):
if not self.saved:
- raise Task.NotSaved("Task needs to be saved before it can be deleted")
+ raise Task.NotSaved(
+ "Task needs to be saved before it can be deleted")
# Refresh the status, and raise exception if the task is deleted
self.refresh(only_fields=['status'])
def start(self):
if not self.saved:
- raise Task.NotSaved("Task needs to be saved before it can be started")
+ raise Task.NotSaved(
+ "Task needs to be saved before it can be started")
# Refresh, and raise exception if task is already completed/deleted
self.refresh(only_fields=['status'])
def stop(self):
if not self.saved:
- raise Task.NotSaved("Task needs to be saved before it can be stopped")
+ raise Task.NotSaved(
+ "Task needs to be saved before it can be stopped")
# Refresh, and raise exception if task is already completed/deleted
self.refresh(only_fields=['status'])
def done(self):
if not self.saved:
- raise Task.NotSaved("Task needs to be saved before it can be completed")
+ raise Task.NotSaved(
+ "Task needs to be saved before it can be completed")
# Refresh, and raise exception if task is already completed/deleted
self.refresh(only_fields=['status'])
def completed(self):
return self.filter(status=COMPLETED)
+ def deleted(self):
+ return self.filter(status=DELETED)
+
+ def waiting(self):
+ return self.filter(status=WAITING)
+
+ def recurring(self):
+ return self.filter(status=RECURRING)
+
def filter(self, *args, **kwargs):
"""
Returns a new TaskQuerySet with the given filters added.