Exemplo n.º 1
0
def emp_add():
    values = json.loads(request.form['params'])
    try:
        empid = Employee.add(values)
    except Exception as ex:
        return jsonify(error=str(ex))
    return jsonify(empid=empid, employees=Employee.get_all())
Exemplo n.º 2
0
def emp_drop():
    empid = json.loads(request.args['empid'])
    success = Employee.delete(empid)
    if not success:
        msg = 'Record not deleted for unknown reason. Contact admin.'
        return jsonify(error=msg)
    data = Employee.get_all()
    return jsonify(employees=data)
Exemplo n.º 3
0
    def _get_data(self):
        from dal.dao import Dao
        from models.project import Project
        from models.employee import Employee
        from models.assignment import Assignment

        dao = Dao(db_path=self.db_path, stateful=True)
        self._prj_rex = Project.get_all(dao)
        self._emp_rex = Employee.get_all(dao)
        self._asn_rex = Assignment.get_all(dao)
        dao.close()
Exemplo n.º 4
0
def emp_update():
    values = json.loads(request.form['params'])
    empid = values['id']
    try:
        numrows = Employee.update(values)
        if numrows != 1:
            msg = 'Record not updated for unknown reason. Contact admin.'
            return jsonify(error=msg)
    except Exception as ex:
        return jsonify(error=str(ex))
    return jsonify(empid=empid, employees=Employee.get_all())
Exemplo n.º 5
0
def prj_list():
    projects = Project.get_all()
    emp_rex = Employee.get_all()
    employees = [{'id': employee['id'], 'value': employee['name']} for employee in emp_rex]

    is_authenticated = session['is_authenticated'] if 'is_authenticated' in session else False
    page = 'projects.html' if is_authenticated else 'projects_ro.html'

    return render_template(
        page,
        title='allocat projects',
        projects=projects,
        employees=employees
    )
Exemplo n.º 6
0
def prj_list():
    # app.logger.info('User has opened Projects.')
    rex = Project.get_all()
    prjs = [rec.serialize() for rec in rex] if rex else []

    rex = Employee.get_all()
    emps = [{'id': rec.id, 'name': rec.name} for rec in rex]

    rex = Assignment.get_all()
    asns = [rec.serialize() for rec in rex] if rex else []

    return render_template('projects/project_panel.html',
                           title='allocat projects',
                           projects=prjs,
                           employees=emps,
                           assignments=asns)
Exemplo n.º 7
0
def emp_list():
    employees = Employee.get_all()
    prj_rex = Project.get_all()
    projects = [
        {
            'id': project['id'],
            'value': project['nickname'],
            'first_month': project['first_month'],
            'last_month': project['last_month']
        } for project in prj_rex]

    is_authenticated = session['is_authenticated'] if 'is_authenticated' in session else False
    page = 'employees.html' if is_authenticated else 'employees_ro.html'

    return render_template(
        page,
        title='allocat employees',
        projects=projects,
        employees=employees
    )
Exemplo n.º 8
0
 def __load(self, months):
     employees = Employee.get_all()
     assignments = Assignment.get_for_timeframe(months[0], months[-1])
     employee_assignments = {}
     for assignment in assignments:
         if assignment['employee_id'] not in employee_assignments:
             employee_assignments[assignment['employee_id']] = []
         employee_assignments[assignment['employee_id']].append(assignment)
     for employee in employees:
         row = EffortRow(employee)
         for month in months:
             cell = EffortCell(month)
             if employee['id'] not in employee_assignments:
                 continue
             for emp_asn in employee_assignments[employee['id']]:
                 if int(month) < emp_asn['first_month'] or int(month) > emp_asn['last_month']:
                     continue
                 cell.total += emp_asn['effort']
                 cell.percent_efforts.append(
                     PercentEffort(emp_asn['project'], emp_asn['effort'])
                 )
             row.effort_cells.append(cell)
         if row.effort_cells:
             self.effort_rows.append(row)
Exemplo n.º 9
0
    def _get_data(self):
        from dal.dao import Dao
        from tests.ledger_data.test_data import invoices_q2_pre_query

        from models.employee import Employee
        from models.department import Department
        from models.grant_admin import GrantAdmin
        from models.invoice import Invoice
        from models.assignment import Assignment

        dao = Dao(db_path=self.db_path, stateful=True)
        self._emp_rex = Employee.get_all(dao)
        self._dept_rex = Department.get_all(dao)
        self._grant_admin_rex = GrantAdmin.get_all(dao)
        invoices_unpaid = Invoice.get_rex(dao)
        # invoices_unpaid = invoices_q2
        self._invoices_sent = [
            invoice for invoice in invoices_unpaid if invoice.sent
        ]
        self._invoices_unsent = [
            invoice for invoice in invoices_unpaid if not invoice.sent
        ]
        self._asn_rex = Assignment.get_billables(dao)
        dao.close()
Exemplo n.º 10
0
 def __load(self, months):
     employees = Employee.get_all()
     assignments = Assignment.get_for_timeframe(months[0], months[-1])
     employee_assignments = {}
     for assignment in assignments:
         if assignment['employee_id'] not in employee_assignments:
             employee_assignments[assignment['employee_id']] = []
         employee_assignments[assignment['employee_id']].append(assignment)
     for employee in employees:
         row = EffortRow(employee)
         for month in months:
             cell = EffortCell(month)
             if employee['id'] not in employee_assignments:
                 continue
             for emp_asn in employee_assignments[employee['id']]:
                 if int(month) < emp_asn['first_month'] or int(
                         month) > emp_asn['last_month']:
                     continue
                 cell.total += emp_asn['effort']
                 cell.percent_efforts.append(
                     PercentEffort(emp_asn['project'], emp_asn['effort']))
             row.effort_cells.append(cell)
         if row.effort_cells:
             self.effort_rows.append(row)