Exemple #1
0
def user_followers_changed(sender, **kwargs):
    try:
        if kwargs['action'] == 'post_add':
            source_user = kwargs['instance']
            if source_user:
                for i in kwargs['pk_set']:
                    target_user = UserProfile.objects.get(pk=i)
                    if target_user:
                        ActivityFollow(user=source_user, to_user=target_user).save()

                        notification = Notification()
                        notification.from_user = source_user
                        notification.to_user = target_user
                        notification.notification_text = "You have a new follower on Deep South Sounds"

                        notification.notification_html = "<a href='%s'>%s</a> followed you on <a href='http://deepsouthsounds.com'>Deep South Sounds</a>" % (
                            wrap_full(source_user.get_profile_url()),
                            source_user.get_nice_name()
                        )

                        notification.notification_url = source_user.get_absolute_url()
                        notification.verb = "followed"
                        notification.target = target_user.get_nice_name()
                        notification.save()
    except Exception, ex:
        print "Error sending new follower: %s" % ex.message
Exemple #2
0
    def post_social(self):
        if settings.DEBUG:
            return

        try:
            verb = self.get_verb_past()
            object = self.get_object_singular()
            if verb == "favourited":
                action_type = "deepsouthsounds:favourite"
            if verb == "liked":
                action_type = "like"
            if verb == "followed":
                action_type = "og.follows"
            else:
                action_type = "deepsouthsounds:play"

            if False:
                social_account = SocialToken.objects.filter(
                    account__user=self.user.user,
                    account__provider='facebook')[0]
                facebook = OpenFacebook(social_account.token)
                notification_html = {object: wrap_full(self.get_object_url())}
                result = facebook.set('me/%s' % action_type, notification_html)
                print(result)
        except Exception as ex:
            print(ex)
            pass
Exemple #3
0
    def post_social(self):
        if settings.DEBUG:
            return

        try:
            verb = self.get_verb_past()
            object = self.get_object_singular()
            if verb == "favourited":
                action_type = "deepsouthsounds:favourite"
            if verb == "liked":
                action_type = "like"
            if verb == "followed":
                action_type = "og.follows"
            else:
                action_type = "deepsouthsounds:play"

            social_account = SocialToken.objects.filter(account__user=self.user.user, account__provider='facebook')[0]
            facebook = OpenFacebook(social_account.token)
            notification_html = {
                object: wrap_full(self.get_object_url())
            }
            result = facebook.set('me/%s' % action_type, notification_html)
            print result
        except Exception, ex:
            print ex.message
            pass
Exemple #4
0
    def create_notification(self):
        try:
            notification = Notification()
            notification.from_user = self.user
            notification.to_user = self.get_target_user()
            notification.notification_text = "%s %s %s" % (
                self.user.get_nice_name() if self.user is not None else "Anonymouse",
                self.get_verb_past(),
                self.get_object_name_for_notification())

            notification.notification_html = "<a href='%s'>%s</a> %s <a href='%s'>%s</a>" % (
                wrap_full(self.user.get_profile_url() if self.user is not None else ""),
                self.user.get_nice_name() if self.user is not None else "Anonymouse",
                self.get_verb_past(),
                wrap_full(self.get_object_url()),
                self.get_object_name_for_notification()
            )

            notification.notification_url = self.get_object_url()
            notification.verb = self.get_verb_past()
            notification.target = self.get_object_name()
            notification.save()
        except Exception, ex:
            print "Error creating activity notification: %s" % ex.message
Exemple #5
0
def user(request, args):
    try:
        user = UserProfile.objects.get(slug=args['user_id'])
    except UserProfile.DoesNotExist:
        raise Http404

    image = user.get_avatar_image()
    profile_url = user.get_profile_url()
    default = _getPayload(request)
    extras = {
        "title": user.get_nice_name(),
        "description": user.get_profile_description().replace('<br>', '\n'),
        "profile_url": wrap_full(profile_url),
        "image_url": image,
    }
    payload = dict(list(default.items()) + list(extras.items()))
    response = render_to_response('inc/facebook/user.html',
                                  payload,
                                  context_instance=RequestContext(request))
    return response
Exemple #6
0
def user(request, args):
    try:
        user = UserProfile.objects.get(slug=args['user_id'])
    except UserProfile.DoesNotExist:
        raise Http404

    image = user.get_avatar_image()
    profile_url = user.get_profile_url()
    default = _getPayload(request)
    extras = {
        "title": user.get_nice_name(),
        "description": user.get_profile_description().replace('<br>', '\n'),
        "profile_url": wrap_full(profile_url),
        "image_url": image,
    }
    payload = dict(default.items() + extras.items())
    response = render_to_response(
        'inc/facebook/user.html',
        payload,
        context_instance=RequestContext(request)
    )
    return response