Example #1
0
 def save(self, team_entity: TeamEntity):
     team_model = DataConverters.from_team_entity(team_entity)
     print(F"Team: {team_model.created_at}")
     team_model.save()
     team_model.refresh_from_db()
     new_team_entity = DataConverters.to_team_entity(team_model)
     print(F"New team entity: {new_team_entity.name}")
     return new_team_entity
Example #2
0
 def save(self, employee_entity: EmployeeEntity):
     """
     Concrete implementation of abstract save function in EmployeeReport
     :param employee_entity:
     :return:
     """
     employee_model = DataConverters.from_employee_entity(employee_entity)
     employee_model.save()
     employee_model.refresh_from_db()
     return DataConverters.to_employee_entity(employee_model)
Example #3
0
 def retrieve_all(self):
     work_arrangements = WorkArrangement.objects.all()
     wa_entities = []
     for work_arrangement in work_arrangements:
         wa_entities.append(
             DataConverters.to_work_arrangement_entity(work_arrangement))
     return wa_entities
 def retrieve_by_work_arrangement_pk(self, work_arrangement_pk):
     try:
         work_time_obj = WorkTime.objects.get(
             work_arrangement_id=work_arrangement_pk)
         return DataConverters.to_work_time_entity(work_time_obj)
     except WorkTime.DoesNotExist:
         return None
 def retrieve_all_work_times(self):
     work_time_objs = WorkTime.objects.all()
     work_time_entities = []
     for work_time in work_time_objs:
         work_time_entities.append(
             DataConverters.to_work_time_entity(work_time))
     return work_time_entities
Example #6
0
 def delete(self, team_pk):
     try:
         team = Team.objects.get(pk=team_pk)
         team.delete()
         team_entity = DataConverters.to_team_entity(team)
         return team_entity
     except Team.DoesNotExist:
         raise Team.DoesNotExist
 def save_work_time(self, wt_entity: WorkTimeEntity):
     wt_model = WorkTime(id=wt_entity.id,
                         employee_id=wt_entity.employee.id,
                         hours=wt_entity.hours,
                         work_arrangement_id=wt_entity.work_arrangement.id)
     wt_model.save()
     wt_model.refresh_from_db()
     return DataConverters.to_work_time_entity(wt_model)
Example #8
0
 def delete(self, employee_pk: int):
     try:
         employee = Employee.objects.get(pk=employee_pk)
         employee.delete()
         employee_entity = DataConverters.to_employee_entity(employee)
         return employee_entity
     except Employee.DoesNotExist:
         raise Employee.DoesNotExist
Example #9
0
    def retrieve_all(self):
        team_objects = Team.objects.all()
        team_models = []

        for team in team_objects:

            team_models.append(DataConverters.to_team_entity(team))
        return team_models
Example #10
0
    def retrieve_all_teams_employees(self):
        # loop through team objects and each team employees
        team_employees_entities = []
        team_employees = TeamEmployee.objects.all()

        for te_model in team_employees:
            team_employees_entities.append(
                DataConverters.to_team_employee_entity(te_model))
        return team_employees_entities
Example #11
0
 def save_team_employee(self, te_entity: TeamEmployeeEntity):
     te_model = TeamEmployee(team_id=te_entity.team.id,
                             employee_id=te_entity.employee.id,
                             created_at=te_entity.created_at,
                             updated_at=te_entity.updated_at)
     te_model.save()
     print("Saved")
     te_model.refresh_from_db()
     return DataConverters.to_team_employee_entity(te_model)
Example #12
0
 def retrieve_all(self):
     """
     Concrete implementation of abstract retrieve_all function in EmployeeRepo port
     :return:
     """
     employee_objs = Employee.objects.all()
     employee_models = []
     for employee in employee_objs:
         employee_models.append(DataConverters.to_employee_entity(employee))
     return employee_models
Example #13
0
    def save(self, wa_entity: WorkArrangementEntity):

        wa_model = WorkArrangement(id=wa_entity.id,
                                   percent=wa_entity.percent,
                                   employee_id=wa_entity.employee.id,
                                   team_id=wa_entity.team.id,
                                   remarks=wa_entity.remarks)
        wa_model.save()
        wa_model.refresh_from_db()
        return DataConverters.to_work_arrangement_entity(wa_model)
Example #14
0
 def retrieve_all_team_leaders(self):
     """
     Retrieve all teams and get their respective leaders as employee entities
     :return:
     """
     team_leaders = TeamLeader.objects.all()
     leader_entities = []
     for team_leader in team_leaders:
         leader_entities.append(DataConverters.to_team_leader_entity(team_leader))
     return leader_entities
Example #15
0
 def employee_exists(self, employee_pk):
     """
     Implementation of abstract employee_exists function in EmployeeRepo port
     :param employee_pk:
     :return:
     """
     try:
         employee = Employee.objects.get(pk=employee_pk)
         return DataConverters.to_employee_entity(employee)
     except Employee.DoesNotExist:
         return None
Example #16
0
 def save_team_leader(self, tl_entity: TeamLeaderEntity):
     team_leader = TeamLeader(
         id=tl_entity.id,
         leader_id=tl_entity.leader.id,
         team_id=tl_entity.team.id,
         created_at=tl_entity.created_at,
         updated_at=tl_entity.updated_at
     )
     team_leader.save()
     team_leader.refresh_from_db()
     return DataConverters.to_team_leader_entity(team_leader)
Example #17
0
 def retrieve_team_leader(self, tl_pk: int):
     """
     Retrieve team leader and all teams it leader
     :param tl_pk:
     :return:
     """
     try:
         team_leader = TeamLeader.objects.get(pk=tl_pk)
         return DataConverters.to_team_leader_entity(team_leader)
     except TeamLeader.DoesNotExist:
         return None
Example #18
0
 def retrieve_by_id(self, employee_pk):
     """
     Concrete implementation of abstract retrieve_by_id function in EmployeeRepo port
     :param employee_pk:
     :return:
     """
     try:
         employee_obj = Employee.objects.get(pk=employee_pk)
         return DataConverters.to_employee_entity(employee_obj)
     except Employee.DoesNotExist:
         return None
Example #19
0
 def delete_team_employee(self, te_pk: int):
     """Retrieve tea"""
     team_employee = TeamEmployee.objects.get(pk=te_pk)
     team_employee.delete()
     return DataConverters.to_team_employee_entity(team_employee)
Example #20
0
 def team_employee_exists(self, te_pk):
     try:
         team_employee = TeamEmployee.objects.get(pk=te_pk)
         return DataConverters.to_team_employee_entity(team_employee)
     except TeamEmployee.DoesNotExist:
         return None
Example #21
0
 def retrieve_work_time(self, wt_pk: int):
     work_time_obj = WorkTime.objects.get(pk=wt_pk)
     return DataConverters.to_work_time_entity(work_time_obj)
Example #22
0
 def retrieve_team_employees(self, te_pk: int):
     te_model = TeamEmployee.objects.get(pk=te_pk)
     return DataConverters.to_team_employee_entity(te_model)
Example #23
0
 def work_arrangement_exists(self, wa_pk: int):
     try:
         work_arrangement = WorkArrangement.objects.get(pk=wa_pk)
         return DataConverters.to_work_arrangement_entity(work_arrangement)
     except WorkArrangement.DoesNotExist:
         return None
Example #24
0
 def team_exists(self, team_pk):
     try:
         team_obj = Team.objects.get(pk=team_pk)
         return DataConverters.to_team_entity(team_obj)
     except Team.DoesNotExist:
         return None
Example #25
0
 def delete(self, wa_pk: int):
     work_arrangement = WorkArrangement.objects.get(pk=wa_pk)
     work_arrangement.delete()
     return DataConverters.to_work_arrangement_entity(work_arrangement)