def new_comment(sender, **kwargs): if hasattr(sender.instance, '_vis'): try: fb_client = FacebookClient(user=sender.user) except: return from os import environ params = { "name": sender.instance.name, "link": environ['HTTP_HOST'] + sender.instance.get_absolute_url(), "caption": "Sugerencia de " + sender.instance.user.username, "picture": environ['HTTP_HOST'] + "/user/" + sender.instance.user.username + "/picture/", } params = dict([k, v.encode('utf-8')] for k, v in params.items()) if sender.instance._is_public(): params["privacy"] = {'value': 'EVERYONE'} else: params["privacy"] = {'value': 'CUSTOM', 'friends': 'SELF'} post_id = fb_client.consumer.put_wall_post(sender.msg, params) from models import _FacebookPost fb_post = _FacebookPost(instance=str(sender.key()), post=post_id['id']) fb_post.put() else: return
def new_suggestion(sender, **kwargs): try: fb_client = FacebookClient(user=sender.user) except: return params = { "name": "Ver detalles de la sugerencia", "link": __web_settings.WEB_APP + "suggestion/" + sender.slug, "caption": "Detalles del sitio (%(sitio)s), comentarios, etc." % { 'sitio': sender.poi.name }, #"caption": "Foto de %(sitio)s" % {'sitio':sender.poi.name}, "picture": 'https://georemindme.appspot.com/user/georemindme/picture/', } if sender.description is not None: params["description"] = sender.description #Pasamos todos los valores a UTF-8 params = dict([k, v.encode('utf-8')] for k, v in params.items()) if sender._is_public(): params["privacy"] = {'value': 'EVERYONE'} else: params["privacy"] = {'value': 'CUSTOM', 'friends': 'SELF'} try: if 'msg' in kwargs: post_id = fb_client.consumer.put_wall_post(kwargs['msg'], params) else: post_id = fb_client.consumer.put_wall_post( "%(sugerencia)s" % {'sugerencia': sender.name.encode('utf-8')}, params) from models import _FacebookPost fb_post = _FacebookPost(instance=str(sender.key()), post=post_id['id']) fb_post.put() except: pass
def new_comment(sender, **kwargs): if hasattr(sender.instance, '_vis'): try: fb_client=FacebookClient(user=sender.user) except: return from os import environ params= { "name": sender.instance.name, "link": environ['HTTP_HOST'] + sender.instance.get_absolute_url(), "caption": "Sugerencia de "+sender.instance.user.username, "picture": environ['HTTP_HOST'] +"/user/"+sender.instance.user.username+"/picture/", } params = dict([k, v.encode('utf-8')] for k, v in params.items()) if sender.instance._is_public(): params["privacy"]= {'value':'EVERYONE'} else: params["privacy"]= {'value':'CUSTOM','friends':'SELF'} post_id = fb_client.consumer.put_wall_post(sender.msg, params) from models import _FacebookPost fb_post = _FacebookPost(instance=str(sender.key()), post=post_id['id']) fb_post.put() else: return
def new_list(sender, **kwargs): from geolist.models import ListSuggestion, ListRequested try: fb_client=FacebookClient(user=sender.user) except: return params= { "name": sender.name, "link": __web_settings.WEB_APP+sender.get_absolute_url(), "caption": _(u"Detalles de la lista, comentarios, etc."), #"caption": "Foto de %(sitio)s" % {'sitio':sender.poi.name}, "picture": 'https://georemindme.appspot.com/user/georemindme/picture/', } if sender.description is not None: params["description"]= "This is a longer description of the attachment" params = dict([k, v.encode('utf-8')] for k, v in params.items()) if sender._is_public(): params["privacy"]={'value':'EVERYONE'} else: params["privacy"]={'value':'CUSTOM','friends':'SELF'} if isinstance(sender, ListSuggestion): if 'msg' in kwargs: post_id = fb_client.consumer.put_wall_post(kwargs['msg'], params) else: post_id = fb_client.consumer.put_wall_post("He creado una lista de sugerencias ", params) elif isinstance(sender, ListRequested): if 'msg' in kwargs: post_id = fb_client.consumer.put_wall_post(kwargs['msg'], params) else: post_id = fb_client.consumer.put_wall_post("Necesito sugerencias, ¿me podéis ayudar?", params) else: return from models import _FacebookPost fb_post = _FacebookPost(instance=str(sender.key()), post=post_id['id']) fb_post.put()
def new_suggestion(sender, **kwargs): try: fb_client=FacebookClient(user=sender.user) except: return params= { "name": "Ver detalles de la sugerencia", "link": __web_settings.WEB_APP+"suggestion/"+sender.slug, "caption": "Detalles del sitio (%(sitio)s), comentarios, etc." % {'sitio':sender.poi.name}, #"caption": "Foto de %(sitio)s" % {'sitio':sender.poi.name}, "picture": 'https://georemindme.appspot.com/user/georemindme/picture/', } if sender.description is not None: params["description"]=sender.description #Pasamos todos los valores a UTF-8 params = dict([k, v.encode('utf-8')] for k, v in params.items()) if sender._is_public(): params["privacy"]={'value':'EVERYONE'} else: params["privacy"]={'value':'CUSTOM','friends':'SELF'} try: if 'msg' in kwargs: post_id = fb_client.consumer.put_wall_post(kwargs['msg'], params) else: post_id = fb_client.consumer.put_wall_post("%(sugerencia)s" % {'sugerencia':sender.name.encode('utf-8')}, params) from models import _FacebookPost fb_post = _FacebookPost(instance=str(sender.key()), post=post_id['id']) fb_post.put() except: pass
def new_vote(sender, **kwargs): from geovote.models import Comment from geoalert.models import Suggestion from os import environ if hasattr(sender.instance, '_vis'): try: fb_client=FacebookClient(user=sender.user) except: return if isinstance(sender.instance, Comment): params= { "link": environ['HTTP_HOST'] + sender.instance.instance.get_absolute_url(), "caption": sender.instance.user.username, #"picture": "http://georemindme.com/media/img/whatsup.png" "picture": environ['HTTP_HOST'] +"/user/"+sender.instance.instance.user.username+"/picture", } if isinstance(sender.instance.instance, Suggestion): params["name"]= sender.instance.instance.name message = "Me gusta el comentario: \"%(comentario)s\" de %(autor)s en la sugerencia:" % {'comentario': sender.instance.msg, 'autor':sender.instance.user.username } else: params["name"]="Ver lista de sugerencias: "+ sender.instance.instance.name message = "Me gusta el comentario: \"%(comentario)s\" de %(autor)s" % {'comentario': sender.instance.msg, 'autor': sender.instance.user.username } elif isinstance(sender.instance, Suggestion): message = "Me gusta la sugerencia de %(autor)s:" % { 'autor':sender.instance.user.username } params= { "name": sender.instance.name, "link": environ['HTTP_HOST'] + sender.instance.get_absolute_url(), "caption": sender.instance.user.username, #"picture": "http://georemindme.com/media/img/whatsup.png" "picture": environ['HTTP_HOST'] +"/user/"+sender.instance.user.username+"/picture", } if hasattr(sender.instance,"description"): params['description']=sender.instance.description # codificamos todo el diccionario de parametros, antes de añadir el parametro privacy params = dict([k, v.encode('utf-8')] for k, v in params.items()) if sender.instance._is_public(): params["privacy"]= {'value':'EVERYONE'} else: params["privacy"]= {'value':'CUSTOM','friends':'SELF'} #~ raise Exception(params["picture"]) post_id = fb_client.consumer.put_wall_post(message.encode('utf-8'), params) from models import _FacebookPost fb_post = _FacebookPost(instance=str(sender.key()), post=post_id['id']) fb_post.put() else: return
def new_list(sender, **kwargs): from geolist.models import ListSuggestion, ListRequested try: fb_client = FacebookClient(user=sender.user) except: return params = { "name": sender.name, "link": __web_settings.WEB_APP + sender.get_absolute_url(), "caption": _(u"Detalles de la lista, comentarios, etc."), #"caption": "Foto de %(sitio)s" % {'sitio':sender.poi.name}, "picture": 'https://georemindme.appspot.com/user/georemindme/picture/', } if sender.description is not None: params[ "description"] = "This is a longer description of the attachment" params = dict([k, v.encode('utf-8')] for k, v in params.items()) if sender._is_public(): params["privacy"] = {'value': 'EVERYONE'} else: params["privacy"] = {'value': 'CUSTOM', 'friends': 'SELF'} if isinstance(sender, ListSuggestion): if 'msg' in kwargs: post_id = fb_client.consumer.put_wall_post(kwargs['msg'], params) else: post_id = fb_client.consumer.put_wall_post( "He creado una lista de sugerencias ", params) elif isinstance(sender, ListRequested): if 'msg' in kwargs: post_id = fb_client.consumer.put_wall_post(kwargs['msg'], params) else: post_id = fb_client.consumer.put_wall_post( "Necesito sugerencias, ¿me podéis ayudar?", params) else: return from models import _FacebookPost fb_post = _FacebookPost(instance=str(sender.key()), post=post_id['id']) fb_post.put()
def new_vote(sender, **kwargs): from geovote.models import Comment from geoalert.models import Suggestion from os import environ if hasattr(sender.instance, '_vis'): try: fb_client = FacebookClient(user=sender.user) except: return if isinstance(sender.instance, Comment): params = { "link": environ['HTTP_HOST'] + sender.instance.instance.get_absolute_url(), "caption": sender.instance.user.username, #"picture": "http://georemindme.com/media/img/whatsup.png" "picture": environ['HTTP_HOST'] + "/user/" + sender.instance.instance.user.username + "/picture", } if isinstance(sender.instance.instance, Suggestion): params["name"] = sender.instance.instance.name message = "Me gusta el comentario: \"%(comentario)s\" de %(autor)s en la sugerencia:" % { 'comentario': sender.instance.msg, 'autor': sender.instance.user.username } else: params[ "name"] = "Ver lista de sugerencias: " + sender.instance.instance.name message = "Me gusta el comentario: \"%(comentario)s\" de %(autor)s" % { 'comentario': sender.instance.msg, 'autor': sender.instance.user.username } elif isinstance(sender.instance, Suggestion): message = "Me gusta la sugerencia de %(autor)s:" % { 'autor': sender.instance.user.username } params = { "name": sender.instance.name, "link": environ['HTTP_HOST'] + sender.instance.get_absolute_url(), "caption": sender.instance.user.username, #"picture": "http://georemindme.com/media/img/whatsup.png" "picture": environ['HTTP_HOST'] + "/user/" + sender.instance.user.username + "/picture", } if hasattr(sender.instance, "description"): params['description'] = sender.instance.description # codificamos todo el diccionario de parametros, antes de añadir el parametro privacy params = dict([k, v.encode('utf-8')] for k, v in params.items()) if sender.instance._is_public(): params["privacy"] = {'value': 'EVERYONE'} else: params["privacy"] = {'value': 'CUSTOM', 'friends': 'SELF'} #~ raise Exception(params["picture"]) post_id = fb_client.consumer.put_wall_post(message.encode('utf-8'), params) from models import _FacebookPost fb_post = _FacebookPost(instance=str(sender.key()), post=post_id['id']) fb_post.put() else: return