Skip to content
Snippets Groups Projects
Commit 46889708 authored by Roang's avatar Roang
Browse files

Add render of original message to reply form

parent 21cfcd5d
No related branches found
No related tags found
No related merge requests found
{% import "plainui/components/form_elements.html.j2" as form_elements %} {% import "plainui/components/form_elements.html.j2" as form_elements %}
{% import "plainui/components/nav.html.j2" as navMacro with context %} {% import "plainui/components/nav.html.j2" as navMacro with context %}
{% from "plainui/components/markdown.html.j2" import markdown %}
{% extends "plainui/base.html.j2" %} {% extends "plainui/base.html.j2" %}
...@@ -42,6 +43,14 @@ ...@@ -42,6 +43,14 @@
</div> </div>
</div> </div>
</form> </form>
{% if in_reply_to %}
<hr class="hub-spacer">
<div class="p-0 m-0">
<div class="hub-card">
<h2 class="hub-head-main">{{ in_reply_to.subject }}</h2>
<div class="card-body">{{ markdown(in_reply_to_body, border=False) }}</div>
</div>
</div>
{% endif %}
<hr class="hub-spacer"> <hr class="hub-spacer">
{% endblock content %} {% endblock content %}
...@@ -5,6 +5,8 @@ __all__ = ( ...@@ -5,6 +5,8 @@ __all__ = (
'PersonalMessageShowView', 'PersonalMessageShowView',
) )
import contextlib
from django_ratelimit.decorators import ratelimit from django_ratelimit.decorators import ratelimit
from django.contrib import messages from django.contrib import messages
...@@ -67,10 +69,17 @@ class PersonalMessageSendView(ConferenceRequiredMixin, FormView): ...@@ -67,10 +69,17 @@ class PersonalMessageSendView(ConferenceRequiredMixin, FormView):
form_class = NewDirectMessageForm form_class = NewDirectMessageForm
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
in_reply_to_uuid = self.request.POST.get('in_reply_to', self.request.GET.get('in_reply_to', ''))
in_reply_to = None
if in_reply_to_uuid:
with contextlib.suppress(DirectMessage.DoesNotExist):
in_reply_to = DirectMessage.objects.filter(recipient=self.request.user, deleted_by_recipient=False).get(id=in_reply_to_uuid)
return { return {
**super().get_context_data(**kwargs), **super().get_context_data(**kwargs),
'conf': self.conf, 'conf': self.conf,
'disable_share': True, 'disable_share': True,
'in_reply_to': in_reply_to,
'in_reply_to_body': render_markdown(self.conf, in_reply_to.body) if in_reply_to else '',
} }
def get_initial(self): def get_initial(self):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment