Delete button doesn't work
spiropan opened this issue · 12 comments
Hello,
Thank you for this great application. I am having one issue. I have the latest version of the software Version 0.8.0. Clicking on the "Delete" button doesn't work for me. The href redirects to "#"on line 28 of the page.html template. After fixing it to redirect to url_for('blogging.delete', post_id=post.post_id) I am getting a "Method Not Allowed The method is not allowed for the requested URL."
Thank you,
@spiropan Thanks for reporting this issue. Does the earlier version work for you? There was one small change in 0.8.0. That might have broken this feature.
@spiropan
I ran the example\main.py
and the delete functionality still works as of 0.8.0. One thing to keep in mind is that the delete functionality needs the necessary authentication. When you delete without authentication (I tested and found), you get "Method not allowed". So what is missing is the authentication. Can you check if you have the authentication setup properly?
Two questions:
- Does
example\main.py
work for you? - Are you able to share a minimal example as a test case?
@spiropan Have you modified the template "page.html" file in your application by any chance? Based on what you say, can you check if the form
in the delete section is still submitting a POST
request:
<form action="{{ url_for('blogging.delete', post_id=post.post_id) }}" method="POST">
<button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
<input type="submit" value="Yes" class="btn btn-primary" id="confirmedDelete"/>
</form>
refer to the method="POST" above. In your debug, you can check when you hit delete, if it is still making a POST request. The delete is a POST request and the code seems right to me.
If you haven't modified anything, we can check to see why a GET request is needed.
@spiropan
I see what is going on now. Can you check if you have the Javascript lines 70-77 (in page.html
) in your custom page.html
? My suspicion is you don't.
Basically the javascript triggers the modal to show up. What you provide here is a more bootstrap way of doing it, which seems cleaner.
So if you can, please provide a PR with your modification for the <a .. >
tag and remove the
<script>
$(document).ready(function(){
$("#delete").click(function(){
$('#confirmModal').modal('show');
});
$("img").addClass("center-block").addClass("img-responsive");
});
</script>
at the bottom in page.html
.