예제 #1
0
def new_follower(sender, **kwargs):
    """
        Captura la señal de un nuevo seguidor
        Escribe en el timeline de los dos usuarios.
        Envia una notificacion al correo.
        Escribe en el timeline de notificaciones
    """
    from google.appengine.ext import db
    from models_acc import UserTimelineSystem, UserTimeline, UserSettings
    if not isinstance(kwargs['following'], db.Key):
        raise AttributeError
    if kwargs['following'].id() == 962005 or sender.username == 'georemindme':
        return 
    from google.appengine.ext.deferred import defer
    defer(UserTimeline.add_timelines_to_follower, kwargs['following'], sender.key())
    settings = UserSettings.objects.get_by_id(kwargs['following'].id())
    timeline = UserTimelineSystem(parent = sender, user = sender, instance = kwargs['following'], msg_id=100, visible=False)
    put = db.put_async([timeline])
    if settings.show_followings:
        timelinePublic = UserTimeline(parent=sender, user = sender, instance = kwargs['following'], msg_id=100)
        timelinePublic.put()
    from google.appengine.ext.deferred import defer
    defer(settings.notify_follower, sender.key())  # mandar email de notificacion
    put.get_result()
    if sender.key() != kwargs['following']:
        from geouser.models_utils import _Notification
        notification = _Notification(parent=kwargs['following'], owner=kwargs['following'], timeline=timeline)
        notification.put()
예제 #2
0
def new_following_list(sender, **kwargs):
    timeline = UserTimelineSystem(parent = kwargs['user'], user = kwargs['user'], instance = sender, msg_id=353, visible=False)
    put = db.put_async(timeline)
    sender.counters.set_followers(+1)
    put.get_result()
    if sender.user is not None:
        if kwargs['user'].key() != sender.user.key():
            from geouser.models_utils import _Notification
            notification = _Notification(parent=sender.user, owner=sender.user, timeline=timeline)
            notification.put()
예제 #3
0
def modified_list(sender, **kwargs):
    if isinstance(sender, ListRequested):
        timeline = UserTimelineSystem(parent=kwargs['querier'], user=kwargs['querier'], msg=351, _vis=sender._get_visibility())
        from georemindme.tasks import NotificationHandler
        NotificationHandler().list_followers_notify(sender)
        timeline.put()
        if sender.user is not None:
            if kwargs['querier'].key() != sender.user.key():
                from geouser.models_utils import _Notification
                notification = _Notification(parent=sender.user, owner=sender.user, timeline=timeline)
                notification.put()
예제 #4
0
def new_following_suggestion(sender, **kwargs):
    timeline = UserTimelineSystem(parent = kwargs['user'], user = kwargs['user'], instance = sender, msg_id=303, visible=False)
    p = timeline.put_async()
    sender.counters.set_followers(+1)
    p.get_result()
    from google.appengine.ext.deferred import defer
    defer(sender.user.settings.notify_suggestion_follower, sender.key(), kwargs['user'].key())
    if sender.user is not None:
        if kwargs['user'].key() != sender.user.key():
            from geouser.models_utils import _Notification
            notification = _Notification(parent=sender.user, owner=sender.user, timeline=timeline)
            notification.put()
예제 #5
0
def new_following_list(sender, **kwargs):
    timeline = UserTimelineSystem(parent=kwargs['user'],
                                  user=kwargs['user'],
                                  instance=sender,
                                  msg_id=353,
                                  visible=False)
    put = db.put_async(timeline)
    sender.counters.set_followers(+1)
    put.get_result()
    if sender.user is not None:
        if kwargs['user'].key() != sender.user.key():
            from geouser.models_utils import _Notification
            notification = _Notification(parent=sender.user,
                                         owner=sender.user,
                                         timeline=timeline)
            notification.put()
예제 #6
0
def modified_list(sender, **kwargs):
    if isinstance(sender, ListRequested):
        timeline = UserTimelineSystem(parent=kwargs['querier'],
                                      user=kwargs['querier'],
                                      msg=351,
                                      _vis=sender._get_visibility())
        from georemindme.tasks import NotificationHandler
        NotificationHandler().list_followers_notify(sender)
        timeline.put()
        if sender.user is not None:
            if kwargs['querier'].key() != sender.user.key():
                from geouser.models_utils import _Notification
                notification = _Notification(parent=sender.user,
                                             owner=sender.user,
                                             timeline=timeline)
                notification.put()
예제 #7
0
 def put(self):
     if self.sender.key() == self.to.key():
         return
     if not self.is_saved():
         super(Invitation, self).put()
         from geouser.models_acc import UserTimelineSystem
         timeline = UserTimelineSystem(parent=self.sender, user=self.sender, msg_id=110, instance=self)
         from geouser.models_utils import _Notification
         notification = _Notification(parent=self.to, owner=self.to, timeline=timeline)
         put = db.put_async([timeline, notification])            
         if self.to.settings.notification_invitation:
             from geomail import send_notification_invitation
             send_notification_invitation(self.to.email, self.sender, self)
         put.get_result()
     else:
         super(Invitation, self).put()
예제 #8
0
def new_following_suggestion(sender, **kwargs):
    timeline = UserTimelineSystem(parent=kwargs['user'],
                                  user=kwargs['user'],
                                  instance=sender,
                                  msg_id=303,
                                  visible=False)
    p = timeline.put_async()
    sender.counters.set_followers(+1)
    p.get_result()
    from google.appengine.ext.deferred import defer
    defer(sender.user.settings.notify_suggestion_follower, sender.key(),
          kwargs['user'].key())
    if sender.user is not None:
        if kwargs['user'].key() != sender.user.key():
            from geouser.models_utils import _Notification
            notification = _Notification(parent=sender.user,
                                         owner=sender.user,
                                         timeline=timeline)
            notification.put()
예제 #9
0
def new_comment(sender, **kwargs):
    from google.appengine.ext.deferred import defer
    from geoalert.models import Suggestion
    from geolist.models import ListSuggestion
    from geouser.models_acc import UserTimeline, UserTimelineSystem
    sender.instance.put(from_comment=True)
    timeline = UserTimelineSystem(parent=sender.user,
                                  user=sender.user,
                                  instance=sender,
                                  msg_id=120,
                                  visible=False)
    from google.appengine.ext import db
    p = db.put_async([timeline])
    if hasattr(sender.instance, '_vis'):
        if isinstance(sender.instance, Suggestion):
            timelinePublic = UserTimeline(
                parent=sender.user,
                user=sender.user,
                instance=sender,
                msg_id=120,
                _vis=sender.instance._get_visibility())
            timelinePublic.put()
        if isinstance(sender.instance, ListSuggestion):
            timelinePublic = UserTimeline(
                parent=sender.user,
                user=sender.user,
                instance=sender,
                msg_id=121,
                _vis=sender.instance._get_visibility())
            timelinePublic.put()
    if isinstance(sender.instance, Suggestion) or isinstance(
            sender.instance, ListSuggestion):
        defer(sender.user.settings.notify_suggestion_comment, sender.key())
        sender.instance.counters.set_comments()
    p.get_result()
    if sender.instance.user is not None:
        if sender.user.key() != sender.instance.user.key():
            from geouser.models_utils import _Notification
            notification = _Notification(parent=sender.instance.user.key(),
                                         owner=sender.instance.user.key(),
                                         timeline=timeline)
            notification.put()
예제 #10
0
def new_vote(sender, **kwargs):
    from geoalert.models import Suggestion
    from geovote.models import Comment
    from geolist.models import ListSuggestion
    from geouser.models_acc import UserTimeline
    if isinstance(sender.instance, Suggestion):
        influenced = sender.instance.user.counters_async()
        supported = sender.user.counters_async()
        timelinePublic = UserTimeline(parent=sender.user,
                                      user=sender.user,
                                      instance=sender,
                                      msg_id=305,
                                      _vis=sender.instance._get_visibility())
        timelinePublic.put()
        i = influenced.next()
        s = supported.next()
        i.set_influenced()
        s.set_supported()
    elif isinstance(sender.instance, Comment):
        timelinePublic = UserTimeline(parent=sender.user,
                                      user=sender.user,
                                      instance=sender,
                                      msg_id=125,
                                      _vis=sender.instance._get_visibility())
        timelinePublic.put()
    elif isinstance(sender.instance, ListSuggestion):
        timelinePublic = UserTimeline(user=sender.user,
                                      instance=sender,
                                      msg_id=355,
                                      _vis=sender.instance._get_visibility())
        timelinePublic.put()
    else:
        return
    if sender.instance.user is not None:
        if sender.user.key() != sender.instance.user.key():
            from geouser.models_utils import _Notification
            notification = _Notification(parent=sender.instance.user.key(),
                                         owner=sender.instance.user.key(),
                                         timeline=timelinePublic)
            notification.put()
예제 #11
0
def new_follower(sender, **kwargs):
    """
        Captura la señal de un nuevo seguidor
        Escribe en el timeline de los dos usuarios.
        Envia una notificacion al correo.
        Escribe en el timeline de notificaciones
    """
    from google.appengine.ext import db
    from models_acc import UserTimelineSystem, UserTimeline, UserSettings
    if not isinstance(kwargs['following'], db.Key):
        raise AttributeError
    if kwargs['following'].id() == 962005 or sender.username == 'georemindme':
        return
    from google.appengine.ext.deferred import defer
    defer(UserTimeline.add_timelines_to_follower, kwargs['following'],
          sender.key())
    settings = UserSettings.objects.get_by_id(kwargs['following'].id())
    timeline = UserTimelineSystem(parent=sender,
                                  user=sender,
                                  instance=kwargs['following'],
                                  msg_id=100,
                                  visible=False)
    put = db.put_async([timeline])
    if settings.show_followings:
        timelinePublic = UserTimeline(parent=sender,
                                      user=sender,
                                      instance=kwargs['following'],
                                      msg_id=100)
        timelinePublic.put()
    from google.appengine.ext.deferred import defer
    defer(settings.notify_follower,
          sender.key())  # mandar email de notificacion
    put.get_result()
    if sender.key() != kwargs['following']:
        from geouser.models_utils import _Notification
        notification = _Notification(parent=kwargs['following'],
                                     owner=kwargs['following'],
                                     timeline=timeline)
        notification.put()