Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
refactor: 👌 add docs to utils.extend_model.py
  • Loading branch information
Angeluz-07 committed May 21, 2020
commit 449623fd9bbce152ef688327bbbe2007a110e761
17 changes: 16 additions & 1 deletion utils/extend_model.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,27 @@
# TODO : check if we can improve this by using the overwritten __add__ method
def add_customer_name_to_projects(projects, customers):
"""
Add attribute customer_name in project model, based on customer_id of the
project
:param (list) projects: projects retrieved from project repository
:param (list) customers: customers retrieved from customer repository

TODO : check if we can improve this by using the overwritten __add__ method
"""
for project in projects:
for customer in customers:
if project.customer_id == customer.id:
setattr(project, 'customer_name', customer.name)


def add_project_name_to_time_entries(time_entries, projects):
"""
Add attribute project_name in time-entry model, based on project_id of the
time_entry
:param (list) time_entries: time_entries retrieved from time-entry repository
:param (list) projects: projects retrieved from project repository

TODO : check if we can improve this by using the overwritten __add__ method
"""
for time_entry in time_entries:
for project in projects:
if time_entry.project_id == project.id:
Expand Down