Introduce notifications app and integrate emails
Add a new notifications app (models, serializers, views, admin, tasks, consumers, routing, urls, tests) with Notification.notify for in-app websocket pushes and optional email delivery. Centralize email sending in notifications.tasks.send_email_with_context and re-export it from account.tasks for compatibility. Update account and commerce and advertisement tasks to use Notification.notify/_notify_order and the new email helper; adjust order/notification tasks to consolidate logic. Wire notifications into ASGI routing, settings and URL conf. Misc: handle OSError when importing weasyprint, add tmp/ to .gitignore, add local .claude PowerShell checks, add social.blog skeleton, and remove legacy ews-component test files.
This commit is contained in:
@@ -1,47 +1,35 @@
|
||||
from venv import create
|
||||
from account.tasks import send_email_with_context
|
||||
from notifications.tasks import send_email_with_context
|
||||
from configuration.models import SiteConfiguration
|
||||
|
||||
from celery import shared_task
|
||||
from celery.schedules import crontab
|
||||
|
||||
from commerce.models import Product
|
||||
import datetime
|
||||
|
||||
|
||||
@shared_task
|
||||
def send_contact_me_email_task(client_email, message_content):
|
||||
context = {
|
||||
"client_email": client_email,
|
||||
"message_content": message_content
|
||||
}
|
||||
config_email = SiteConfiguration.get_solo().contact_email
|
||||
recipient = config_email if config_email else "brunovontor@gmail.com"
|
||||
send_email_with_context(
|
||||
recipients=recipient,
|
||||
subject="Poptávka z kontaktního formuláře!!!",
|
||||
template_path="email/contact_me.html",
|
||||
context=context,
|
||||
context={
|
||||
"client_email": client_email,
|
||||
"message_content": message_content,
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
@shared_task
|
||||
def send_newly_added_items_to_store_email_task_last_week():
|
||||
last_week_date = datetime.datetime.now() - datetime.timedelta(days=7)
|
||||
|
||||
"""
|
||||
__lte -> Less than or equal
|
||||
__gte -> Greater than or equal
|
||||
__lt -> Less than
|
||||
__gt -> Greater than
|
||||
"""
|
||||
|
||||
products_of_week = Product.objects.filter(
|
||||
include_in_week_summary_email=True,
|
||||
created_at__gte=last_week_date
|
||||
created_at__gte=last_week_date,
|
||||
)
|
||||
|
||||
config = SiteConfiguration.get_solo()
|
||||
|
||||
send_email_with_context(
|
||||
recipients=config.contact_email,
|
||||
subject="Nový produkt přidán do obchodu",
|
||||
@@ -49,6 +37,5 @@ def send_newly_added_items_to_store_email_task_last_week():
|
||||
context={
|
||||
"products_of_week": products_of_week,
|
||||
"site_currency": config.currency,
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user