def _show_service(self): from view.recruitment_req import RecruitmentReq from view.task_req import TaskReq from view.mediator import get_mediator from view.financial_req import FinancialReq m = get_mediator() r = RecruitmentReq(self.employee_type) sub_teams = ['Photography', 'Decoration', 'Audio', 'Graphic designer', 'Network Engineer', 'Technician'] event_ids = [c['id'] for c in m.get_event()] f = FinancialReq(self.employee_type, event_ids) staff_data = m.get_employee('position', '0', all_data=False) team_members = [{'id': s['id'], 'name': s['name']} for s in staff_data] t = TaskReq(event_ids, team_members, sub_teams) self.tabs.addTab(self.event_tab, self.events) self.tabs.addTab(self.task_tab, self.tasks) self.tabs.addTab(t, self.new_task) self.tabs.addTab(r, self.hire_req) self.tabs.addTab(f, self.financial_req) self.show()
def onSubmit(self): from view.mediator import get_mediator m = get_mediator() if self.isInputValid(): if not self.data: m.create_client_req(self.client_rec_no_edit.currentText(), self.event_type_edit.text(), self.description_edit.toPlainText(), self.from_date.text(), self.to_date.text(), self.exp_no_edit.text(), self.planned_budget_edit.text(), self.decorations_edit.toPlainText(), self.filming_edit.toPlainText(), self.poster_edit.toPlainText(), self.food_edit.toPlainText(), self.music_edit.toPlainText(), self.computer_edit.toPlainText(), self.other_edit.toPlainText(), self.approved_check_box.isChecked()) self.clear_form() self.blink_label.start(2000) else: m.update_event(self.data['id'], self.client_rec_no_edit.currentText(), self.event_type_edit.text(), self.description_edit.toPlainText(), self.from_date.text(), self.to_date.text(), self.exp_no_edit.text(), self.planned_budget_edit.text(), self.decorations_edit.toPlainText(), self.filming_edit.toPlainText(), self.poster_edit.toPlainText(), self.food_edit.toPlainText(), self.music_edit.toPlainText(), self.computer_edit.toPlainText(), self.other_edit.toPlainText(), self.approved_check_box.isChecked()) self.hide() else: self.blink_label.setText('Empty fields') self.blink_label.start(2000)
def _create_recruitment_req_tab(self): from view.mediator import get_mediator m = get_mediator() data = m.get_recruitment_req() recruitment_req_table = self._create_table(self._rearrange(data, ['id', 'req_dpt', 'type', 'years_exp', 'title', 'description'])) recruitment_req_table.cellDoubleClicked.connect(self.onRecReqDoubleClick) return recruitment_req_table
def onLogin(self): from view.mediator import get_mediator m = get_mediator() if not m.check_credentials(self.userEdit.text(), self.passwordEdit.text()): self.wrong_login.setVisible(True) else: m.login(self.userEdit.text()) self.hide()
def _create_financial_req_tab(self): from view.mediator import get_mediator m = get_mediator() data = m.get_financial_req() financial_req_table = self._create_table(self._rearrange(data, ['id','event_id', 'req_dpt', 'req_amount', 'reason'])) financial_req_table.cellDoubleClicked.connect(self.onFinReqDoubleClick) return financial_req_table
def _create_client_tab(self): from view.mediator import get_mediator m = get_mediator() data = m.get_client() client_table = self._create_table(self._rearrange(data, ['id', 'name', 'events', 'mail', 'address', 'phone', 'age'])) return client_table
def _show_customer_service(self): from view.mediator import get_mediator m = get_mediator() ids = {c['id']: c['name'] for c in m.get_client()} from view.event_req import ClientReq cr = ClientReq(ids) self.tabs.addTab(cr, self.new_event) self.show()
def _create_employee_tab(self): from view.mediator import get_mediator m = get_mediator() data = m.get_employee() for e in data: e.update({'position':self.roles[e['position']]}) empl_table = self._create_table(self._rearrange(data, ['id', 'name', 'position', 'mail', 'address', 'age'])) return empl_table
def onRecReqDoubleClick(self, row, col): if not self.recruitment_req_popup or not self.recruitment_req_popup.isVisible(): from view.recruitment_req import RecruitmentReq from view.mediator import get_mediator m = get_mediator() # the event id rec_req = self.recruitment_req_tab.item(row, 0).text() fin_req_data = m.get_recruitment_req('id', rec_req, all_data=False)[0] fin_req_data.update({'id': rec_req}) self.recruitment_req_popup = RecruitmentReq(self.employee_type, fin_req_data) else: self.recruitment_req_popup.setFocus()
def _show_senior_customer_service_officer(self): # Retrieve the client IDs from view.mediator import get_mediator m = get_mediator() from view.new_client import NewClient nc = NewClient() self.tabs.addTab(self.event_tab, self.events) self.tabs.addTab(self.client_tab, self.clients) self.tabs.addTab(nc, self.new_client) self.show()
def onFinReqDoubleClick(self, row, col): if not self.financial_req_popup or not self.financial_req_popup.isVisible(): from view.financial_req import FinancialReq from view.mediator import get_mediator m = get_mediator() # the event id event_ids = [c['id'] for c in m.get_event()] fin_req = self.financial_req_tab.item(row, 0).text() fin_req_data = m.get_financial_req('id', fin_req, all_data=False)[0] fin_req_data.update({'id': fin_req}) self.event_popup = FinancialReq(self.employee_type, event_ids, fin_req_data) else: self.financial_req_popup.setFocus()
def _create_task_tab(self): from view.mediator import get_mediator m = get_mediator() if self.employee_type == 'team_member': data = m.get_task('staff_id', '{}-{}'.format(self.user_id, self.name), all_data=False) else: data = m.get_task() task_table = self._create_table(self._rearrange(data, ['id', 'priority'])) task_table.cellDoubleClicked.connect(self.onTaskDoubleClick) return task_table
def _show_administration(self): from view.recruitment_req import RecruitmentReq from view.mediator import get_mediator m = get_mediator() from view.financial_req import FinancialReq event_ids = [c['id'] for c in m.get_event()] f = FinancialReq(self.employee_type, event_ids) r = RecruitmentReq(self.employee_type) self.tabs.addTab(self.employee_tab, self.employees) self.tabs.addTab(self.client_tab, self.clients) self.tabs.addTab(f, self.fin_req) self.tabs.addTab(self.event_tab, self.events) self.tabs.addTab(r, self.hire_req) self.show()
def onSubmit(self): from view.mediator import get_mediator m = get_mediator() if self.isInputValid(): try: m.create_client(self.name_edit.text(), self.age_edit.text(), self.address_edit.toPlainText(), self.mail_edit.text(), self.phone_edit.text()) self.blink_label.setText('Request submitted') except KeyError: self.blink_label.setText('Client already exists') self.clear_form() else: self.blink_label.setText('Empty field(s)') self.blink_label.start(2000)
def _create_event_tab(self): from view.mediator import get_mediator m = get_mediator() data = m.get_event() event_table = self._create_table( self._rearrange(data, ['id', 'client_id', 'event_type', 'description', 'approved', 'from_date', 'to_date', 'exp_no', 'planned_budget', 'decorations', 'filming', 'poster', 'food', 'music', 'computer', 'other'])) event_table.cellDoubleClicked.connect(self.onEventDoubleClick) # Event contains a lot of information, hide some... for i in range(8, event_table.columnCount()): event_table.setColumnHidden(i, True) return event_table
def onEventDoubleClick(self, row, col): if not self.event_popup or not self.event_popup.isVisible(): from view.event_req import ClientReq from view.mediator import get_mediator m = get_mediator() # get the client id from the table cl_id = self.event_tab.item(row, 1).text() # the event id ev_id = self.event_tab.item(row, 0).text() event_data = m.get_event('id', ev_id, all_data=False)[0] event_data.update({'id': ev_id}) # and his/her name name = m.get_client('id', cl_id, all_data=False)[0]['name'] self.event_popup = ClientReq({cl_id: name}, event_data, self.employee_type == 'senior_customer_service_officer') else: self.event_popup.setFocus()
def onTaskDoubleClick(self, row, col): if not self.event_popup or not self.event_popup.isVisible(): from view.task_req import TaskReq from view.mediator import get_mediator m = get_mediator() task_id = self.task_tab.item(row, 0).text() task_data = m.get_task('id', task_id, all_data=False)[0] task_data.update({'id': task_id}) event_ids = [c['id'] for c in m.get_event()] # ---- staff_data = m.get_employee('position', '0', all_data=False) team_members = [{'id': s['id'], 'name': s['name']} for s in staff_data] # ---- sub_teams = ['Photography', 'Decoration', 'Audio', 'Graphic designer', 'Network Engineer', 'Technician'] if self.employee_type == 'team_member': self.task_popup = TaskReq(event_ids, team_members, sub_teams, task_data, True) else: self.task_popup = TaskReq(event_ids, team_members, sub_teams, task_data, False) else: self.task_popup.setFocus()
def onLogout(self): from view.mediator import get_mediator m = get_mediator() m.logout() self.destroy()
def onRefresh(self): from view.mediator import get_mediator m = get_mediator() m.login(self.username) self.destroy()