def getTaskActionReports(self, task_id): mainlog.info("getTaskActionReports {}".format(task_id)) r = self.dao.task_action_report_dao.get_reports_for_task(task_id) try: return rpctools.sqla_to_hash(r) except Exception, e: mainlog.exception(e)
def getMoreTaskInformation(self, task_id): try: mainlog.debug( "getMoreTaskInformation, task id = {}".format(task_id)) t = self.dao.task_dao.find_by_id(task_id) if isinstance(t, TaskOnOperation): operation = t.operation employees_on_task = self.dao.task_dao.employees_on_task(t) h = { 'task_type': 'TaskOnOperation', 'description': operation.description, 'operation_definition': operation.operation_model.description, 'operation_definition_short': operation.operation_model.short_id, 'order_part_description': operation.production_file.order_part.description, 'order_description': operation.production_file.order_part.order.description, 'order_part_id': operation.production_file.order_part.label, 'order_id': operation.production_file.order_part.order.label, 'customer_name': operation.production_file.order_part.order.customer. fullname, 'employees_on_task': map(lambda emp: emp.employee_id, employees_on_task) } mainlog.debug("getMoreTaskInformation, returning {}".format(h)) self.dao.session.commit() return h elif isinstance(t, TaskOnNonBillable): h = { 'task_type': 'TaskOnNonBillable', 'description': t.operation_definition.description } self.dao.session.commit() return h else: raise Exception("Unsupported task type") except Exception, e: mainlog.exception(e) return None
def getLastActionReport(self, task_id, employee_id): mainlog.info("getLastActionReport task:{} employee:{}".format( task_id, employee_id)) try: reports = self.dao.task_action_report_dao.get_reports_for_task_employee( task_id, employee_id) if reports: return rpctools.sqla_to_hash(reports[-1]) else: mainlog.debug("getLastActionReport : return None") return None except Exception, e: mainlog.exception(e) return None
def getOngoingTasksInformation(self, employee_id): try: mainlog.debug( "getOngoingTasksInformation, employee id = {}".format( employee_id)) employee = self.dao.employee_dao.find_by_id(employee_id) task_list = self.dao.task_dao.ongoing_tasks_for_employee(employee) r = rpctools.sqla_to_hash(task_list) mainlog.debug( "getOngoingTasksInformation, about to return with : {}".format( r)) self.dao.session.commit() return r except Exception, e: mainlog.exception(e) return None
def getTaskInformation(self, task_id): try: mainlog.debug("getTaskInformation, task id = {}".format(task_id)) data = BarCodeIdentifier.barcode_to_id(task_id) if data[0] == Operation: operation_id = data[1] t = self.dao.task_dao.task_for_operation(operation_id) else: e = "Can't get that object, I don't recognize it" raise xmlrpclib.Fault(1000, e) return rpctools.sqla_to_hash(t) except Exception, e: mainlog.exception(e) e = "Task {} not found".format(task_id) mainlog.error(e) raise xmlrpclib.Fault(1000, e)
self._recordDayOutAction(employee, action_time, location) else: h['action_kind'] = self._recordActionOnWorkTask( task_id, employee, action_time, location) return h except ServerException, e: self.dao.session.rollback() mainlog.trace() raise xmlrpclib.Fault(e.code, e.msg) except Exception, e: self.dao.session.rollback() mainlog.trace() mainlog.exception(e) # msg = u"Problem while recording pointage : {}".format(e) msg = "" raise xmlrpclib.Fault(1000, msg) def usersInformation(self): users = [] for employee in self.dao.employee_dao.all(): print(employee.employee_id) u = User(employee.employee_id, employee.fullname) u.set_picture_bytes(employee.picture_bytes()) users.append(u) # users = [ User(10,"Theo Champailler"), User(11,"Eva Champailler") ] return users