Exemple #1
0
 def push(self):
     parameter = parameter_encode(self.attributes)
     parameter['command'] = "updateMission"
     res = API.post(parameter)
     if res:
         return True
     else:
         return False
Exemple #2
0
 def push(self):
     parameter = parameter_encode(self.attributes)
     parameter["command"] = "updateProject"
     res = API.post(parameter)
     if res:
         print res
         return True
     else:
         return False
Exemple #3
0
 def destroy(self):
     parameter = dict()
     parameter["metadata_code"] = self.metadata_code()
     parameter["command"] = "removeMissionMetadata"
     res = API.post(parameter)
     if res:
         print res
         return True
     else:
         return False
Exemple #4
0
 def destroy(self):
     parameter = dict()
     parameter["note_code"] = self.note_code
     parameter["command"] = "removeMissionNote"
     res = API.post(parameter)
     if res:
         print res
         return True
     else:
         return False
Exemple #5
0
 def add_to_db(self):
     parameter = parameter_encode(self.attributes)
     parameter['command'] = "addMission"
     res = API.post(parameter)
     if res:
         attr = json.loads(res)
         self.attributes = attr
         return True
     else:
         return False
Exemple #6
0
 def add_to_db(self):
     parameter = parameter_encode(self.attributes)
     parameter["command"] = "addProject"
     res = API.post(parameter)
     if res:
         project_data = json.loads(res)
         self.attributes['project_code'] = project_data['project_code']
         return True
     else:
         return False
Exemple #7
0
 def destroy(self):
     parameter = dict()
     parameter["target_code"] = self.target_code()
     parameter["command"] = "removeMissionTarget"
     res = API.post(parameter)
     if res:
         print res
         return True
     else:
         return False
Exemple #8
0
 def destroy(self):
     print "delete %s" % self.name()
     parameter = parameter_encode(self.attributes)
     parameter['command'] = "removeMission"
     res = API.post(parameter)
     if res:
         # attr = json.loads(res)
         print res
         self.parent.remove_child(self.row())
         del self
         return True
     else:
         return False
Exemple #9
0
    def add_to_db(self):
        if not self.task:
            print "The metadata have not mission_code."
            return False

        parameter = parameter_encode(self.attributes)
        parameter["mission_code"] = self.mission_code()
        parameter["command"] = "addMetadata"
        res = API.post(parameter)
        if res:
            attr = json.loads(res)
            self.set_metadata_code(attr.get("metadata_code", ""))
            return True
        else:
            return False
Exemple #10
0
 def add_to_db(self):
     if not self.task:
         print "The require have not mission_code."
         return False
     if not self.task_code():
         self.set_task_code(self.task.task_code())
     parameter = parameter_encode(self.attributes)
     parameter["command"] = "addMissionRequire"
     res = API.post(parameter)
     if res:
         require_data = json.loads(res)
         self.set_require_code(require_data.get('require_code', ""))
         return True
     else:
         return False
Exemple #11
0
 def add_to_db(self):
     if not self.task:
         print "The note have not mission_code."
         return False
     if not self.task_code():
         self.set_task_code(self.task.task_code())
     parameter = parameter_encode(self.attributes)
     parameter["command"] = "addNote"
     res = API.post(parameter)
     if res:
         attr = json.loads(res)
         self.set_note_code(attr.get("note_code", ""))
         self.set_user_code(attr.get("user_code", ""))
         return True
     else:
         return False
Exemple #12
0
    def targets(self):
        parameter = parameter_encode(self.attributes)
        parameter['command'] = "getMissionTargets"
        res = API.post(parameter)
        target_list = []
        if not res:
            return target_list

        result = json.loads(res)
        if not result:
            return target_list
        for item in result:
            target = TaskTarget(item, self)
            target_list.append(target)

        return target_list
Exemple #13
0
    def requires(self):
        parameter = parameter_encode(self.attributes)
        parameter['command'] = "getMissionRequires"
        res = API.post(parameter)
        require_list = []
        if not res:
            return require_list

        result = json.loads(res)
        if not result:
            return require_list
        for item in result:
            require = TaskRequire(item, self)
            require_list.append(require)

        return require_list
Exemple #14
0
    def notes(self):
        parameter = parameter_encode(self.attributes)
        parameter['command'] = "getMissionNote"
        res = API.post(parameter)
        note_list = []
        if not res:
            return note_list

        result = json.loads(res)
        if not result:
            return note_list
        for item in result:
            note = TaskNote(item, self)
            note_list.append(note)

        return note_list
Exemple #15
0
    def all_metadata(self):
        parameter = parameter_encode(self.attributes)
        parameter['command'] = "getMissionMetadata"
        res = API.post(parameter)
        metadata_list = []
        if not res:
            return metadata_list

        result = json.loads(res)
        if not result:
            return metadata_list
        for item in result:
            metadata = Metadata(item)
            metadata.task = self
            metadata_list.append(metadata)

        return metadata_list
Exemple #16
0
    def projects():
        data = dict()
        data["command"] = "getProjects"
        res = API.post(data)

        if not res:
            return []

        project_data = json.loads(res)
        if not project_data:
            return []

        projects = []
        for p in project_data:
            projects.append(Project(p))

        return projects
Exemple #17
0
    def tasks(self):
        """return task list"""
        data = dict()
        data["command"] = "getMissions"
        data["project_code"] = self.project_code()

        task_list = []
        res = API.post(data)
        if not res:
            return task_list
        tasks_data = json.loads(res)
        if not tasks_data:
            return task_list
        for t in tasks_data:
            # t["start_date"] = datetime_to_date(t.get("start_date", ""))
            # t["due_date"] = datetime_to_date(t.get("due_date", ""))
            task_list.append(Task(t))

        return task_list