Skip to content

Commit 4aea5a1

Browse files
authored
Merge pull request #197 from ioet/196-include-customer-info-on-entries
closes: #196 include customer information for time-entries
2 parents 93649c1 + 2fa0baf commit 4aea5a1

File tree

3 files changed

+21
-4
lines changed

3 files changed

+21
-4
lines changed

time_tracker_api/time_entries/time_entries_model.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
from time_tracker_api.activities import activities_model
2020

2121
from utils.extend_model import (
22-
add_project_name_to_time_entries,
22+
add_project_info_to_time_entries,
2323
add_activity_name_to_time_entries,
2424
create_in_condition,
2525
create_custom_query_from_str,
@@ -223,7 +223,8 @@ def find_all(
223223
projects = project_dao.get_all(
224224
custom_sql_conditions=[custom_conditions], visible_only=False
225225
)
226-
add_project_name_to_time_entries(time_entries, projects)
226+
227+
add_project_info_to_time_entries(time_entries, projects)
227228

228229
activity_dao = activities_model.create_dao()
229230
activities = activity_dao.get_all(

time_tracker_api/time_entries/time_entries_namespace.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,20 @@
138138
description='Email of the user that owns the time-entry',
139139
example=faker.email(),
140140
),
141+
'customer_id': fields.String(
142+
required=False,
143+
title='Customer ID',
144+
max_length=50,
145+
description='Unique ID for the customer the entry belongs to',
146+
example=faker.uuid4(),
147+
),
148+
'customer_name': fields.String(
149+
required=False,
150+
title='Customer Name',
151+
max_length=50,
152+
description='Name of the customer the entry belongs to',
153+
example=faker.company(),
154+
),
141155
}
142156
time_entry_response_fields.update(common_fields)
143157

utils/extend_model.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ def add_customer_name_to_projects(projects, customers):
1616
setattr(project, 'customer_name', customer.name)
1717

1818

19-
def add_project_name_to_time_entries(time_entries, projects):
19+
def add_project_info_to_time_entries(time_entries, projects):
2020
"""
21-
Add attribute project_name in time-entry model, based on project_id of the
21+
Add project info in time-entry model, based on project_id of the
2222
time_entry
2323
:param (list) time_entries: time_entries retrieved from time-entry repository
2424
:param (list) projects: projects retrieved from project repository
@@ -30,6 +30,8 @@ def add_project_name_to_time_entries(time_entries, projects):
3030
if time_entry.project_id == project.id:
3131
name = project.name + " (archived)" if project.is_deleted() else project.name
3232
setattr(time_entry, 'project_name', name)
33+
setattr(time_entry, 'customer_id', project.customer_id)
34+
setattr(time_entry, 'customer_name', project.customer_name)
3335

3436

3537
def add_activity_name_to_time_entries(time_entries, activities):

0 commit comments

Comments
 (0)