2 from model.action import *
3 from model.model import WriteableItem
4 from model import action
6 class ActiveActionStatus(ActionStatus):
8 super(ActiveActionStatus,self).__init__('active',1,u'-')
11 if type(o) == ActionFile:
16 active_status = ActiveActionStatus()
17 action.active = active_status
21 class ActionFile(WriteableItem):
22 def __init__(self,action):
24 self.update_methods = {'status':self.update_status,'description':self.update_description,'context':self.set_context}
25 self.action.observers.append(self)
27 def notify(self,action,attribute,new=None,old=None):
28 super(ActionFile,self).notify(action,attribute,new=new,old=old)
29 if attribute in self.update_methods:
30 self.update_methods[attribute](new=new,old=old)
33 if self.action.status == active:
34 super(ActionFile,self).write()
36 def update_description(self,new,old=None):
37 if self.action.status == active and old:
38 self.remove(self.path(description=old))
40 def update_status(self,new,old=None):
41 if new == inactive or new == done:
44 def set_context(self,new,old=None):
45 if self.action.status == active and old:
46 self.remove(self.path(context=old))
48 def update_done_status(self):
49 if self.action.status == active and not self.exists():
50 self.action.status = done
52 def path(self,context=None,description=None):
54 context = self.action.context
56 description = self.action.description
57 return os.path.join(context,description+'.act')
60 def file_string(self):
61 string = self.action.project_file_string()
62 if self.action.project:
63 string = string+u'\nProject: %s'%self.action.project