Exemple #1
0
    def get(self, request, promise_slug, result):
        try:
            promise = Promise.objects.get(slug=promise_slug)
        except Promise.DoesNotExist:
            pass
        else:
            if request.user.profile == promise.creator:
                promise.status = result
                promise.save()

                # Posting to facebook
                post_data = social(promise, self.request.user.profile)
                msg = (u'I just achieved my promise on Promise.ly: '
                       u'{post_description}. Thanks for your support! {}').format(promise.get_absolute_url())
                self.request.user.profile.wall_post(
                    self.request, msg.format(**post_data))
        return HttpResponseRedirect(reverse('promise', args=[promise_slug]))
Exemple #2
0
    def save_promise(self, data):
        form = NewPromiseForm(data)
        if form.is_valid():
            new_promise = form.process(self.request)
            key = get_promise_key(self.request.user.profile.id)
            redis_connection.lpush(key, new_promise.id)

            # Posting to facebook
            if data.get('facebook_share') == 'on':
                post_data = social(new_promise, self.request.user.profile)
                msg = (u'I just created a promise on Promise.ly: '
                       u'{post_description}. Please support me! {link}')
                self.request.user.profile.wall_post(
                    self.request, msg.format(**post_data))

            # Logging stuff
            logger.log('promise', data={
                'creator_id': new_promise.creator.id,
                'promise_id': new_promise.id,
            })
            return new_promise