Ejemplo n.º 1
0
 def getHashtagById(self, chat_id):
     dao = HashtagsDAO()
     row = dao.getHashtagById(chat_id)
     if not row:
         return jsonify(Error="Hashtag Not Found"), 404
     else:
         chat = self.build_hashtag_dict(row)
         return jsonify(Hashtag=chat)
Ejemplo n.º 2
0
 def getHashtagsPostX(self, post_id):
     dao = HashtagsDAO()
     hashtag_list = dao.getHashtahPostX(post_id)
     result_list = []
     for row in hashtag_list:
         result = self.build_hashtag_dict(row)
         result_list.append(result)
     return jsonify(Hashtag=result_list)
Ejemplo n.º 3
0
 def getAllHashtags(self):
     dao = HashtagsDAO()
     hashtag_list = dao.getAllHashtags()
     result_list = []
     for row in hashtag_list:
         result = self.build_hashtag_dict(row)
         result_list.append(result)
     return jsonify(Hashtag=result_list)
Ejemplo n.º 4
0
 def getHashtagId(self, hash_name):
     dao = HashtagsDAO()
     row = dao.getHashtagId(hash_name)
     if not row:
         return jsonify(Error="Hashtag Not Found"), 404
     else:
         chat = self.build_hashtag_id_dict(row)
         return jsonify(Hashtag=chat)
Ejemplo n.º 5
0
 def getDailyHashtags(self):
     dao = HashtagsDAO()
     hashtag_list = dao.getDailyHashtags()
     if not hashtag_list:
         return jsonify(Error="Session Not Found"), 404
     else:
         result_list = []
         for index, row in enumerate(hashtag_list, start=1):
             position = self.build_daily_hashtag_dict(row, index)
             result_list.append(position)
         return jsonify(Hashtag=result_list)
Ejemplo n.º 6
0
 def insertHashtagToPost(self, json):
     print(json)
     p_with_hashtag = json['p_with_hashtag']
     hashtag_id = json['hashtag_id']
     post = PostsDAO().getPostById(p_with_hashtag)
     hashtag = HashtagsDAO().getHashtagById(hashtag_id)
     if not post:
         return jsonify(Error="Post not found."), 404
     elif not hashtag:
         return jsonify(Error="Hashtag not found."), 404
     elif p_with_hashtag and hashtag_id:
         HashtagsDAO().insertHashtagToPost(p_with_hashtag, hashtag_id)
         result = self.build_hashtag_Post(p_with_hashtag, hashtag_id)
         return jsonify(Has_Hashatg=result)
     else:
         return jsonify(Error="Unexpected attributes in post request"), 400
Ejemplo n.º 7
0
 def createHashtag(self, json):
     hash_name = json['hash_name']
     if hash_name:
         hashtag = HashtagsDAO().createHashtag(hash_name)
         result = self.build_hashtag_attributes(hashtag, hash_name)
         return jsonify(Hashtag=result), 201
     else:
         return jsonify(
             Error="Unexpected attributes in hashtag request"), 400