Beispiel #1
0
 def removeAnsVote(self, ansID):
     USERS_COLLECTION.find_one_and_update(
         {'_id': self.username}, {'$pull': {
             'voted_ans': {
                 'ansID': ansID
             }
         }})
Beispiel #2
0
 def updateAnsVote(self, ansID, vote):
     USERS_COLLECTION.find_one_and_update(
         {
             '_id': self.username,
             'voted_ans.ansID': ansID
         }, {'$set': {
             'voted_ans.$.vote': vote
         }})
Beispiel #3
0
 def removeQuesVote(self, quesID):
     USERS_COLLECTION.find_one_and_update(
         {'_id': self.username},
         {'$pull': {
             'voted_ques': {
                 'quesID': quesID
             }
         }})
Beispiel #4
0
 def updateQuesVote(self, quesID, vote):
     USERS_COLLECTION.find_one_and_update(
         {
             '_id': self.username,
             'voted_ques.quesID': quesID
         }, {'$set': {
             'voted_ques.$.vote': vote
         }})
Beispiel #5
0
 def addQuesVote(self, quesID, vote):
     USERS_COLLECTION.find_one_and_update(
         {'_id': self.username},
         {'$addToSet': {
             'voted_ques': {
                 'quesID': quesID,
                 'vote': vote
             }
         }})
Beispiel #6
0
 def addAnsVote(self, ansID, vote):
     USERS_COLLECTION.find_one_and_update(
         {'_id': self.username},
         {'$addToSet': {
             'voted_ans': {
                 'ansID': ansID,
                 'vote': vote
             }
         }})
Beispiel #7
0
 def setBookmark(self, quesID):
     bookmarked = (USERS_COLLECTION.find_one({'_id':
                                              self.username}))['bookmarks']
     if quesID in bookmarked:
         USERS_COLLECTION.update_one({'_id': self.username},
                                     {'$pull': {
                                         'bookmarks': quesID
                                     }})
         return False
     else:
         USERS_COLLECTION.find_one_and_update(
             {'_id': self.username}, {'$addToSet': {
                 'bookmarks': quesID
             }})
         return True
Beispiel #8
0
 def update_answers(self, ansID):
     USERS_COLLECTION.find_one_and_update({'_id': self.username}, {'$addToSet': {'ansPosted': ansID}})
Beispiel #9
0
 def update_questions(self, quesID):
     USERS_COLLECTION.find_one_and_update({'_id': self.username}, {'$addToSet': {'quesPosted': quesID}})
Beispiel #10
0
 def update_karma(self, karma):
     USERS_COLLECTION.find_one_and_update({'_id': self.username},
                                          {'$inc': {
                                              'karma': karma
                                          }})
Beispiel #11
0
 def update_comments(self, commentID):
     USERS_COLLECTION.find_one_and_update(
         {'_id': self.username},
         {'$addToSet': {
             'commentPosted': commentID
         }})