From 6227f747c18f48e989d6f04cf3a260ff1c035c97 Mon Sep 17 00:00:00 2001 From: Deimos Date: Mon, 15 Jun 2020 17:27:22 -0600 Subject: [PATCH] Use intercooler for comment reply form Previously, the comment reply form was being created entirely client-side by cloning and modifying a {% endmacro %} - -{% macro comment_reply_template() %} - -{% endmacro %} diff --git a/tildes/tildes/templates/notifications_unread.jinja2 b/tildes/tildes/templates/notifications_unread.jinja2 index 0258c07..6cab6a8 100644 --- a/tildes/tildes/templates/notifications_unread.jinja2 +++ b/tildes/tildes/templates/notifications_unread.jinja2 @@ -3,7 +3,7 @@ {% extends 'base_user_menu.jinja2' %} -{% from 'macros/comments.jinja2' import comment_label_options_template, comment_reply_template, render_single_comment with context %} +{% from 'macros/comments.jinja2' import comment_label_options_template, render_single_comment with context %} {% from 'macros/links.jinja2' import link_to_group with context %} {% block title %}Unread notifications{% endblock %} @@ -80,5 +80,4 @@ {% block templates %} {{ comment_label_options_template(comment_label_options) }} - {{ comment_reply_template() }} {% endblock %} diff --git a/tildes/tildes/templates/topic.jinja2 b/tildes/tildes/templates/topic.jinja2 index fab73fb..ee8e36c 100644 --- a/tildes/tildes/templates/topic.jinja2 +++ b/tildes/tildes/templates/topic.jinja2 @@ -4,7 +4,7 @@ {% extends 'base.jinja2' %} {% from 'macros/buttons.jinja2' import post_action_toggle_button with context %} -{% from 'macros/comments.jinja2' import comment_label_options_template, comment_reply_template, render_comment_tree with context %} +{% from 'macros/comments.jinja2' import comment_label_options_template, render_comment_tree with context %} {% from 'macros/datetime.jinja2' import adaptive_date_responsive, time_ago %} {% from 'macros/forms.jinja2' import markdown_textarea %} {% from 'macros/groups.jinja2' import group_segmented_link %} @@ -21,7 +21,6 @@ {% block templates %} {% if request.user %} - {{ comment_reply_template() }} {{ comment_label_options_template(comment_label_options) }} {% endif %} {% endblock %} diff --git a/tildes/tildes/templates/user.jinja2 b/tildes/tildes/templates/user.jinja2 index 9faf384..6d19357 100644 --- a/tildes/tildes/templates/user.jinja2 +++ b/tildes/tildes/templates/user.jinja2 @@ -3,7 +3,7 @@ {% extends 'base_user_menu.jinja2' %} -{% from 'macros/comments.jinja2' import comment_label_options_template, comment_reply_template, render_single_comment with context %} +{% from 'macros/comments.jinja2' import comment_label_options_template, render_single_comment with context %} {% from 'macros/links.jinja2' import link_to_group with context %} {% from 'macros/topics.jinja2' import render_topic_for_listing with context %} @@ -11,7 +11,6 @@ {% block templates %} {% if request.user %} - {{ comment_reply_template() }} {{ comment_label_options_template(comment_label_options) }} {% endif %} {% endblock %} diff --git a/tildes/tildes/views/api/web/comment.py b/tildes/tildes/views/api/web/comment.py index 71fc941..7b4dead 100644 --- a/tildes/tildes/views/api/web/comment.py +++ b/tildes/tildes/views/api/web/comment.py @@ -130,6 +130,17 @@ def get_comment_contents(request: Request) -> dict: return {"comment": request.context} +@ic_view_config( + route_name="comment_reply", + request_method="GET", + renderer="comment_reply.jinja2", + permission="reply", +) +def get_comment_reply(request: Request) -> dict: + """Get the reply form for a comment with Intercooler.""" + return {"parent_comment": request.context} + + @ic_view_config( route_name="comment", request_method="GET",