Ejemplo n.º 1
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.º 2
0
 def questions_threads_post(id):
     question = cdw.questions.with_id(id)
     form = PostForm(request.form, csrf_enabled=False)
     
     current_app.logger.debug(request.form.to_dict())
     
     if form.validate():
         post = form.to_post()
         follow_sms = form.get_follow_sms() 
         follow_email = form.get_follow_email()
         
         # The kiosk will send a phone number with the post if the user
         # wants to subscribe via SMS so we need to set the user's phone
         if form.origin.data == 'kiosk':
             follow_sms = True
         thread = cdw.create_thread(question, post, follow_sms, follow_email)
             
         return jsonify(thread)
     else:
         current_app.logger.debug("Error creating thread: %s" % form.errors)
         return jsonify({"error":form.errors}, 400)
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 questions_threads_post(id):
        question = cdw.questions.with_id(id)
        form = PostForm(request.form, csrf_enabled=False)

        current_app.logger.debug(request.form.to_dict())

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

            # The kiosk will send a phone number with the post if the user
            # wants to subscribe via SMS so we need to set the user's phone
            if form.origin.data == 'kiosk':
                follow_sms = True
            thread = cdw.create_thread(question, post, follow_sms,
                                       follow_email)

            return jsonify(thread)
        else:
            current_app.logger.debug("Error creating thread: %s" % form.errors)
            return jsonify({"error": form.errors}, 400)
Ejemplo n.º 5
0
 def posts_index_post():
     form = PostForm(request.form, csrf_enabled=False)
     if form.validate():
         return jsonify(cdw.posts.save(form.to_post()))
     else:
         return jsonify({"errors": form.errors}, 400)
Ejemplo n.º 6
0
 def posts_index_post():
     form = PostForm(request.form, csrf_enabled=False)
     if form.validate():
         return jsonify(cdw.posts.save(form.to_post()))
     else:
         return jsonify({"errors":form.errors}, 400)