def like_deal(request,deal_id): if request.user.is_authenticated(): user = User.instance(request.user) try: deal = Deal.objects.get(id=deal_id) except Deal.DoesNotExist, dne: return Response({"success":False,"message":"Deal does not exist"}) try: ud = UserDeal.objects.get(deal=deal,user=user) return Response.json({"success":False,"message":"Already in my deals","at":str(ud.added)}) except UserDeal.DoesNotExist,ex: ud = UserDeal(deal=deal,user=user) ud.save() return Response.json({"success":True,"message":"success added to my deals", "id":ud.id})
def facebook_feed(request): f_acc = feed_account(request,"facebook") if f_acc is dict: return Response.json(f_acc) fb = Facebook(settings.CRED['FACEBOOK_APP_ID'] ,settings.CRED['FACEBOOK_APP_SECRET'],settings.CRED['FACEBOOK_RETURN_URL']) params = {"feed" : fb.news_feed(f_acc.oauth_token)} return Response.render_html("social/facebook_feed.html",params)
def twitter_feed(request): f_acc = feed_account(request,"twitter") if f_acc is dict: return Response.json(f_acc) twt = Twitter(settings.CRED['TWITTER_CONSUMER_KEY'] ,settings.CRED['TWITTER_CONSUMER_SECRET'],settings.CRED['TWITTER_RETURN_URL']) #return Response.json(twt.home_timeline(f_acc)) params = {"feed":twt.home_timeline(f_acc)} return Response.render_html("social/twitter_feed.html",params)
def reject_deal(request , deal_id): deal = Deal.objects.get(id=deal_id) deal.delete() return Response.json({"success" : True , "message" : "Deal Has Been DELETED"})
def approve_deal(request, deal_id): deal = Deal.objects.get(id=deal_id) deal.approved = True deal.save() return Response.json({"success" : True , "message" : "Deal Has Been Approved"})