Exemple #1
0
    def post(self, request):

        try:
            msg = request.POST['post']
            post_fb = request.POST['post_fb']
            post = Post(request.USER, msg.encode('utf-8'), 2, 1)
            post = post.save()

            if int(post_fb) > 0:
                from social.publish import Publish
                fb = Publish(request.USER)
                url = PostShort(post.pk)
                try:
                    fb.post(post.message, url.url_post())
                except Exception, er: pass

        except Exception, er:
            print er
            return HttpResponse('{"status":false}', mimetype='text/json')
Exemple #2
0
    def post(self, request):
        getdict = request.POST



        user_data = {'user': request.USER,
                     'amount': getdict.get('amount'),
                     'cigarette': getdict.get('cigarette'),
                     'method': "post"}

        history = History(user_data)
        last_history = history.save()

        HistoryCtrl = History({'user': request.USER,
                               'method': "get"})

        msg = HistoryCtrl.get_message_history_prev(last_history)
        post = Post(request.USER, msg, 2,2)
        post = post.save()

        if int(getdict.get('post_fb')) > 0:
            from social.publish import Publish
            fb = Publish(request.USER)
            url = PostShort(post.pk)
            try:
                fb.post(request.USER.primary_name()+post.message, url.url_post())
            except Exception, er: pass

        RES = {
            'status': True,
            'message': post.message,
            'id': post.id,
            'type': post.type,
            'username': post.user.username,
            'picture': post.user.picture_square()
        }

        return HttpResponse(simplejson.dumps(RES), mimetype='text/json')