Skip to content

Commit a2a4411

Browse files
committed
Fixes #7 create technology response for server generated fields
1 parent 44092ef commit a2a4411

File tree

1 file changed

+22
-19
lines changed

1 file changed

+22
-19
lines changed

time_tracker_api/technologies/technologies_api.py

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,48 +4,51 @@
44

55
# Technology Model
66
technology = ns.model('Technology', {
7-
'id': fields.String(
8-
readOnly=True,
9-
required=True,
10-
title='Identifier',
11-
description='The unique id of the technology'
12-
),
13-
'tenant_id': fields.String(
14-
required=True,
15-
title='Tenant',
16-
max_length=64,
17-
description='The tenant this technology belongs to'
18-
),
197
'name': fields.String(
208
required=True,
219
title='Name',
2210
max_length=50,
2311
description='Name of the technology'
2412
),
13+
})
14+
15+
technology_response = ns.inherit('TechnologyResponse', technology, {
16+
'id': fields.String(
17+
readOnly=True,
18+
required=True,
19+
title='Identifier',
20+
description='The unique identifier',
21+
),
2522
'created_at': fields.Date(
23+
readOnly=True,
2624
title='Created',
2725
description='Date of creation'
2826
),
2927
'created_by': fields.String(
30-
required=True,
28+
readOnly=True,
3129
title='Creator',
3230
max_length=64,
33-
description='Id of user who first added this technology',
31+
description='User that created it',
32+
),
33+
'tenant_id': fields.String(
34+
readOnly=True,
35+
title='Tenant',
36+
max_length=64,
37+
description='The tenant this belongs to',
3438
),
3539
})
3640

37-
3841
@ns.route('')
3942
class Technologies(Resource):
4043
@ns.doc('list_technologies')
41-
@ns.marshal_list_with(technology, code=200)
44+
@ns.marshal_list_with(technology_response, code=200)
4245
def get(self):
4346
"""List all technologies"""
4447
return [], 200
4548

4649
@ns.doc('create_technology')
4750
@ns.expect(technology)
48-
@ns.marshal_with(technology, code=201)
51+
@ns.marshal_with(technology_response, code=201)
4952
def post(self):
5053
"""Create a technology"""
5154
return ns.payload, 201
@@ -56,7 +59,7 @@ def post(self):
5659
@ns.param('uid', 'The technology identifier')
5760
class Technology(Resource):
5861
@ns.doc('get_technology')
59-
@ns.marshal_with(technology)
62+
@ns.marshal_with(technology_response)
6063
def get(self, uid):
6164
"""Retrieve a technology"""
6265
return {}
@@ -71,7 +74,7 @@ def post(self, uid):
7174

7275
@ns.doc('put_technology')
7376
@ns.expect(technology)
74-
@ns.marshal_with(technology)
77+
@ns.marshal_with(technology_response)
7578
def put(self, uid):
7679
"""Create or replace a technology"""
7780
return ns.payload()

0 commit comments

Comments
 (0)