1 from log.logging import logger
2 from model.action import *
5 def edit_action(action):
8 return f.isSaved() == 1
10 class ActionView( object ):
12 def __init__( self, action):
22 fields = [(u'Context','text',self.action.context),
23 (u'Description','text',self.action.description),
24 (u'Info','text',self.action.info)]
25 logger.log(repr(fields))
26 self.form = appuifw.Form(fields, appuifw.FFormEditModeOnly)
28 self.form.save_hook = self.markSaved
29 self.form.flags = appuifw.FFormEditModeOnly
34 def save_fields(self):
35 context = self.get_context()
36 if len(context.strip()) == 0:
37 context,description,info,status = parse_action_line(self.get_description())
39 description = self.get_description()
40 context = parse_context(context)
42 if len(self.get_info().strip()) > 0:
43 info = self.get_info()
46 self.action.context = context
47 self.action.description = description
48 self.action.info = info
50 ## save_hook send True if the form has been saved.
51 def markSaved( self, saved ):
52 #appuifw.note(u'save_hook called with %s'%saved)
54 if saved and self.is_valid():
60 def get_description( self ):
61 return unicode(self.form[1][2])
65 def get_context( self ):
66 return unicode(self.form[0][2])
68 return len(self.form[0]) > 2 and len(self.form[1]) > 2
72 return unicode(self.form[2][2])