コード例 #1
0
 def getAllReactionsbyMessageID(self, mid):
     dao = ReactionDAO()
     result = dao.getAllReactionsbyMessageID(mid)
     if result == None:
         return jsonify(Error="NOT FOUND"), 404
     else:
         mapped_result = []
         for r in result:
             mapped_result.append(self.mapToDict(r))
         return jsonify(Reactions=mapped_result)
コード例 #2
0
 def getAllDislikes(self):
     dao = ReactionDAO()
     result = dao.getAllDislikes()
     if result == None:
         return jsonify(Error="NOT FOUND"), 404
     else:
         mapped_result = []
         for r in result:
             mapped_result.append(self.mapToDict(r))
         return jsonify(Reactions=mapped_result)
コード例 #3
0
ファイル: reactions.py プロジェクト: JuanCCabrera/DBProject
 def getNumberOfDislikesByMessageID(self, mid):
     dao = ReactionDAO()
     result = dao.getNumberOfDislikesByMessageID(mid)
     if result == None:
         return jsonify(Error="NOT FOUND"), 404
     else:
         mapped_result = []
         for r in result:
             mapped_result.append(self.mapToDictNumberOfLikesOrDislikes(r))
         return jsonify(Reactions=mapped_result)
コード例 #4
0
ファイル: reactions.py プロジェクト: JuanCCabrera/DBProject
 def updateDislikeinMessage(self, form):
     dao = ReactionDAO()
     if len(form) != 2:
         return jsonify(Error="Malformed insert request"), 400
     else:
         MReaction = False
         UID = form['UID']
         MID = form['MID']
         if UID and MID:
             row = dao.updateReactioninMessage(MReaction, UID, MID)
             if row == None:
                 return jsonify(Error="Invalid Update"), 404
             else:
                 result = self.ReactioninMessage_dict(MReaction, UID, MID)
                 return jsonify(Dislike=result)
         else:
             return jsonify(
                 Error="Unexpected attributes in insert request"), 400
コード例 #5
0
ファイル: reactions.py プロジェクト: JuanCCabrera/DBProject
 def insertLikeinMessage(self, form):
     dao = ReactionDAO()
     if len(form) != 2:
         return jsonify(Error="Malformed insert request"), 400
     else:
         UID = form['UID']
         MID = form['MID']
         validate = dao.validateReaction(UID, MID)
         if validate == None:
             MReaction = True
             if UID and MID:
                 row = dao.insertReactioninMessage(MReaction, UID, MID)
                 if row == None:
                     return jsonify(Error="Invalid Insert"), 404
                 else:
                     result = self.ReactioninMessage_dict(
                         MReaction, UID, MID)
                     return jsonify(Like=result)
             else:
                 return jsonify(
                     Error="Unexpected attributes in insert request"), 400
         else:
             return self.updateLikeinMessage(form)