-
Notifications
You must be signed in to change notification settings - Fork 88
add request to comment context #95
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Allows use with dynamically added forms
Codecov Report
@@ Coverage Diff @@
## master #95 +/- ##
=========================================
+ Coverage 85.03% 85.1% +0.07%
=========================================
Files 16 16
Lines 608 611 +3
=========================================
+ Hits 517 520 +3
Misses 91 91
Continue to review full report at Codecov.
|
@@ -145,7 +145,8 @@ def get_template_name(self, *tag_args, **tag_kwargs): | |||
return get_comment_template_name(comment=tag_args[0]) | |||
|
|||
def get_context_data(self, parent_context, *tag_args, **tag_kwargs): | |||
return get_comment_context_data(comment=tag_args[0]) | |||
_, request, _ = parent_context |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can't possibly work on Python 2.
How about request = parent_context.get('request')
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi!
Thanks for these changes. Although a lot more is included, they are useful changes. However, could you please look into these review comments?
@@ -23,7 +23,7 @@ class AjaxCommentTags(BaseInclusionNode): | |||
Using the ``@register.inclusion_tag`` is not sufficient, | |||
because some keywords require custom parsing. | |||
""" | |||
template_name = "fluent_comments/templatetags/ajax_comment_tags.html" | |||
template_name = "comments/ajax_comment_tags.html" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is the template changed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to be able to override the template if needed
$('body').on('mousedown', 'form.js-comments-form :input', setActiveInput); | ||
$('body').on('submit', 'form.js-comments-form', onCommentFormSubmit); | ||
$('body').on('click', '.comment-reply-link', showThreadedReplyForm); | ||
$('body').on('click', '.comment-cancel-reply-link', cancelThreadedReplyForm); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you make sure the $body
is fetched only once?
@@ -26,14 +26,15 @@ def get_comment_template_name(comment): | |||
] | |||
|
|||
|
|||
def get_comment_context_data(comment, action=None): | |||
def get_comment_context_data(comment, action=None, request=None): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note that get_comment_context_data
is called in 3 places, and each one should include the request.
Thanks @vdboor, i'll add the changes tonight. |
Fix problems pointed in the PR# 95 comments
I'm sorry, I noticed that the JavaScript changes are too invasive. The There have been several unfinished attempts to convert the script to a jQuery plugin format, which would make such re-initialization much easier too. That might be a good starting point implementing this change. Instead, I've fixed the request value elsewhere in 82856c6 |
In my case I needed the request context to check if the user was authenticated to show or not the "reply" link.