22from .projects_model import project_dao
33from time_tracker_api .errors import MissingResource
44from time_tracker_api .api import audit_fields
5+ from faker import Faker
6+
7+ faker = Faker ()
58
69ns = Namespace ('projects' , description = 'API for projects (clients)' )
710
1114 required = True ,
1215 title = 'Name' ,
1316 max_length = 50 ,
14- description = 'Name of the project'
17+ description = 'Name of the project' ,
18+ example = faker .company (),
1519 ),
1620 'description' : fields .String (
1721 title = 'Description' ,
18- description = 'Description about the project'
22+ description = 'Description about the project' ,
23+ example = faker .paragraph (),
1924 ),
2025 'type' : fields .String (
2126 required = True ,
2227 title = 'Type' ,
2328 max_length = 30 ,
2429 description = 'If it is `Costumer`, `Training` or other type' ,
30+ example = faker .word (['Customer' , 'Training' ]),
2531 ),
2632})
2733
3137 required = True ,
3238 title = 'Identifier' ,
3339 description = 'The unique identifier' ,
40+ example = faker .random_int (1 , 9999 ),
3441 )
3542}
3643project_response_fields .update (audit_fields )
@@ -66,24 +73,24 @@ def post(self):
6673 help = 'Is the project active?' )
6774
6875
69- @ns .route ('/<string:uid >' )
76+ @ns .route ('/<string:id >' )
7077@ns .response (404 , 'Project not found' )
71- @ns .param ('uid ' , 'The project identifier' )
78+ @ns .param ('id ' , 'The project identifier' )
7279class Project (Resource ):
7380 @ns .doc ('get_project' )
7481 @ns .marshal_with (project )
75- def get (self , uid ):
82+ def get (self , id ):
7683 """Retrieve a project"""
77- return project_dao .get (uid )
84+ return project_dao .get (id )
7885
7986 @ns .doc ('update_project_status' )
8087 @ns .expect (project )
8188 @ns .response (204 , 'State of the project successfully updated' )
82- def post (self , uid ):
89+ def post (self , id ):
8390 """Updates a project using form data"""
8491 try :
8592 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
8794 except ValueError :
8895 abort (code = 400 )
8996 except MissingResource as e :
@@ -92,13 +99,13 @@ def post(self, uid):
9299 @ns .doc ('put_project' )
93100 @ns .expect (project_input )
94101 @ns .marshal_with (project )
95- def put (self , uid ):
102+ def put (self , id ):
96103 """Create or replace a project"""
97- return project_dao .update (uid , ns .payload )
104+ return project_dao .update (id , ns .payload )
98105
99106 @ns .doc ('delete_project' )
100107 @ns .response (204 , 'Project deleted successfully' )
101- def delete (self , uid ):
108+ def delete (self , id ):
102109 """Deletes a project"""
103- project_dao .delete (uid )
110+ project_dao .delete (id )
104111 return None , 204
0 commit comments