Skip to content

Commit e4185b4

Browse files
author
EliuX
committed
fix: Close #85 #86 Ignore deleted objects and tweak ns constraints
1 parent a844168 commit e4185b4

File tree

10 files changed

+46
-90
lines changed

10 files changed

+46
-90
lines changed

time_tracker_api/activities/activities_model.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class ActivityDao(CRUDDao):
1515
'partition_key': PartitionKey(path='/tenant_id'),
1616
'unique_key_policy': {
1717
'uniqueKeys': [
18-
{'paths': ['/name']},
18+
{'paths': ['/name', '/deleted']},
1919
]
2020
}
2121
}

time_tracker_api/activities/activities_namespace.py

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,26 +20,13 @@
2020
),
2121
'description': fields.String(
2222
title='Description',
23+
required=False,
2324
description='Comments about the activity',
2425
example=faker.paragraph(),
2526
)
2627
})
2728

28-
activity_response_fields = {
29-
'id': fields.String(
30-
readOnly=True,
31-
required=True,
32-
title='Identifier',
33-
description='The unique identifier',
34-
example=faker.uuid4(),
35-
),
36-
'tenant_id': fields.String(
37-
required=True,
38-
title='Identifier of Tenant',
39-
description='Tenant this activity belongs to',
40-
example=faker.uuid4(),
41-
),
42-
}
29+
activity_response_fields = {}
4330
activity_response_fields.update(common_fields)
4431

4532
activity = ns.inherit(

time_tracker_api/api.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,20 @@
1717

1818
# Common models structure
1919
common_fields = {
20+
'id': fields.String(
21+
title='Identifier',
22+
readOnly=True,
23+
required=True,
24+
description='The unique identifier',
25+
example=faker.uuid4(),
26+
),
27+
'tenant_id': fields.String(
28+
title='Identifier of Tenant',
29+
readOnly=True,
30+
required=True,
31+
description='Tenant it belongs to',
32+
example=faker.uuid4(),
33+
),
2034
'deleted': fields.String(
2135
readOnly=True,
2236
required=True,

time_tracker_api/customers/customers_model.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class CustomerDao(CRUDDao):
1515
'partition_key': PartitionKey(path='/tenant_id'),
1616
'unique_key_policy': {
1717
'uniqueKeys': [
18-
{'paths': ['/name']},
18+
{'paths': ['/name', '/deleted']},
1919
]
2020
}
2121
}

time_tracker_api/customers/customers_namespace.py

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,35 +12,22 @@
1212
# Customer Model
1313
customer_input = ns.model('CustomerInput', {
1414
'name': fields.String(
15-
required=True,
1615
title='Name',
16+
required=True,
1717
max_length=50,
1818
description='Name of the customer',
1919
example=faker.company(),
2020
),
2121
'description': fields.String(
2222
title='Description',
23+
required=False,
2324
max_length=250,
2425
description='Description about the customer',
2526
example=faker.paragraph(),
2627
),
2728
})
2829

29-
customer_response_fields = {
30-
'id': fields.String(
31-
readOnly=True,
32-
required=True,
33-
title='Identifier',
34-
description='The unique identifier',
35-
example=faker.uuid4(),
36-
),
37-
'tenant_id': fields.String(
38-
required=True,
39-
title='Identifier of Tenant',
40-
description='Tenant this customer belongs to',
41-
example=faker.uuid4(),
42-
),
43-
}
30+
customer_response_fields = {}
4431
customer_response_fields.update(common_fields)
4532

4633
customer = ns.inherit(

time_tracker_api/project_types/project_types_model.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class ProjectTypeDao(CRUDDao):
1515
'partition_key': PartitionKey(path='/tenant_id'),
1616
'unique_key_policy': {
1717
'uniqueKeys': [
18-
{'paths': ['/name', '/customer_id']},
18+
{'paths': ['/name', '/customer_id', '/deleted']},
1919
]
2020
}
2121
}

time_tracker_api/project_types/project_types_namespace.py

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -12,45 +12,35 @@
1212
# ProjectType Model
1313
project_type_input = ns.model('ProjectTypeInput', {
1414
'name': fields.String(
15-
required=True,
1615
title='Name',
16+
required=True,
1717
max_length=50,
1818
description='Name of the project type',
1919
example=faker.random_element(["Customer","Training","Internal"]),
2020
),
2121
'description': fields.String(
2222
title='Description',
23+
required=False,
2324
max_length=250,
24-
description='Description about the project type',
25+
description='Comments about the project type',
2526
example=faker.paragraph(),
2627
),
2728
'customer_id': fields.String(
2829
title='Identifier of the Customer',
29-
description='Customer this project type belongs to',
30+
required=False,
31+
description='Customer this project type belongs to. '
32+
'If not specified, it will be considered an internal project of the tenant.',
3033
example=faker.uuid4(),
3134
),
3235
'parent_id': fields.String(
33-
title='Identifier of Parent of the project type',
34-
description='Defines a self reference of the model ProjectType',
36+
title='Identifier of the parent project type',
37+
required=False,
38+
description='This parent node allows to created a tree-like structure for project types',
3539
example=faker.uuid4(),
3640
),
3741
})
3842

39-
project_type_response_fields = {
40-
'id': fields.String(
41-
readOnly=True,
42-
required=True,
43-
title='Identifier',
44-
description='The unique identifier',
45-
example=faker.uuid4(),
46-
),
47-
'tenant_id': fields.String(
48-
required=True,
49-
title='Identifier of Tenant',
50-
description='Tenant this project type belongs to',
51-
example=faker.uuid4(),
52-
),
53-
}
43+
project_type_response_fields = {}
5444
project_type_response_fields.update(common_fields)
5545

5646
project_type = ns.inherit(

time_tracker_api/projects/projects_model.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class ProjectDao(CRUDDao):
1515
'partition_key': PartitionKey(path='/tenant_id'),
1616
'unique_key_policy': {
1717
'uniqueKeys': [
18-
{'paths': ['/name', '/customer_id']},
18+
{'paths': ['/name', '/customer_id', '/deleted']},
1919
]
2020
}
2121
}

time_tracker_api/projects/projects_namespace.py

Lines changed: 10 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -20,38 +20,27 @@
2020
),
2121
'description': fields.String(
2222
title='Description',
23+
required=False,
2324
max_length=250,
2425
description='Description about the project',
2526
example=faker.paragraph(),
2627
),
2728
'customer_id': fields.String(
28-
required=True,
2929
title='Identifier of the Customer',
30-
description='Customer this project belongs to',
31-
example=faker.uuid4(),
32-
),
33-
'project_type_id': fields.String(
34-
title='Identifier of Project type',
35-
description='Type of the project. Used for grouping',
36-
example=faker.uuid4(),
37-
)
38-
})
39-
40-
project_response_fields = {
41-
'id': fields.String(
42-
readOnly=True,
43-
required=True,
44-
title='Identifier',
45-
description='The unique identifier',
30+
required=False,
31+
description='Customer this project type belongs to. '
32+
'If not specified, it will be considered an internal project of the tenant.',
4633
example=faker.uuid4(),
4734
),
48-
'tenant_id': fields.String(
35+
'parent_id': fields.String(
36+
title='Identifier of the parent project type',
4937
required=False,
50-
title='Identifier of Tenant',
51-
description='Tenant this project belongs to',
38+
description='This parent node allows to created a tree-like structure for projects',
5239
example=faker.uuid4(),
5340
),
54-
}
41+
})
42+
43+
project_response_fields = {}
5544
project_response_fields.update(common_fields)
5645

5746
project = ns.inherit(

time_tracker_api/time_entries/time_entries_namespace.py

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,9 @@
5050
),
5151
'uri': fields.String(
5252
title='Uniform Resource identifier',
53-
description='Either identifier or locator',
53+
description='Either identifier or locator of a resource in the Internet that helps to understand'
54+
' what this time entry was about. For example, A Jira ticket, a Github issue, a Google document.',
55+
required=False,
5456
example=faker.random_element([
5557
'https://github.com/ioet/time-tracker-backend/issues/51',
5658
'#54',
@@ -75,25 +77,12 @@
7577
})
7678

7779
time_entry_response_fields = {
78-
'id': fields.String(
79-
readOnly=True,
80-
title='Identifier',
81-
description='The unique identifier',
82-
example=faker.uuid4(),
83-
),
8480
'running': fields.Boolean(
8581
readOnly=True,
8682
title='Is it running?',
8783
description='Whether this time entry is currently running or not',
8884
example=faker.boolean(),
8985
),
90-
'tenant_id': fields.String(
91-
required=True,
92-
readOnly=True,
93-
title='Identifier of Tenant',
94-
description='Tenant this project belongs to',
95-
example=faker.uuid4(),
96-
),
9786
'owner_id': fields.String(
9887
required=True,
9988
readOnly=True,

0 commit comments

Comments
 (0)