From 2873707e5023e4fe92573688d46bc591acb3810d Mon Sep 17 00:00:00 2001 From: j Date: Tue, 26 Sep 2023 19:44:38 +0200 Subject: [PATCH] add links --- app/item/views.py | 5 +++-- app/static/js/comments.js | 2 +- requirements.txt | 1 + 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/app/item/views.py b/app/item/views.py index 87253b9..d31247d 100644 --- a/app/item/views.py +++ b/app/item/views.py @@ -1,6 +1,7 @@ +import json import xml.etree.ElementTree as ET -import json +import ox from django.utils import timezone from django.utils.timezone import datetime, timedelta @@ -158,7 +159,7 @@ def comment(request): comment.name = data['name'] comment.email = data['email'] comment.session_key = request.session.session_key - comment.text = data['text'] + comment.text = ox.add_links(data['text']) comment.save() link = request.build_absolute_uri(comment.item.get_absolute_url()) tasks.notify_moderators.delay(comment.id, link) diff --git a/app/static/js/comments.js b/app/static/js/comments.js index 513dad0..1d86ff9 100644 --- a/app/static/js/comments.js +++ b/app/static/js/comments.js @@ -161,7 +161,7 @@ document.querySelector('button#add-comment').addEventListener('click', event => ` comment.querySelector('.name').innerText = response.name comment.querySelector('.date').innerText = response.date - comment.querySelector('.text').innerText = response.text + comment.querySelector('.text').innerHTML = response.text document.querySelector('.comments .comments-content').append(comment) document.querySelector('.add-comment textarea').value = '' if (!user.username) { diff --git a/requirements.txt b/requirements.txt index cc954f7..e80dfb9 100644 --- a/requirements.txt +++ b/requirements.txt @@ -14,3 +14,4 @@ django-celery-beat redis django-brake python-telegram-bot +ox