From 29b81cbd217ab3e846a74300b501c2d2c1f44523 Mon Sep 17 00:00:00 2001 From: tanshu Date: Sat, 14 Jul 2018 10:52:39 +0530 Subject: [PATCH] Fix: Employee was not saving because of isStarred, added that functionality to employee --- brewman/models/master.py | 12 ++++++------ brewman/views/employee.py | 4 +++- .../employee-detail/employee-detail.component.css | 7 +++++++ .../employee-detail/employee-detail.component.html | 3 +++ overlord/src/app/employee/employee.ts | 1 + 5 files changed, 20 insertions(+), 7 deletions(-) diff --git a/brewman/models/master.py b/brewman/models/master.py index 8ad8fb34..c158bff8 100644 --- a/brewman/models/master.py +++ b/brewman/models/master.py @@ -1,5 +1,5 @@ -from datetime import date import uuid +from datetime import date from sqlalchemy import ( UniqueConstraint, @@ -16,8 +16,8 @@ from sqlalchemy import ( ) from sqlalchemy.orm import relationship -from .meta import Base from brewman.models.guidtype import GUID +from .meta import Base class Product(Base): @@ -332,15 +332,15 @@ class Employee(AccountBase): attendances = relationship('Attendance', backref='employee', cascade=None, cascade_backrefs=False) fingerprints = relationship('Fingerprint', backref='employee', cascade=None, cascade_backrefs=False) - def __init__(self, code=None, name=None, is_active=None, cost_centre_id=None, designation=None, salary=None, - service_points=None, joining_date=None, leaving_date=None): + def __init__(self, code=None, name=None, is_starred=None, is_active=None, cost_centre_id=None, designation=None, + salary=None, service_points=None, joining_date=None, leaving_date=None): self.designation = designation self.salary = salary self.service_points = service_points self.joining_date = joining_date self.leaving_date = leaving_date - super().__init__(code=code, name=name, type=10, is_active=is_active, is_reconcilable=False, - cost_centre_id=cost_centre_id) + super().__init__(code=code, name=name, type=10, is_starred=is_starred, is_active=is_active, + is_reconcilable=False, cost_centre_id=cost_centre_id) def create(self, dbsession): code = dbsession.query(func.max(AccountBase.code)).filter(AccountBase.type == self.type).one()[0] diff --git a/brewman/views/employee.py b/brewman/views/employee.py index 10c018b8..0da0b3ec 100644 --- a/brewman/views/employee.py +++ b/brewman/views/employee.py @@ -53,6 +53,7 @@ def save(request): except (ValueError, KeyError, TypeError): raise ValidationError("Joining Date is not a valid date") + is_starred = request.json_body['isStarred'] is_active = request.json_body['isActive'] try: if is_active: @@ -64,7 +65,7 @@ def save(request): except (ValueError, KeyError, TypeError): raise ValidationError("Leaving Date is not a valid date") - item = Employee(0, name, is_active, cost_centre_id, designation, salary, service_points, joining_date, + item = Employee(0, name, is_starred, is_active, cost_centre_id, designation, salary, service_points, joining_date, leaving_date).create(request.dbsession) transaction.commit() return employee_info(item.id, request.dbsession) @@ -102,6 +103,7 @@ def update(request): except (ValueError, KeyError, TypeError): raise ValidationError("Joining Date is not a valid date") + item.is_starred = request.json_body['isStarred'] item.is_active = request.json_body['isActive'] try: if item.is_active: diff --git a/overlord/src/app/employee/employee-detail/employee-detail.component.css b/overlord/src/app/employee/employee-detail/employee-detail.component.css index e69de29b..1c0ef634 100644 --- a/overlord/src/app/employee/employee-detail/employee-detail.component.css +++ b/overlord/src/app/employee/employee-detail/employee-detail.component.css @@ -0,0 +1,7 @@ +.gold { + color: gold; +} + +.pointer { + cursor: pointer; +} diff --git a/overlord/src/app/employee/employee-detail/employee-detail.component.html b/overlord/src/app/employee/employee-detail/employee-detail.component.html index e79b4f4c..e60d8049 100644 --- a/overlord/src/app/employee/employee-detail/employee-detail.component.html +++ b/overlord/src/app/employee/employee-detail/employee-detail.component.html @@ -1,6 +1,9 @@ Employee + + {{ item.isStarred ? 'star' : 'star_border' }} +
diff --git a/overlord/src/app/employee/employee.ts b/overlord/src/app/employee/employee.ts index 5998c6ce..f2fecef6 100644 --- a/overlord/src/app/employee/employee.ts +++ b/overlord/src/app/employee/employee.ts @@ -4,6 +4,7 @@ export class Employee { id: string; code: number; name: string; + isStarred: boolean; isActive: boolean; designation: string; salary: number;