예제 #1
0
    def update_model(self, form_values):
        model = self.model[self.view.get_selected_idx()]
        try:
            model.update(Dao(), form_values)
        except Exception as ex:
            uil.show_error(str(ex))
            return

        uil.show_msg('Employee updated!', 'Hallelujah!')
예제 #2
0
    def add_model(self, form_values):
        new_model = Employee(self.get_new_model_values(form_values))

        try:
            new_model.id = new_model.add(Dao())
        except Exception as ex:
            uil.show_error(str(ex))
            return

        uil.show_msg('Employee added!', 'Hallelujah!')
예제 #3
0
    def apply_filter(self, attr):
        selection = None
        if attr != 'All':
            selection = self.view.get_done_list_selection()
            if not selection:
                uil.show_error('No invoice selected!')
                return

        self.view.apply_filter(attr, selection)
        self.set_total_due(attr, selection)
예제 #4
0
    def update_dept(self, obj, value):
        obj.name = value.upper()
        if not obj.name:
            uil.show_error('Department name missing!')
            return

        if obj.id:
            obj.update(Dao())
        else:
            obj.id = obj.add(Dao())
예제 #5
0
    def update_admin(self, obj, value):
        err_msg = vl.validate_name(value)
        if err_msg:
            uil.show_error(err_msg)
            return

        obj.name = value.upper()
        if obj.id:
            obj.update(Dao())
        else:
            obj.add(Dao())
예제 #6
0
    def save(self):
        err_msg = self.validate()
        if err_msg:
            uil.show_error(err_msg)
            return

        form_values = self.get_form_values()
        if self.view.get_selected_idx() == -1:
            self.add_model(form_values)
        else:
            self.update_model(form_values)
예제 #7
0
    def update_pm_nonva_email(self, emp, value):
        if not vl.validate_email(value):
            uil.show_error('Invalid non-VA email!')
            return

        if not emp.name:
            uil.show_error('PM name missing!')
            return

        emp.nonva_email = value
        emp.update_pm(Dao())
예제 #8
0
    def drop(self, action):
        idx = self.view.get_selected_idx()

        if action == 'Undrop':
            self.undrop(idx)
            return

        try:
            self.model[idx].drop(Dao())
        except Exception as ex:
            uil.show_error(str(ex))
            return
예제 #9
0
    def add_model(self, form_values):
        from models.project import Project

        new_model = Project(self.get_new_model_values(form_values))

        try:
            new_model.id = new_model.add(Dao())
        except Exception as ex:
            uil.show_error(str(ex))
            return

        uil.show_msg('Project added!', 'Hallelujah!')
예제 #10
0
    def drop_asn(self):
        selections = self.view.get_selected_asns()
        ids = [x.id for x in selections]
        if not ids:
            uil.show_error('No assignments selected!')
            return

        if uil.confirm(self.view, 'Drop selected assignments?'):
            try:
                Assignment.drop_many(Dao(), ids)
            except Exception as ex:
                uil.show_error(str(ex))
                return
예제 #11
0
    def update_pm_va_email(self, emp, value):
        err_msg = vl.validate_va_email(value)
        if err_msg:
            uil.show_error(err_msg)
            self.view.focus_pm_va_email()
            return

        if not emp.name:
            uil.show_error('PM name missing!')
            return

        emp.va_email = value
        emp.update_pm(Dao())
예제 #12
0
 def no_match(self):
     match = self.view.get_match_selection()
     if match:
         uil.show_error("But you've selected a match!")
         self.view.set_match_selection(match)
         return
     selection = self.view.get_list_selection()
     objs = self.view.get_list()
     selection.matched = True
     self.view.display(objs)
     try:
         result = Employee.add_name(Dao(), selection.name)
     except Exception as e:
         uil.show_error(str(e))
예제 #13
0
    def update_admin_email(self, obj, value):
        if not vl.validate_email(value):
            uil.show_error('Invalid email!')
            return

        if not obj.name:
            uil.show_error('Admin name missing!')
            return

        obj.email = value
        if obj.id:
            obj.update(Dao())
        else:
            obj.add(Dao())
예제 #14
0
    def undrop(self, idx):
        try:
            self.model[idx].undrop(Dao())
            self.model[idx].active = 1
            self.model[idx].asns = []
        except Exception as ex:
            uil.show_error(str(ex))
            return

        self.refresh_list()
        if idx >= len(self.model):
            idx = len(self.model) - 1
        self.set_selection(idx)

        self.view.set_details_active(True, self.model_name)
예제 #15
0
 def load_form(self):
     item = self.view.get_work_list_selection()
     if not item:
         return
     if not item.salary or not item.fringe:
         emp_rec = gbl.dataset.get_emp_rec_by_name(item.employee)
         item.salary = emp_rec.salary
         if not item.salary:
             uil.show_error('%s has no salary! Not imported?' %
                            (item.employee, ))
         else:
             item.fringe = emp_rec.fringe
             item.amount, item.total_day = self.calculate_cost(
                 item.salary, item.fringe, item.effort, item.days)
             if not item.balance:
                 item.balance = item.amount
     self.view.load_form(item)
예제 #16
0
    def match(self):
        match, idx = self.view.get_match_selection()
        if not match:
            uil.show_error('No match selected!')
            return

        if idx != 0:
            if not uil.confirm(self.view,
                               'Not the highest score! Are you sure?'):
                return

        objs = self.view.get_list()
        selection = self.view.get_list_selection()
        selection.matched = True
        self.view.display(objs)
        try:
            result = Employee.update_name(Dao(), match['name'], selection.name)
        except Exception as e:
            uil.show_error(str(e))
예제 #17
0
    def on_ok_click(self, evt):
        import lib.validator_lib as vl

        va_email = self.email_ctrl.GetValue()
        err_msg = vl.validate_email(va_email)
        if not err_msg:
            uil.show_error(err_msg)
            return
        self.emp.va_email = va_email

        nonva_email = self.email_ctrl.GetValue()
        err_msg = vl.validate_email(nonva_email)
        if not err_msg:
            uil.show_error(err_msg)
            return
        self.emp.nonva_email = nonva_email

        self.emp.pm = True

        self.Hide()
예제 #18
0
    def update_allocat(self):
        rex = self.view.get_rex()
        new_rex = []
        for rec in rex:
            new_rec = {
                'id': next((x.id for x in self.emps if x.name == rec.name),
                           None),
                'salary': rec.salary,
                'fringe': rec.fringe
            }
            if not new_rec['id']:
                uil.show_error('Uh oh! No employee record for ' + rec.name)
                return
            new_rex.append(new_rec)

        dao = Dao(stateful=True)
        try:
            Employee.update_salaries(dao, new_rex)
            uil.show_msg('Hurray!', 'Done!')
        except Exception as e:
            uil.show_error(str(e))
        finally:
            dao.close()
예제 #19
0
 def run_query(self):
     try:
         frum = self.view.get_frum()
     except ValueError:
         uil.show_error('Invalid From Month!')
         return
     try:
         thru = self.view.get_thru()
     except ValueError:
         uil.show_error('Invalid Thru Month!')
         return
     if not ml.is_valid_span(frum, thru):
         uil.show_error('Invalid time frame!')
         return
     months = ml.get_months(frum, thru)
     rows, self.breakdowns = self.build_dataset(frum, thru, months)
     self.view.load_grid(months, rows)