Skip to content

Commit c6a8bcb

Browse files
committed
Sends UUID as reply
1 parent 09f648b commit c6a8bcb

File tree

3 files changed

+10
-11
lines changed

3 files changed

+10
-11
lines changed

app/mod_photos/controllers.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def post_photos():
4848
data_to_object ={'uuid':identifier, 'filepath': filepath, 'analysed':False, 'info':str("empty")}
4949
new_photo = Photo.create(**data_to_object)
5050

51-
data = {'filename':f_name, 'id2': new_photo.id}
51+
data = {'filename':new_photo.filepath, 'uuid': new_photo.uuid}
5252
#TODO refactor to set up necessary methods to create responses
5353
#TODO is it necessary to return 200 command
5454
resp = None
@@ -89,21 +89,22 @@ def post_photosStr():
8989
data_to_object ={'uuid':identifier, 'filepath': filepath, 'analysed':False, 'info':str("empty")}
9090
new_photo = Photo.create(**data_to_object)
9191

92-
data = {'filename':f_name, 'id2': new_photo.id }
92+
data = {'uuid': new_photo.uuid }
9393
#TODO refactor to set up necessary methods to create responses
9494
#TODO is it necessary to return 200 command
9595
resp = None
9696
if data == None:
9797
resp = responses.new200()
9898
else:
99-
resp = responses.new201(data)
99+
resp = responses.new201(data)
100100
return resp
101101

102102

103-
@mod_photos.route('/photos/<int:id>',methods=['GET'])
104-
def get_photos_one(id):
105-
photo =Photo.query.get_or_404(id)
106-
return jsonify(photo.serialize_all())
103+
@mod_photos.route('/photos/<string:uuid>',methods=['GET'])
104+
def get_photos_one(uuid):
105+
#photo =Photo.query.get_or_404(id)
106+
photo = Photo.query.filter_by(uuid=uuid).first_or_404()
107+
return jsonify(photo.serialize_all())
107108

108109
@mod_photos.route('/photos',methods=['GET'])
109110
def get_photos():

app/mod_photos/models.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class Photo(Base,CRUDMixin):
1313
filepath = db.Column(db.String(500), nullable=False)
1414
analysed = db.Column(db.Boolean,default=False)
1515
info = db.Column(db.String(1000),nullable=False)
16-
16+
1717

1818
def __init__(self,uuid,filepath,analysed=False,info=""):
1919
self.uuid = uuid
@@ -22,13 +22,11 @@ def __init__(self,uuid,filepath,analysed=False,info=""):
2222
self.info=info
2323

2424
def get_id(self):
25-
return self.id
25+
return self.id
2626

2727
def serialize(self):
2828
return {'uuid':self.uuid}
2929
def serialize_all(self):
3030
return {'uuid':self.uuid, 'filepath': self.filepath, 'analysed': self.analysed, 'info': self.info}
3131
def __repr__(self):
3232
return '<photo uuid=%r filepath=%r>' % (self.uuid,self.filepath)
33-
34-

celerybeat-schedule

0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)