def untweet(tid, uid): "untweet a retweeted tweet" d = op.get('RETWEET',uid) print d for k in d.keys(): if d[k]==tid or k==tid: t1,t2 = k,d[k] op.remove_column('RETWEET', uid, [t1]) delete_tweet(t2,uid)
def mark_as_favorite(uid,tid): val = is_favourite(uid,tid) if val: d = op.get('FAVORITE_IS', tid) t = d[uid] op.remove_column('FAVORITE_OF', uid,[t]) op.remove_column('FAVORITE_IS', tid,[uid]) else: val = op.get('TWEETS',tid) timestamp = long(time.time() * 1e6) timestamp = str(timestamp) op.insert('FAVORITE_OF', uid, {timestamp:tid}) op.insert('FAVORITE_IS', tid, {uid:timestamp})
def delete_tweet(tweetid,uid) : "to delete a tweet" val = op.get('TWEETS',tweetid) op.remove_row('TWEETS', tweetid) key = str(val['timestamp']) + ":" + uid op.remove_column('USERLINE', uid, [key]) #delete from timeline and userline op.remove_column('TIMELINE', uid, [key]) print "during delete " + key for followerID in op.get('FOLLOWER', uid): print followerID if 'status' != followerID: op.remove_column('TIMELINE', followerID, [key]) #delete from followers timeline d = op.get('FAVORITE_IS', tweetid) #delete from favourites list op.remove_row('FAVORITE_IS', tweetid) for key in d: v = str(d[key]) op.remove_column('FAVORITE_OF',key,[v]) d = op.get_all('HASH_TAGS') for k,v in d: for key,val in v.items(): if 'status' != key: if str(tweetid) == str(val): op.remove_column('HASH_TAGS',k,[key])
def unfollow(): "inside unfollow" follower = session["other_user"] following = session["username"] followerId = op.get("USERNAME", follower) followingId = op.get("USERNAME", following) d = op.get("FOLLOWING", followingId["uid"]) uid1 = followerId["uid"] uid2 = followingId["uid"] op.remove_column("FOLLOWING", followingId["uid"], [uid1]) t = op.get("FOLLOWER", followerId["uid"]) op.remove_column("FOLLOWER", followerId["uid"], [uid2]) d = op.get("TIMELINE", uid2) for key, value in d.iteritems(): val = op.get("TWEETS", value) if "status" not in val: if val["user"] == str(uid1): t = str(val["timestamp"]) + ":" + uid1 op.remove_column("TIMELINE", uid2, [t]) return redirect(url_for("get_userline"))