Esempio n. 1
0
def post_moderation_abstract_handler(sender, instance, status, **kwargs):
    # here I call signal function coming form django-geoads
    ad_post_save_handler(sender, instance, **kwargs)
    #
    #tip: ContentType.objects.get_for_model(instance)
    #tip: here we could get instance.filterset
    if status == 1:
        # send on twitter
        token = oauth.Token(key=settings.TWITTER_ACCESS_TOKEN_KEY,
                            secret=settings.TWITTER_ACCESS_TOKEN_SECRET)
        consumer = oauth.Consumer(settings.TWITTER_CONSUMER_KEY,
                                  settings.TWITTER_CONSUMER_SECRET)
        client = oauth.Client(consumer, token)
        ad = HomeForSaleAd.objects.get(id=instance.moderated_object.changed_object.id)
        habitation_type = ad.get_habitation_type_display()
        price = ad.price
        surface = int(ad.surface)
        rooms = int(ad.nb_of_rooms)
        status = u'#achetersanscom %s - %s€ - %sm² - %s pièces' % (habitation_type,
                                                price, surface, rooms)
        pnt = GEOSGeometry('SRID=%s;%s' % (ad.location.srid, ad.location.wkt))
        latitude = pnt.y
        longitude = pnt.x
        params = 'status=%s&lat=%s&long=%s&display_coordinates=true' % (urlencode(status), latitude, longitude)
        #print params
        if not settings.DEBUG and settings.TWITTER_NOTIFICATION:
            resp, content = client.request(
                'http://api.twitter.com/1/statuses/update.xml?%s' % (params),
                "POST"
            )
Esempio n. 2
0
def post_moderation_abstract_handler(sender, instance, status, **kwargs):
    ad_post_save_handler(sender, instance)
Esempio n. 3
0
def post_moderation_abstract_handler(sender, instance, status, **kwargs):
    ad_post_save_handler(sender, instance)