def del_fsq_update(update_id, obj_id, access_token): if update_id is not None: url = "%s/%s/%s" % ('pageupdates', update_id, 'delete') api = FoursquareAPI(access_token) dict = {"update_id": update_id} data = api.request(url, post_args=dict) print data FSQPageUpdate.collection().update({"_id": coerce_bson_id(obj_id)}, {"$set": {"is_deleted": 1}})
def put_fsq_update(shout, venue_id, access_token, state): datetime_now = datetime.datetime.utcnow().isoformat('T') page_update = FSQPageUpdate() page_update.venue_id = venue_id page_update.shout = shout page_update.createdAt = datetime_now page_update.fields = {"shout": shout} if state == CampaignState.PUBLISHED: venue = FSQVenue.collection().find_one({"venue_id": venue_id}) url = "%s/%s" % ("pageupdates", "add") api = FoursquareAPI(access_token) dict = {"pageId": venue["fields"]["venue"]["venuePage"]["id"], "venueId": venue_id, "shout": shout} data = api.request(url, post_args=dict) page_update.fields = data["response"]["pageUpdate"] page_update.update_id = data["response"]["pageUpdate"]["id"] page_update._id = FSQPageUpdate.collection().insert(page_update.serialize()) return page_update
print id # delete twitter status if mapping_obj.twitter is not None: id = mapping_obj.twitter tweet = TWTweet.collection().find_one({"_id": coerce_bson_id(id)}) try: del_tweet(tweet["fields"]["id_str"] if tweet["fields"] is not None else None, id, brand_obj.twitter["access_token"]["key"], brand_obj.twitter["access_token"]["secret"]) except Exception, err: print traceback.format_exc() print id # delete foursquare page update if mapping_obj.foursquare is not None: id = mapping_obj.foursquare page_update = FSQPageUpdate.collection().find_one({"_id": coerce_bson_id(id)}) try: del_fsq_update(page_update["update_id"] if page_update["update_id"] is not None else None, id, brand_obj.foursquare["access_token"]) except Exception, err: print traceback.format_exc() print id # delete campaign if mapping_obj.campaign is not None: id = mapping_obj.campaign Campaign.collection().remove({"_id": coerce_bson_id(id)}) # delete blog if mapping_obj.blog is not None: id = mapping_obj.blog Campaign.collection().remove({"_id": coerce_bson_id(id)})