Ejemplo n.º 1
0
def post_create():
    post_form = PostCrudForm(csrf_enabled=False)

    if post_form.validate():
        thread = cdw.threads.with_id(post_form.debate_id.data)
        cdw.post_to_thread(thread, post_form.to_post())
        flash('Reply created successfully', 'info')
    else:
        current_app.logger.debug(post_form.errors)
        flash('Error creating reply. Try again.', 'error')

    return redirect(request.referrer)
Ejemplo n.º 2
0
def post_create():
    post_form = PostCrudForm(csrf_enabled=False)
    
    if post_form.validate():
        thread = cdw.threads.with_id(post_form.debate_id.data)
        cdw.post_to_thread(thread, post_form.to_post())
        flash('Reply created successfully', 'info')
    else:
        current_app.logger.debug(post_form.errors)
        flash('Error creating reply. Try again.', 'error')
    
    return redirect(request.referrer)
Ejemplo n.º 3
0
    def threads_posts_post(thread_id):
        thread = cdw.threads.with_id(thread_id)
        form = PostForm(request.form, csrf_enabled=False)

        if form.validate():
            post = form.to_post()
            follow_sms = form.get_follow_sms()
            follow_email = form.get_follow_email()

            # Assume kiosk users want to follow by SMS, even if they haven't
            # provided their phone number since the SMS service is intelligent
            # enough to ignore users without phone numbers
            if form.origin.data == 'kiosk':
                follow_sms = True

            post = cdw.post_to_thread(thread, post, follow_sms, follow_email)
            return jsonify(post.as_dict(full_path=True))
        else:
            return jsonify({"errors": form.errors}, 400)
Ejemplo n.º 4
0
 def threads_posts_post(thread_id):
     thread = cdw.threads.with_id(thread_id)
     form = PostForm(request.form, csrf_enabled=False)
     
     if form.validate():
         post = form.to_post()
         follow_sms = form.get_follow_sms() 
         follow_email = form.get_follow_email()
         
         # Assume kiosk users want to follow by SMS, even if they haven't
         # provided their phone number since the SMS service is intelligent
         # enough to ignore users without phone numbers
         if form.origin.data == 'kiosk':
             follow_sms = True
             
         post = cdw.post_to_thread(thread, post, follow_sms, follow_email)    
         return jsonify(post)
     else:
         return jsonify({"errors": form.errors}, 400)
Ejemplo n.º 5
0
            self.send_sms_message(msg, [user.phoneNumber])
            abort(500, description='User sent bad words')

        current_app.logger.debug('post via sms')

        thread = user.threadSubscription
        lastPost = None

        try:
            lastPost = cdw.posts.with_fields_first(author=user, thread=thread)

        except EntityNotFoundException:

            user = cdw.users.with_fields(
                phoneNumber=user.phoneNumber,
                origin='kiosk').order_by('-lastPostDate').first()

            lastPost = cdw.posts.with_fields_first(author=user, thread=thread)

        except Exception, e:
            current_app.logger.error('Error posting via SMS: %s' % e)
            raise

        p = Post(yesNo=lastPost.yesNo,
                 author=user,
                 text=message,
                 thread=thread,
                 origin="cell")

        cdw.post_to_thread(thread, p)
Ejemplo n.º 6
0
        
        current_app.logger.debug('post via sms')
        
        thread = user.threadSubscription
        lastPost = None
        
        try:
            lastPost = cdw.posts.with_fields_first(
                author=user, thread=thread)
            
        except EntityNotFoundException:
            
            user = cdw.users.with_fields(
                    phoneNumber=user.phoneNumber, 
                    origin='kiosk').order_by('-lastPostDate').first()
            
            lastPost = cdw.posts.with_fields_first(
                    author=user, thread=thread)
            
        except Exception, e:
            current_app.logger.error('Error posting via SMS: %s' % e)
            raise
            
        p = Post(yesNo=lastPost.yesNo, 
                 author=user, 
                 text=message, 
                 thread=thread, 
                 origin="cell")
        
        cdw.post_to_thread(thread, p)