From 38a24af07085119fb4b7b93dd0803138265af392 Mon Sep 17 00:00:00 2001 From: Mykhailo Poienko <22IMC10258@fh-krems.ac.at> Date: Thu, 2 Jan 2025 11:10:55 +0100 Subject: [PATCH] Ruff check and isort, cleanup templates and added version to the docs. --- demoapp/custom_user/admin.py | 2 - demoapp/custom_user/tests.py | 1 - demoapp/custom_user/views.py | 2 - demoapp/settings.py | 6 +- demoapp/static/uni/uni_logo.png | Bin 14112 -> 0 bytes demoapp/templates/email/contexed_uni.html | 110 ------------------ demoapp/templates/email/uni.html | 81 ------------- demoapp/tests/mailpit.py | 2 +- demoapp/tests/test_admin.py | 2 - demoapp/tests/test_backends.py | 3 +- demoapp/tests/test_commands.py | 6 +- demoapp/tests/test_connections.py | 2 +- demoapp/tests/test_dblock.py | 1 - demoapp/tests/test_emailmodel.py | 1 - demoapp/tests/test_integration.py | 6 +- demoapp/tests/test_mail.py | 12 +- demoapp/tests/test_tags.py | 8 +- demoapp/tests/test_templates.py | 6 +- docs/source/conf.py | 1 + docs/source/usage.rst | 2 - sendmail/admin/emailmerge.py | 2 +- sendmail/admin/emailmodel.py | 5 +- sendmail/django_compressor.py | 27 +++-- sendmail/mail.py | 6 +- sendmail/management/commands/sendmail.py | 4 +- .../commands/subcommands/cleanup_mail.py | 3 +- .../commands/subcommands/dblocks.py | 3 +- .../commands/subcommands/send_queued_mail.py | 3 +- sendmail/models/emailmerge.py | 2 +- sendmail/models/newsletter.py | 2 - sendmail/parser.py | 24 +--- sendmail/tasks.py | 2 +- sendmail/views.py | 4 +- 33 files changed, 57 insertions(+), 284 deletions(-) delete mode 100644 demoapp/static/uni/uni_logo.png delete mode 100644 demoapp/templates/email/contexed_uni.html delete mode 100644 demoapp/templates/email/uni.html diff --git a/demoapp/custom_user/admin.py b/demoapp/custom_user/admin.py index 8c38f3f3..846f6b40 100644 --- a/demoapp/custom_user/admin.py +++ b/demoapp/custom_user/admin.py @@ -1,3 +1 @@ -from django.contrib import admin - # Register your models here. diff --git a/demoapp/custom_user/tests.py b/demoapp/custom_user/tests.py index 7ce503c2..49290204 100644 --- a/demoapp/custom_user/tests.py +++ b/demoapp/custom_user/tests.py @@ -1,3 +1,2 @@ -from django.test import TestCase # Create your tests here. diff --git a/demoapp/custom_user/views.py b/demoapp/custom_user/views.py index 91ea44a2..60f00ef0 100644 --- a/demoapp/custom_user/views.py +++ b/demoapp/custom_user/views.py @@ -1,3 +1 @@ -from django.shortcuts import render - # Create your views here. diff --git a/demoapp/settings.py b/demoapp/settings.py index 94508441..d6d1fdcd 100644 --- a/demoapp/settings.py +++ b/demoapp/settings.py @@ -10,7 +10,6 @@ https://docs.djangoproject.com/en/3.0/ref/settings/ """ import os -from datetime import timedelta from pathlib import Path from django.utils.translation import gettext_lazy as _ @@ -81,7 +80,7 @@ } } } - MEDIA_URL = f"http://127.0.0.1:9000/media/" + MEDIA_URL = "http://127.0.0.1:9000/media/" else: MEDIA_URL = '/media/' MEDIA_ROOT = BASE_DIR / 'workdir' / 'media' @@ -218,10 +217,7 @@ 'EMAIL_TEMPLATES': [ ('email/demo.html', _("Demo")), ('email/default.html', _('Default')), - ('email/placeholders.html', _('Placeholders')), ('email/in.html', _('Incoming')), - ('email/uni.html', _('University')), - ('email/contexed_uni.html', _('Contexed')), ('email/test_updated_parser.html', 'Test updated parser'), ('email/tracker.html', _('Tracker')), ], diff --git a/demoapp/static/uni/uni_logo.png b/demoapp/static/uni/uni_logo.png deleted file mode 100644 index 546713a6d8da215172abe699d0298f3cb763275d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 14112 zcmaKTbyOYCvM#Q{9X7UccXxMp4=w>V&c@x{A-D&3LI}Z~;O;KL-R0$X?mhRuKi+w> zW~OC*^;K1OtzNUbYob(@Wl)d^ksu%-P~>DK)&G{ce;--|xWDf`@<;T)1%aECuA2tP z%FWZ%#S%iy0%T@MCg)&kZK-Z)YT@NPVkrm#0S&a()OFKUQsg%WIWU|4gJA|cIQ^A| zfDjY`JDHk)v2-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sx<^Hg##&I!2y?cS?|Yh81uF31IjduS-`~CP&}zOni7}={8Bki-M4cDp5&p9# zNWm0;wj>}TDIdNWDIcKik?c5B^}r<4d|50Ww93=vwiV)6extENktOp|J2b#e?zfpU z;j>MG|Cu2p43bP2dGOt;f_mlf527Q*>x_eIXJ64{t7}=;uAdLgSIbtfW?KWvpO?Rc zqYBIX7S3DWa~S~=CHcJg-f0Z}od;+S>uu*8m0ZYFNa`OVAE%Nhb(F^w1F`u7GK!je0PJZDYX&Mae)y- z=WCCmMqQ2@vVJ;xaTAXUd-+`!6^yrJ4N?U2JSM;P7FisaHWd;8(4C2Yvrq3F_W!1* zr1xF-#zJQp{{la44{qd!A9T(c2~il3sUzMB;vNwNRflnSIvwnFvfjZ=|FIT#3N~OD znp&Gi%V46f47ghs;9k2r%FYj-C+~cpI6Q%^yJG%fwSOuEcfBH#%$xgOHIL-4?MNY! z2Xu=fe{^GnG??d@*?n&UaW-)ZQ@=vY=OnG>%LCB1KJv0hvrzo|{M^8Taqvkk=XHMH zVS~|DH}09vKIQdo+fx9QwHTYUCpV@G=B4l%@6$*UXiyJ(B04IKsQ0>VL0=9u`=ukA zrUo_BM#%fyny2%&pute97GH$E)3AJ^SWexlPOm3xL!TcKGUcWFTm8= zt-U7vY(NkFc@SAJScZ|L<&YK_4M9O~s_)CTZD+Nnc8tDx5Ql6X03h*x3Ec4IA}oe0 zP2_U$e@|z?-4jZ{1#;`zPZmc|nQ<#7u$|P}1tq9rkN=hnmV&j7XiPEdeUPbeY~^1g z8dO>US4bY=lnmKf<5_o-gmgF^^9{n&a{pcZI5#Q5r$m5|)jGZR - - - - -
- - - - - - - -
- - - - - - - - - - -
1px transparent
zur -Online-Version
-Universität Innsbruck
- -
{{ topic }}
-
{{ subtopic }}
-
-
1px transparent
-
- - - - -
- - - - - -
- - - - - - -
- {% for new in news %} - {{ new.some.dur }} - {{ new.some.val }} - - - - - - - - - - -
Hello
-
Vorwort
-
{{ new.text }}
-Beitrag lesen
Schatten
- {% endfor %} -
-
-
- - - - -
-
- - - -
- - - - -
- - - - -
- - - - - - - -
1px transparent
Offenlegung -nach §25 MedG
-
-
-
-
-{% endblock %} \ No newline at end of file diff --git a/demoapp/templates/email/uni.html b/demoapp/templates/email/uni.html deleted file mode 100644 index b6504001..00000000 --- a/demoapp/templates/email/uni.html +++ /dev/null @@ -1,81 +0,0 @@ -{% extends 'sendmail/base.html' %} -{% load sendmail %} - -{% block container %} -
- - - - -
- - - - - - - -
- - - - - - - - - - -
1px transparent
zur -Online-Version
-Universität Innsbruck
- -
{{ topic }}
-
{{ subtopic }}
-
-
1px transparent
-
- - - - -
- - -{% placeholder 'content' %} -
-
- - - - -
-
- - - -
- - - - -
- - - - -
- - - - - - - -
1px transparent
Offenlegung -nach §25 MedG
-
-
-
-
-{% endblock %} \ No newline at end of file diff --git a/demoapp/tests/mailpit.py b/demoapp/tests/mailpit.py index 022a62fb..0145cfdb 100644 --- a/demoapp/tests/mailpit.py +++ b/demoapp/tests/mailpit.py @@ -17,7 +17,7 @@ def __init__(self): try: response = self.info() self.already_running = attempts == 0 - except requests.exceptions.ConnectionError as e: + except requests.exceptions.ConnectionError: print("\nStarting Mailpit server\n") self.process = subprocess.Popen([MAILPIT_BINARY]) sleep(0.2) diff --git a/demoapp/tests/test_admin.py b/demoapp/tests/test_admin.py index 4f67bddf..6c3533e0 100644 --- a/demoapp/tests/test_admin.py +++ b/demoapp/tests/test_admin.py @@ -1,7 +1,5 @@ from dataclasses import dataclass -import pytest - from sendmail.admin.admin_utils import convert_media_urls_to_tags, get_message_preview, render_placeholder_content diff --git a/demoapp/tests/test_backends.py b/demoapp/tests/test_backends.py index b9957641..a2a1c914 100644 --- a/demoapp/tests/test_backends.py +++ b/demoapp/tests/test_backends.py @@ -1,6 +1,5 @@ -import os + import pathlib -from datetime import timedelta from email.mime.image import MIMEImage import pytest diff --git a/demoapp/tests/test_commands.py b/demoapp/tests/test_commands.py index 5bc5bb3d..1285a128 100644 --- a/demoapp/tests/test_commands.py +++ b/demoapp/tests/test_commands.py @@ -7,12 +7,12 @@ from django.core.management import call_command from django.utils.timezone import now -from sendmail.config import settings from sendmail.models.attachment import Attachment from sendmail.models.emailaddress import EmailAddress from sendmail.models.emailmodel import STATUS, EmailModel from sendmail.utils import set_recipients + def call_sendmail(*args, **kwargs): return call_command('sendmail', *args, **kwargs) @@ -92,7 +92,7 @@ def test_send_queued_mail(): @pytest.mark.django_db def test_send_batch(): with mock.patch('django.db.connection.close', return_value=None): - queue = [EmailModel.objects.create(from_email='from@example.com', status=STATUS.queued, language='en') for _ in range(200)] + _ = [EmailModel.objects.create(from_email='from@example.com', status=STATUS.queued, language='en') for _ in range(200)] call_sendmail('batch', processes=1) assert EmailModel.objects.filter(status=STATUS.sent).count() == 100 @@ -122,7 +122,7 @@ def test_failed_deliveries_logging(): """ with mock.patch('django.db.connection.close', return_value=None): - recipient = EmailAddress.objects.create(email=f'to@example.com') + recipient = EmailAddress.objects.create(email='to@example.com') email = EmailModel.objects.create( from_email='from@example.com', status=STATUS.queued, backend_alias='error', language='en' ) diff --git a/demoapp/tests/test_connections.py b/demoapp/tests/test_connections.py index ef410b3e..7c901b2e 100644 --- a/demoapp/tests/test_connections.py +++ b/demoapp/tests/test_connections.py @@ -10,4 +10,4 @@ def test_connections(): assert isinstance(connections['slow_backend'], SlowTestBackend) with pytest.raises(KeyError): - conn = connections['not_valid'] + _ = connections['not_valid'] diff --git a/demoapp/tests/test_dblock.py b/demoapp/tests/test_dblock.py index 2c162566..5a89f3e2 100644 --- a/demoapp/tests/test_dblock.py +++ b/demoapp/tests/test_dblock.py @@ -1,6 +1,5 @@ import time from datetime import timedelta -from multiprocessing import Process import pytest diff --git a/demoapp/tests/test_emailmodel.py b/demoapp/tests/test_emailmodel.py index a7481aa7..d85d430d 100644 --- a/demoapp/tests/test_emailmodel.py +++ b/demoapp/tests/test_emailmodel.py @@ -8,7 +8,6 @@ from sendmail.settings import get_template_engine from sendmail.utils import set_recipients -#from django.conf import settings @pytest.fixture diff --git a/demoapp/tests/test_integration.py b/demoapp/tests/test_integration.py index 18836fdd..27ecaf90 100644 --- a/demoapp/tests/test_integration.py +++ b/demoapp/tests/test_integration.py @@ -1,14 +1,12 @@ import tempfile from multiprocessing import Pool -from typing import List import pytest -import requests -from demoapp.tests.conftest import email_testing + from sendmail.mail import _send_bulk, send, send_many from sendmail.models.emailaddress import EmailAddress -from sendmail.models.emailmerge import EmailMergeModel, PlaceholderContent +from sendmail.models.emailmerge import PlaceholderContent from sendmail.utils import get_recipients_objects, split_emails diff --git a/demoapp/tests/test_mail.py b/demoapp/tests/test_mail.py index 4e3896c1..9dcd9d6a 100644 --- a/demoapp/tests/test_mail.py +++ b/demoapp/tests/test_mail.py @@ -1,24 +1,20 @@ import logging import tempfile from datetime import timedelta -from unittest.mock import patch -from zoneinfo import ZoneInfo import pytest from django.core.exceptions import ValidationError from django.db import connection -from django.db.utils import InterfaceError from django.test.utils import CaptureQueriesContext from django.utils import timezone +from django.core.files.base import ContentFile from sendmail.mail import _send_bulk, create_email, get_queued, send, send_many, split_into_batches from sendmail.models.attachment import Attachment from sendmail.models.emailaddress import EmailAddress, Recipient -from sendmail.models.emailmerge import EmailMergeModel, PlaceholderContent +from sendmail.models.emailmerge import EmailMergeModel from sendmail.models.emailmodel import PRIORITY, STATUS, EmailModel -from sendmail.settings import get_available_backends -#from django.conf import settings @pytest.fixture @@ -478,7 +474,6 @@ def test_get_queued(): assert list(get_queued()) == [queued_email, past_email] -from django.core import mail @pytest.mark.django_db @@ -572,7 +567,6 @@ def test_extra_recipients(template): assert extra[1].address.email == 'bcc2@email.com' -from django.core.files.base import ContentFile @pytest.fixture @@ -598,7 +592,7 @@ def template_with_extra_attachments(settings, template): def test_extra_attachments(template_with_extra_attachments): # Retrieve the template with the extra attachments already set up template = template_with_extra_attachments - en_translation = template.translated_contents.get(language='en') + template.translated_contents.get(language='en') # No need to create the attachment again since the fixture already does that recipients = ['mrec1@gmail.com', 'mrec2@gmail.com'] diff --git a/demoapp/tests/test_tags.py b/demoapp/tests/test_tags.py index f22bd486..080b8e65 100644 --- a/demoapp/tests/test_tags.py +++ b/demoapp/tests/test_tags.py @@ -6,7 +6,7 @@ from django.template import Context from sendmail.template.tags.media_inline import inline_media_image -from sendmail.templatetags.sendmail import inline_image, placeholder +from sendmail.templatetags.sendmail import inline_image @pytest.mark.django_db @@ -83,9 +83,6 @@ def test_media_urls(settings): assert template._attached_images[0].get_payload(decode=True) == open(abs_path, 'rb').read() -# def test_placeholders(): -# assert placeholder('', 'test') == '{{test}}' - def test_static(settings): #settings.STATICFILES_DIRS = [str(settings.BASE_DIR / 'demoapp' / 'tests' / 'assets')] @@ -144,9 +141,10 @@ def test_track_link(settings): assert tracker_link(target_img='invalid.png', context={'email_id': 5, 'target_uri': 'https://google.com'}) == '' def test_click_link(): - from sendmail.templatetags.sendmail import click_link from urllib.parse import quote + from sendmail.templatetags.sendmail import click_link + target_uri = 'https://google.com' quoted = quote(target_uri) diff --git a/demoapp/tests/test_templates.py b/demoapp/tests/test_templates.py index de87ce2e..af56fe6f 100644 --- a/demoapp/tests/test_templates.py +++ b/demoapp/tests/test_templates.py @@ -32,11 +32,7 @@ def test_creation(test_template): assert en_content.subject == 'test_subject' assert en_content.content == 'test_content' - de_content = main.translated_contents.create(language='de') - - # assert de_content.subject == 'Subject, language: de' - # - # assert de_content.content == 'Content, language: de' + main.translated_contents.create(language='de') placeholders_base = PlaceholderContent.objects.values_list('used_template_file', flat=True) diff --git a/docs/source/conf.py b/docs/source/conf.py index aeac8859..0223425d 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -15,6 +15,7 @@ project = 'sendmail' copyright = '2024, Mykhailo Poienko' author = 'Mykhailo Poienko' +version = release = '.'.join(map(str,VERSION)) # -- General configuration --------------------------------------------------- # https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration diff --git a/docs/source/usage.rst b/docs/source/usage.rst index a6fb78fc..130a00b1 100644 --- a/docs/source/usage.rst +++ b/docs/source/usage.rst @@ -411,8 +411,6 @@ in.html All placeholders in the previous example will be parsed successfully and provided for users. -.. warning:: - Placeholders are not recognized in child templates when using the Django {% extends %} tag. Inlines ^^^^^^^^^^^^^^^ diff --git a/sendmail/admin/emailmerge.py b/sendmail/admin/emailmerge.py index db0fe8f2..2e608299 100644 --- a/sendmail/admin/emailmerge.py +++ b/sendmail/admin/emailmerge.py @@ -3,8 +3,8 @@ from django.contrib import admin, messages from django.db import models from django.db.models import Case, IntegerField, Value, When -from django.forms import BaseInlineFormSet, TextInput from django.db.models.fields.json import JSONField +from django.forms import BaseInlineFormSet, TextInput from django.shortcuts import redirect from django.urls import reverse from django.utils.text import Truncator diff --git a/sendmail/admin/emailmodel.py b/sendmail/admin/emailmodel.py index 19afc949..eb7dc6c4 100644 --- a/sendmail/admin/emailmodel.py +++ b/sendmail/admin/emailmodel.py @@ -109,7 +109,8 @@ def get_fieldsets(self, request, obj=None): has_plaintext_content = True elif content_type == 'text/html': has_html_content = True - except Exception as e: + except: #noqa:E722 + # If any exception happens, put its description in content field has_plaintext_content = True if has_html_content: @@ -125,7 +126,7 @@ def render_subject(self, instance): try: message = instance.email_message() return message.subject - except Exception: + except: #noqa:E722 return "Rendering exception" render_subject.short_description = _('Subject') diff --git a/sendmail/django_compressor.py b/sendmail/django_compressor.py index 7cde40a1..c168f403 100644 --- a/sendmail/django_compressor.py +++ b/sendmail/django_compressor.py @@ -1,14 +1,9 @@ from copy import copy -from django.template.base import VariableNode, TextNode, NodeList +from django.template import loader +from django.template.base import NodeList, TextNode, VariableNode from django.template.defaulttags import IfNode -from django.template.loader_tags import ( - BLOCK_CONTEXT_KEY, - ExtendsNode, - BlockNode, - BlockContext, -) - +from django.template.loader_tags import BLOCK_CONTEXT_KEY, BlockContext, BlockNode, ExtendsNode def handle_extendsnode(extendsnode, context): @@ -91,3 +86,19 @@ def expand_blocknode(node, block_stack, block_context): block_context.push(node.name, popped_block) return expanded_nodelist +def handle_includenode(includenode, context): + """ + Process an IncludeNode to include the content of the referenced template. + + Args: + includenode (IncludeNode): The IncludeNode to process. + context (Context): The context in which to render the included template. + + Returns: + NodeList: The nodelist of the included template. + """ + included_template = includenode.template.resolve(context) + if isinstance(included_template, str): + included_template = loader.get_template(included_template) + return included_template.template.nodelist + diff --git a/sendmail/mail.py b/sendmail/mail.py index 24ba9ddc..baa9725a 100644 --- a/sendmail/mail.py +++ b/sendmail/mail.py @@ -15,9 +15,9 @@ from sendmail.models.emailmerge import EmailMergeModel from sendmail.models.emailmodel import PRIORITY, STATUS, EmailModel from sendmail.models.log import Log -from sendmail.settings import (get_available_backends, get_batch_size, get_default_language, get_email_address_model, - get_log_level, get_max_retries, get_message_id_enabled, get_message_id_fqdn, - get_retry_timedelta, get_sending_order, get_break_after_batch) +from sendmail.settings import (get_available_backends, get_batch_size, get_break_after_batch, get_default_language, + get_email_address_model, get_log_level, get_max_retries, get_message_id_enabled, + get_message_id_fqdn, get_retry_timedelta, get_sending_order) from sendmail.signals import email_queued from sendmail.utils import (create_attachments, get_emailmerge, get_language_from_code, get_or_create_recipient, get_recipients_objects, parse_emails, parse_priority, set_recipients, diff --git a/sendmail/management/commands/sendmail.py b/sendmail/management/commands/sendmail.py index b24e76d2..a008decc 100644 --- a/sendmail/management/commands/sendmail.py +++ b/sendmail/management/commands/sendmail.py @@ -1,9 +1,11 @@ from collections import OrderedDict + import sendmail from sendmail.management.commands.subcommands.base import SubcommandsCommand from sendmail.management.commands.subcommands.cleanup_mail import Command as CleanupMailCommand -from sendmail.management.commands.subcommands.send_queued_mail import SendBatch, SendQueuedMail from sendmail.management.commands.subcommands.dblocks import Command as DBLocksCommand +from sendmail.management.commands.subcommands.send_queued_mail import SendBatch, SendQueuedMail + class Command(SubcommandsCommand): command_name = "sendmail" diff --git a/sendmail/management/commands/subcommands/cleanup_mail.py b/sendmail/management/commands/subcommands/cleanup_mail.py index ec85f797..3015d965 100644 --- a/sendmail/management/commands/subcommands/cleanup_mail.py +++ b/sendmail/management/commands/subcommands/cleanup_mail.py @@ -1,10 +1,9 @@ import datetime -from django.core.management.base import BaseCommand from django.utils.timezone import now -from sendmail.utils import cleanup_expired_mails from sendmail.management.commands.subcommands.base import SubcommandsCommand +from sendmail.utils import cleanup_expired_mails class Command(SubcommandsCommand): diff --git a/sendmail/management/commands/subcommands/dblocks.py b/sendmail/management/commands/subcommands/dblocks.py index 84cb2538..26918fed 100644 --- a/sendmail/management/commands/subcommands/dblocks.py +++ b/sendmail/management/commands/subcommands/dblocks.py @@ -1,8 +1,7 @@ -from django.core.management.base import BaseCommand from django.utils.timezone import localtime, now -from sendmail.models.dbmutex import DBMutex from sendmail.management.commands.subcommands.base import SubcommandsCommand +from sendmail.models.dbmutex import DBMutex class Command(SubcommandsCommand): diff --git a/sendmail/management/commands/subcommands/send_queued_mail.py b/sendmail/management/commands/subcommands/send_queued_mail.py index 05886555..f5d13499 100644 --- a/sendmail/management/commands/subcommands/send_queued_mail.py +++ b/sendmail/management/commands/subcommands/send_queued_mail.py @@ -1,11 +1,10 @@ from multiprocessing import Pool -from sendmail.management.commands.subcommands.base import SubcommandsCommand -from django.core.management.base import BaseCommand from django.db import connection as db_connection from sendmail.dblock import LockedException, TimeoutException, db_lock from sendmail.mail import _send_bulk, get_queued +from sendmail.management.commands.subcommands.base import SubcommandsCommand from sendmail.settings import get_batch_delivery_timeout from sendmail.utils import split_emails diff --git a/sendmail/models/emailmerge.py b/sendmail/models/emailmerge.py index 7303088c..19714614 100644 --- a/sendmail/models/emailmerge.py +++ b/sendmail/models/emailmerge.py @@ -7,10 +7,10 @@ from sendmail import cache from sendmail.cache_utils import get_placeholder_names, get_placeholders from sendmail.logutils import setup_loghandlers +from sendmail.parser import extract_variable_names, get_ckeditor_variables from sendmail.sanitizer import clean_html from sendmail.settings import get_email_address_setting from sendmail.validators import validate_template_syntax -from sendmail.parser import extract_variable_names, get_ckeditor_variables logger = setup_loghandlers('INFO') diff --git a/sendmail/models/newsletter.py b/sendmail/models/newsletter.py index 686a8cfd..49d477a9 100644 --- a/sendmail/models/newsletter.py +++ b/sendmail/models/newsletter.py @@ -6,10 +6,8 @@ from django.utils.translation import gettext_lazy as _ from sendmail import mail -from sendmail.models.attachment import Attachment from sendmail.models.emailmerge import EmailMergeModel from sendmail.models.recipients_list import RecipientsList -from sendmail.parser import extract_variable_names, get_ckeditor_variables, get_custom_vars from sendmail.validators import validate_email_with_name STATUS = namedtuple('STATUS', 'draft creation queued completed')._make(range(4)) diff --git a/sendmail/parser.py b/sendmail/parser.py index 116c6f8c..99f3bc44 100644 --- a/sendmail/parser.py +++ b/sendmail/parser.py @@ -1,30 +1,14 @@ import re + from django import template -from django.template import loader, TemplateSyntaxError, TemplateDoesNotExist -from django.template.base import Node, NodeList, VariableNode +from django.template import TemplateDoesNotExist, TemplateSyntaxError +from django.template.base import Node, VariableNode from django.template.context import Context from django.template.defaulttags import ForNode from django.template.loader import get_template from django.template.loader_tags import ExtendsNode, IncludeNode -from sendmail.django_compressor import handle_extendsnode - - -def handle_includenode(includenode, context): - """ - Process an IncludeNode to include the content of the referenced template. - - Args: - includenode (IncludeNode): The IncludeNode to process. - context (Context): The context in which to render the included template. - - Returns: - NodeList: The nodelist of the included template. - """ - included_template = includenode.template.resolve(context) - if isinstance(included_template, str): - included_template = loader.get_template(included_template) - return included_template.template.nodelist +from sendmail.django_compressor import handle_extendsnode, handle_includenode class SendmailParser: diff --git a/sendmail/tasks.py b/sendmail/tasks.py index 553f7d6a..e7795aa9 100644 --- a/sendmail/tasks.py +++ b/sendmail/tasks.py @@ -12,7 +12,7 @@ from django.utils.timezone import now from sendmail.mail import _send_bulk, get_queued -from sendmail.settings import get_celery_enabled, get_break_after_batch +from sendmail.settings import get_break_after_batch, get_celery_enabled from sendmail.utils import cleanup_expired_mails try: diff --git a/sendmail/views.py b/sendmail/views.py index 6ca84859..7f2bd357 100644 --- a/sendmail/views.py +++ b/sendmail/views.py @@ -1,7 +1,7 @@ from django.conf import settings -from django.contrib.messages.storage import default_storage from django.contrib.staticfiles.storage import staticfiles_storage +from django.core.exceptions import ValidationError from django.core.files.storage import default_storage from django.core.validators import URLValidator from django.http import FileResponse, HttpResponseBadRequest, HttpResponseNotFound, HttpResponseRedirect @@ -49,7 +49,7 @@ def click(request, pk): try: URLValidator()(target_uri) - except: + except ValidationError: return HttpResponseBadRequest("Invalid 'target_uri' parameter") if not email.clicked_at: