2
2
from .projects_model import project_dao
3
3
from time_tracker_api .errors import MissingResource
4
4
from time_tracker_api .api import audit_fields
5
+ from faker import Faker
6
+
7
+ faker = Faker ()
5
8
6
9
ns = Namespace ('projects' , description = 'API for projects (clients)' )
7
10
11
14
required = True ,
12
15
title = 'Name' ,
13
16
max_length = 50 ,
14
- description = 'Name of the project'
17
+ description = 'Name of the project' ,
18
+ example = faker .company (),
15
19
),
16
20
'description' : fields .String (
17
21
title = 'Description' ,
18
- description = 'Description about the project'
22
+ description = 'Description about the project' ,
23
+ example = faker .paragraph (),
19
24
),
20
25
'type' : fields .String (
21
26
required = True ,
22
27
title = 'Type' ,
23
28
max_length = 30 ,
24
29
description = 'If it is `Costumer`, `Training` or other type' ,
30
+ example = faker .word (['Customer' , 'Training' ]),
25
31
),
26
32
})
27
33
31
37
required = True ,
32
38
title = 'Identifier' ,
33
39
description = 'The unique identifier' ,
40
+ example = faker .random_int (1 , 9999 ),
34
41
)
35
42
}
36
43
project_response_fields .update (audit_fields )
@@ -66,24 +73,24 @@ def post(self):
66
73
help = 'Is the project active?' )
67
74
68
75
69
- @ns .route ('/<string:uid >' )
76
+ @ns .route ('/<string:id >' )
70
77
@ns .response (404 , 'Project not found' )
71
- @ns .param ('uid ' , 'The project identifier' )
78
+ @ns .param ('id ' , 'The project identifier' )
72
79
class Project (Resource ):
73
80
@ns .doc ('get_project' )
74
81
@ns .marshal_with (project )
75
- def get (self , uid ):
82
+ def get (self , id ):
76
83
"""Retrieve a project"""
77
- return project_dao .get (uid )
84
+ return project_dao .get (id )
78
85
79
86
@ns .doc ('update_project_status' )
80
87
@ns .expect (project )
81
88
@ns .response (204 , 'State of the project successfully updated' )
82
- def post (self , uid ):
89
+ def post (self , id ):
83
90
"""Updates a project using form data"""
84
91
try :
85
92
update_data = project_update_parser .parse_args ()
86
- return project_dao .update (uid , update_data ), 200
93
+ return project_dao .update (id , update_data ), 200
87
94
except ValueError :
88
95
abort (code = 400 )
89
96
except MissingResource as e :
@@ -92,13 +99,13 @@ def post(self, uid):
92
99
@ns .doc ('put_project' )
93
100
@ns .expect (project_input )
94
101
@ns .marshal_with (project )
95
- def put (self , uid ):
102
+ def put (self , id ):
96
103
"""Create or replace a project"""
97
- return project_dao .update (uid , ns .payload )
104
+ return project_dao .update (id , ns .payload )
98
105
99
106
@ns .doc ('delete_project' )
100
107
@ns .response (204 , 'Project deleted successfully' )
101
- def delete (self , uid ):
108
+ def delete (self , id ):
102
109
"""Deletes a project"""
103
- project_dao .delete (uid )
110
+ project_dao .delete (id )
104
111
return None , 204
0 commit comments