Closed ghost closed 5 years ago
@ghost would you please submit a PR with these suggested changes? This would be the best step to use:
http://pyramid-blogr.readthedocs.org/en/latest/blog_create_and_update_view.html
I've recently overhauled the docs so that it is easier to find the files that need to be updated, and I was recently writing up a list of missing features, and noticed this issue report.
Thank you!
This issue needs some modifications to the code. The file names have been modified, entry_id
needs to be renamed to blog_id
and cast to an int
, we've renamed a class from Entry
to BlogRecordService
, and we're now using Jinja2 instead of Mako. Otherwise, it works. I think I'll keep this issue open as a way to rope in a new contributor at an upcoming Santa Cruz Python Meetup.
Updated code to delete post...
Add to 'views/blog.py':
@view_config(
route_name="blog_action",
match_param="action=delete",
renderer="pyramid_blogr:templates/edit_blog.jinja2",
permission="delete",
)
def blog_delete(request):
blog_id = int(request.params.get("id", -1))
entry = BlogRecordService.by_id(blog_id, request)
if not entry:
return HTTPNotFound()
request.dbsession.delete(entry)
return HTTPFound(location=request.route_url("home"))
In 'templates/view_blog.jinja2', after the "Edit entry" link:
:: <a href="{{ request.route_url('blog_action', action='delete', _query={'id':entry.id}) }}">Delete entry</a>
In 'security.py', append to the "__acl__"
list:
(Allow, Authenticated, "delete"),
@kenlittleton would you please create a PR with your suggested changes?
Hello everyone,
I think maybe we should let the reader implement the delete
action on their own as home exercise?
Also if I'm supposed to merge PR #67 this would also require changing documentation and code in all steps of the tutorial. Adding functionality to blog itself is not a problem, this application is not being meant to be an actual blog platform, but to teach basics of project building with pyramid.
@stevepiercy @kenlittleton I don't want to discourage anyone working on this though, maybe we can leave this as an example how delete can be implemented. Maybe there are some other areas that we can expand the tutorial in the future.
Sorry, I missed this https://docs.pylonsproject.org/projects/pyramid-blogr/en/1.10.x/summary.html#new-features and I overlooked the impact to docs and source code.
To elaborate for @kenlittleton, the PR cannot be merged in its current state. Both the docs and source code from the "6. Adding and editing blog entries" step onward would need to be updated. @ergo if those changes were made, would it be acceptable to merge?
If we don't want to update the tutorial and all its subsequent steps, I think the "Open" status of this issue is misleading and encouraged the PR. Perhaps closing both this issue and the related PR would indicate there is an example solution?
Yes I'll accept the PR after all @kenlittleton did all the work and there is nothing wrong with it. It just misses all the docs and source changes. So I leave this up to Ken to continue working on this and update all the steps forward.
I apologize but I'm not comfortable making changes to the published tutorial documentation. I would prefer @stevepiercy's suggestion of closing both the issue and the PR. The new_features link in the summary should suffice to allow one to find the code.
Ok, no problem, thanks for the effort. The blame is on me for leaving the issue unattended.
It would be nice to add remove posts functionality. To improve this example.
Thanks!
in views.py
at the end of view_blog.mako before
in security.py
with big thanks to DimmuR