Esempio n. 1
0
 def deletereaction(self, rid):
     dao = ReactionsDAO()
     if not dao.getReactionsById(rid):
         return jsonify(Error="reaction not found."), 404
     else:
         dao.delete(rid)
         return jsonify(DeleteStatus="OK"), 200
Esempio n. 2
0
 def updatereaction(self, rid, form):
     dao = ReactionsDAO()
     if not dao.getReactionsById(rid):
         return jsonify(Error="reaction not found."), 404
     else:
         if len(form) != 2:
             return jsonify(Error="Malformed update request"), 400
         else:
             rdate = form['rdate']
             reaction = form['reaction']
             if rdate and reaction:
                 dao.update(rid, rdate, reaction)
                 result = self.build_reaction_attributes(
                     rid, rdate, reaction)
                 return jsonify(reaction=result), 200
             else:
                 return jsonify(
                     Error="Unexpected attributes in update request"), 400
Esempio n. 3
0
 def searchreaction(self, args):
     id = args.get("id")
     date = args.get("date")
     dao = ReactionsDAO()
     reactions_list = []
     if (len(args) == 2) and id and date:
         reactions_list = dao.getReactionsByIdAndDate(id, date)
     elif (len(args) == 1) and id:
         reactions_list = dao.getReactionsById(id)
     elif (len(args) == 1) and date:
         reactions_list = dao.getReactionsBydate(date)
     else:
         return jsonify(Error="Malformed query string"), 400
     result_list = []
     for row in reactions_list:
         result = self.build_reaction_dict(row)
         result_list.append(result)
     return jsonify(Reactions=result_list)