Ejemplo n.º 1
0
 def execute(self):        
     rtn = self._new_rtn()
     notebooks = NoteService.get_instance().fetch_notebooks(self._get_user_id())
     std = stdModel()
     defaultnotebook = Notebook()
     defaultnotebook.uid = model.EMPTY_UID
     defaultnotebook.nb_name = i18n.get_i18n_message(conf.get_preferred_language(), "note_label_defaultnotebook")
     defaultnotebook.notecount = NoteService.get_instance().get_notecount(False, self._get_user_id(), notebook_id=model.EMPTY_UID)
     defaultnotebook.creator_id = self._get_user_id()
     notebooks.insert(0, defaultnotebook);
     
     trash = Notebook()
     trash.uid = -100
     trash.nb_name = i18n.get_i18n_message(conf.get_preferred_language(), "note_label_recyclebin")
     trash.notecount = NoteService.get_instance().get_notecount(True, self._get_user_id())
     trash.creator_id = self._get_user_id()
     notebooks.append(trash)
     
     std.notebooks = notebooks
     std.notecount = NoteService.get_instance().get_notecount(False, self._get_user_id())
     std.contactGroups = ContactService.get_instance().fetch_my_groups(self._get_user_id())
     
     stmnotebooks = NoteService.get_instance().fetch_notebooks(self._get_user_id(), sharetome=True)
     notebooks.extend(stmnotebooks)
     
     rtn.set_data(std)
     return rtn.to_json()
Ejemplo n.º 2
0
 def execute(self):        
     rtn = self._new_rtn()
     
     std = stdModel()
     select = self._get_bool_parameter("select", False)
     if not select:
         groups = ContactService.get_instance().fetch_groups(self._get_user_id())
         std.groups = groups;
         defaultgroup = Group()
         defaultgroup.uid = model.EMPTY_UID
         defaultgroup.group_name = i18n.get_i18n_message(conf.get_preferred_language(), "cont_label_defaultgroup")
         defaultgroup.contactcount = ContactService.get_instance().get_contactcount(False, self._get_user_id(), group_id=model.EMPTY_UID)
         defaultgroup.creator_id = self._get_user_id()
         groups.insert(0, defaultgroup);
         
         trash = Group()
         trash.uid = -100
         trash.group_name = i18n.get_i18n_message(conf.get_preferred_language(), "cont_label_recyclebin")
         trash.contactcount = ContactService.get_instance().get_contactcount(True, self._get_user_id())
         trash.creator_id = self._get_user_id()
         groups.append(trash)
         
         stmgroups = ContactService.get_instance().fetch_groups(self._get_user_id(), sharetome=True)
         std.groups.extend(stmgroups)
     else:
         groups = ContactService.get_instance().fetch_groups(self._get_user_id(), withcontactcount=False)
         std.groups = groups;
     rtn.set_data(std)
     return rtn.to_json()
Ejemplo n.º 3
0
 def get_worksheet_name(self, worksheet_id):
     if worksheet_id == None or int(worksheet_id) == model.EMPTY_UID:
         return i18n.get_i18n_message(conf.get_preferred_language(), "task_label_workbasket")
     name = cache.get(CACHESPACE_WORKSPACENAME, worksheet_id)
     if name != None:
         return name
     else:
         worksheet = self.get_worksheet(worksheet_id)
         name = worksheet.ws_name if worksheet is not None else ''
         cache.put(CACHESPACE_WORKSPACENAME, worksheet_id, name)
         return name
Ejemplo n.º 4
0
 def execute(self):        
     rtn = self._new_rtn()
     worksheets = TaskService.get_instance().fetch_worksheets(self._get_user_id())
     std = stdModel()
     workbasket = Worksheet()
     workbasket.uid = model.EMPTY_UID
     workbasket.ws_name = i18n.get_i18n_message(conf.get_preferred_language(), "task_label_workbasket")
     workbasket.taskcount = TaskService.get_instance().get_taskcount(False, self._get_user_id(), worksheet_id=model.EMPTY_UID)
     workbasket.creator_id = self._get_user_id()
     worksheets.insert(0, workbasket)
     
     trash = Worksheet()
     trash.uid = -100
     trash.ws_name = i18n.get_i18n_message(conf.get_preferred_language(), "task_label_recyclebin")
     trash.taskcount = TaskService.get_instance().get_taskcount(True, self._get_user_id())
     trash.creator_id = self._get_user_id()
     worksheets.append(trash)
     
     std.worksheets = worksheets
     
     std.contactGroups = ContactService.get_instance().fetch_my_groups(self._get_user_id())
     
     stmworksheets = TaskService.get_instance().fetch_worksheets(self._get_user_id(), sharetome=True)
     std.worksheets.extend(stmworksheets)
     
     std.worksheetComponents = {}
     std.worksheetVersions = {}
     std.worksheetContacts = {}
     
     for worksheet in std.worksheets:
         if worksheet.group_id != None and worksheet.group_id != model.EMPTY_UID:
             std.worksheetComponents[worksheet.key()] = ContactService.get_instance().fetch_groupcomponents(worksheet.group_id)
             std.worksheetVersions[worksheet.key()] = ContactService.get_instance().fetch_groupversions(worksheet.group_id)
             std.worksheetContacts[worksheet.key()] = ContactService.get_instance().fetch_contacts_by_group(worksheet.group_id)
         else:
             myself = ContactService.get_instance().get_myself(self._get_user_id())
             if myself is not None:
                 std.worksheetContacts[worksheet.key()] = [myself]
     rtn.set_data(std)
     return rtn.to_json()
Ejemplo n.º 5
0
 def get_plan_progress(self):
     planprogress = 'NA'
     if self.due_finishdate is not None and self.due_startdate is not None:
         starttime = self.due_startdate
         finishtime = self.due_finishdate
         plantd = finishtime - starttime + timedelta(days=1)
         now = dtutil.localtoday(conf.get_preferred_timezone())
         nowtd = now - starttime
         if starttime < now :
             if plantd.total_seconds() != 0:
                 planprogress = round(nowtd.total_seconds() / plantd.total_seconds(), 3) * 100
                 if planprogress > 100:
                     ps = round(plantd.total_seconds() * (planprogress - 100) / (100 * 60 * 60 * 24), 1)
                     planprogress = "100%%+%0.0f%s" % (ps, i18n.get_i18n_message(conf.get_preferred_language(), "core_label_day"))
                 else:
                     planprogress = "%0.0f%%" % planprogress            
             else:
                 planprogress = "100%"
         else:
             planprogress = "0%"
     self.planProgress = planprogress
     return planprogress