def do_DELETE(self):
        # Set a 204 response code
        self._set_headers(204)

        # parsing the URL
        (resource, id) = self.parse_url(self.path)

        if resource == "posts":
            delete_post(id)

        # Encode the new animal and send in response
        self.wfile.write("".encode())
    def do_DELETE(self):
        self._set_headers(204)
        (resource, id) = self.parse_url(self.path)

        if resource == "posts":
            delete_post(id)
        elif resource == "comments":
            delete_comment(id)
        elif resource == "tags":
            delete_tag(id)
        elif resource == "categories":
            delete_category(id)

        self.wfile.write("".encode())
Пример #3
0
    def do_DELETE(self):
        # Set a 204 response code
        self._set_headers(204)

        # Parse the URL
        (resource, id) = self.parse_url(self.path)

        # Delete a single animal from the list
        if resource == "posts":
            delete_post(id)

        if resource == "categories":
            delete_category(id)

        self.wfile.write("".encode())
    def do_DELETE(self):
        # Set a 204 response code
        self._set_headers(204)

        # Parse the URL
        (resource, id) = self.parse_url(self.path)

        # Delete a single post or tagPost from the list
        if resource == "posts":
            delete_post(id)
        if resource == "TagPosts":
            delete_tag_post(id)

        # Encode the new object and send in response
        self.wfile.write("".encode())
Пример #5
0
def handle_delete_post_process():
    """Handle process to delete a post."""

    post_id = request.form.get("post")
    delete = delete_post(post_id)

    return delete
Пример #6
0
def remove_post():
    post_id = request.args.get("post_id")
    if posts.delete_post(post_id):
        flash("Aloitus poistettu")
    else:
        flash("Aloituksen poisto epäonnistui")

    return redirect(request.referrer)
Пример #7
0
def index():
    if check_user():
        if 'submitpost' in request.form:
            posts.make_post(
                request.form['title'],
                session['user'],
                request.form['content'])
        if 'submitcomment' in request.form:
            posts.make_comment(
                request.form['postid'],
                session['user'],
                request.form['content'])
        if 'deletepost' in request.form:
            posts.delete_post(request.form['postid'])
    return render_template(
        "home.html",
        posts = posts.get_posts(request.args.get('query')),
        user = session['user'],
        query = request.args.get('query'))
    def do_DELETE(self):
        # Set a 204 response code
        self._set_headers(204)

        # Parse the URL
        (resource, id) = self.parse_url(self.path)

        if resource == "comments":
            delete_comment(id)

        if resource == "tags":
            delete_tag(id)

        if resource == "categories":
            delete_category(id)

        if resource == "posts":
            delete_post(id)

        # Encode the new animal and send in response
        self.wfile.write("".encode())
Пример #9
0
    def do_DELETE(self):
        self._set_headers(204)
        (resource, id) = self.parse_url(self.path)

        # if resource == "users":
        #     delete_user(id)

        if resource == "posts":
            delete_post(id)

        if resource == "comments":
            delete_comment(id)

        # if resource == "subscriptions":
        #     delete_subscription(id)
        # if resource == "reactions":
        #     delete_reaction(id)
        if resource == "tags":
            delete_tag(id)
        if resource == "categories":
            delete_category(id)

        self.wfile.write("".encode())
Пример #10
0
    def do_DELETE(self):
        (resource, id) = self.parse_url(self.path)
        success = False

        if resource == "posts":
            success = delete_post(id)
        elif resource == "post_tags":
            success = delete_postTag(id)
        elif resource == "comments":
            success = delete_comment(id)
        # elif resource == " ":
        #   success = delete_yourResource(id)
        # ...

        # successfully deleted the given resource with the given id
        if (success):
            self._set_headers(204)  # 204 - No Content

        # the delete query affected zero rows in the database
        # or the requested resource to delete doesn't exist / doesn't have a DELETE handler
        else:
            self._set_headers(404)  # 404 - File Not  Found

        self.wfile.write("".encode())
Пример #11
0
    def test_deleting_post(self):
        """Test process of deleting a post."""

        delete_post(1)
        post = Post.query.get(1)
        self.assertEqual(post, None)