Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix - rename uid to uid in some files, fix name file
  • Loading branch information
Angeluz-07 committed Mar 17, 2020
commit 84144a9946b88e096dd977c3289b5b94d41548b6
20 changes: 10 additions & 10 deletions time_tracker_api/projects/projects_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,29 +10,29 @@ def __init__(self):
def get_all(self):
return self.projects

def get(self, uid):
def get(self, id):
for project in self.projects:
if project.get('uid') == uid:
if project.get('id') == id:
return project
raise MissingResource("Project '%s' not found" % uid)
raise MissingResource("Project '%s' not found" % id)

def create(self, project):
self.counter += 1
project['uid'] = str(self.counter)
project['id'] = str(self.counter)
self.projects.append(project)
return project

def update(self, uid, data):
project = self.get(uid)
def update(self, id, data):
project = self.get(id)
if project:
project.update(data)
return project
else:
raise MissingResource("Project '%s' not found" % uid)
raise MissingResource("Project '%s' not found" % id)

def delete(self, uid):
if uid:
project = self.get(uid)
def delete(self, id):
if id:
project = self.get(id)
self.projects.remove(project)

def flush(self):
Expand Down
20 changes: 10 additions & 10 deletions time_tracker_api/projects/projects_namespace.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,24 +73,24 @@ def post(self):
help='Is the project active?')


@ns.route('/<string:uid>')
@ns.route('/<string:id>')
@ns.response(404, 'Project not found')
@ns.param('uid', 'The project identifier')
@ns.param('id', 'The project identifier')
class Project(Resource):
@ns.doc('get_project')
@ns.marshal_with(project)
def get(self, uid):
def get(self, id):
"""Retrieve a project"""
return project_dao.get(uid)
return project_dao.get(id)

@ns.doc('update_project_status')
@ns.expect(project)
@ns.response(204, 'State of the project successfully updated')
def post(self, uid):
def post(self, id):
"""Updates a project using form data"""
try:
update_data = project_update_parser.parse_args()
return project_dao.update(uid, update_data), 200
return project_dao.update(id, update_data), 200
except ValueError:
abort(code=400)
except MissingResource as e:
Expand All @@ -99,13 +99,13 @@ def post(self, uid):
@ns.doc('put_project')
@ns.expect(project_input)
@ns.marshal_with(project)
def put(self, uid):
def put(self, id):
"""Create or replace a project"""
return project_dao.update(uid, ns.payload)
return project_dao.update(id, ns.payload)

@ns.doc('delete_project')
@ns.response(204, 'Project deleted successfully')
def delete(self, uid):
def delete(self, id):
"""Deletes a project"""
project_dao.delete(uid)
project_dao.delete(id)
return None, 204
10 changes: 5 additions & 5 deletions time_tracker_api/technologies/technologies_namespace.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,25 +51,25 @@ def post(self):
return ns.payload, 201


@ns.route('/<string:uid>')
@ns.route('/<string:id>')
@ns.response(404, 'Technology not found')
@ns.param('uid', 'The technology identifier')
@ns.param('id', 'The technology identifier')
class Technology(Resource):
@ns.doc('get_technology')
@ns.marshal_with(technology)
def get(self, uid):
def get(self, id):
"""Retrieve a technology"""
return {}

@ns.doc('put_technology')
@ns.expect(technology_input)
@ns.marshal_with(technology)
def put(self, uid):
def put(self, id):
"""Updates a technology"""
return ns.payload()

@ns.doc('delete_technology')
@ns.response(204, 'Technology deleted successfully')
def delete(self, uid):
def delete(self, id):
"""Deletes a technology"""
return None, 204