Beispiel #1
0
 def put(self):
     # update a single blogpost
     print('Blogpost API: update a single blogpost')
     requestData = request.get_data().decode('utf8')
     blogpostData = json.loads(requestData)        
     newBlogpost = Blogpost()
     newBlogpost.id = blogpostData['p_customer_id']
     newBlogpost.postDate = blogpostData['p_post_date']
     newBlogpost.title = blogpostData['p_title']
     newBlogpost.postContent = blogpostData['p_post_content']
     newBlogpost.keywords = blogpostData['p_keywords']
     newBlogpost.createDate = blogpostData['p_create_date']
     mod_blogpost(newBlogpost) 
     return jsonify({"data":"5"})
    def post(self):
        post = self.request.get("post")
        title = self.request.get("title")
        photo = str(self.request.get("photo"))

        user = {'user_id': "user_id"}

        if user:
            invalidFieldFlag = False
            # Check if diary entry or place is invalid
            if len(title.strip()) == 0:
                PageHandler.invalidTitle = True
                invalidFieldFlag = True
            if len(post.strip()) == 0:
                PageHandler.invalidPost = True
                invalidFieldFlag = True
            if len(photo.strip()) < 100:
                PageHandler.invalidPhoto = True
                invalidFieldFlag = True

            if not invalidFieldFlag:
                PageHandler.invalidTitle = PageHandler.invalidPost = PageHandler.invalidPhoto = False

                user_id = user['user_id']
                new_blogpost = Blogpost(parent=App.DEFAULT_KEY)
                new_blogpost.post = post
                new_blogpost.title = title
                new_blogpost.photo = photo
                new_blogpost.photo_key = uuid.uuid4().hex
                new_blogpost.user_id = user_id


                # Save in the data-store
                new_blogpost.put()

            self.redirect("/blog")
        else:
            self.redirect("/login")
Beispiel #3
0
    def post(self):
        post = self.request.get("post")
        title = self.request.get("title")
        photo = str(self.request.get("photo"))

        user = {'user_id': "user_id"}

        if user:
            invalidFieldFlag = False
            # Check if diary entry or place is invalid
            if len(title.strip()) == 0:
                PageHandler.invalidTitle = True
                invalidFieldFlag = True
            if len(post.strip()) == 0:
                PageHandler.invalidPost = True
                invalidFieldFlag = True
            if len(photo.strip()) < 100:
                PageHandler.invalidPhoto = True
                invalidFieldFlag = True

            if not invalidFieldFlag:
                PageHandler.invalidTitle = PageHandler.invalidPost = PageHandler.invalidPhoto = False

                user_id = user['user_id']
                new_blogpost = Blogpost(parent=App.DEFAULT_KEY)
                new_blogpost.post = post
                new_blogpost.title = title
                new_blogpost.photo = photo
                new_blogpost.photo_key = uuid.uuid4().hex
                new_blogpost.user_id = user_id

                # Save in the data-store
                new_blogpost.put()

            self.redirect("/blog")
        else:
            self.redirect("/login")
Beispiel #4
0
 def post(self):
     # create a new blogpost
     print('Blogpost API: create a new blogpost')
     # print(type(json.dumps(request.data)))
     print('1')
     requestData = request.get_data().decode('utf8')
     print('2')
     blogpostData = json.loads(requestData)
     print('3')
     newBlogpost = Blogpost()
     print('4')
     newBlogpost.postDate = blogpostData['p_post_date']
     print('5')
     newBlogpost.title = blogpostData['p_title']
     print('6')
     newBlogpost.postContent = blogpostData['p_post_content']
     print('7')
     newBlogpost.keywords = blogpostData['p_keywords']
     print('8')
     newBlogpost.createDate = blogpostData['p_create_date']
     print('9')
     add_blogpost(newBlogpost)
     # TODO: Finish this section, then do "def put()"
     return jsonify({"Saved": True})