Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

debug 2 #29

Merged
merged 1 commit into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion GD/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,4 +253,3 @@ def show_toolbar(request):
ALT_EMAIL_HOST_PASSWORD = config("ALT_EMAIL_HOST_PASSWORD")
ALT_EMAIL_PORT = int(config("ALT_EMAIL_PORT"))
ALT_EMAIL_BACKEND = config("ALT_EMAIL_BACKEND")

41 changes: 28 additions & 13 deletions core/admin.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from datetime import timezone

import jdatetime
from dill import objects
from django.contrib import admin
Expand Down Expand Up @@ -67,29 +69,38 @@ def main_presenter(obj):
return "no presenters"


def send_reminder(service):
presentation = service.talk or service.workshop
user = service.user
def send_reminder(services):
if not services:
return

sample = services[0]
presentation = sample.talk or sample.workshop
date = presentation.start
j_date = (jdatetime.datetime.utcfromtimestamp(date.timestamp())
.aslocale(jdatetime.FA_LOCALE).
strftime('%a, %d %b %Y (%H:%M)'))
emails = [service.user.email for service in services]

context = {
'name': user.first_name,
'email': user.email,
'emails': emails,
'title': presentation.title,
'is_online': bool(presentation.is_online),
'link': presentation.presentation_link,
'date': jdatetime.datetime.
fromgregorian(year=date.year, month=date.month, day=date.day, hour=date.hour, minute=date.minute,
locale=jdatetime.FA_LOCALE).strftime('%a, %d %b %Y %H:%M')
'date': j_date
}
reminder_email_task.delay(context)
reminder_email_task(context)


@admin.register(Talk)
class TalkAdmin(admin.ModelAdmin):
def send_reminder_emails(self, request, queryset):
for event in queryset.all():
for service in EventService.objects.filter(talk=event):
send_reminder(service)
services = []
for service in EventService.objects.filter(talk_id=event.id):
if service.payment_state == "CM":
services.append(service)

send_reminder(services)

return JsonResponse({"message": "Emails sent."})

Expand Down Expand Up @@ -126,8 +137,12 @@ def send_reminder_emails(self, request, queryset):
class WorkshopAdmin(admin.ModelAdmin):
def send_reminder_emails(self, request, queryset):
for event in queryset.all():
for service in EventService.objects.filter(workshop=event):
send_reminder(service)
services = []
for service in EventService.objects.filter(workshop_id=event.id):
if service.payment_state == "CM":
services.append(service)

send_reminder(services)

return JsonResponse({"message": "Emails sent."})

Expand Down
4 changes: 2 additions & 2 deletions tasks/emails.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,13 @@ def send_reminder_email(service_data):
subject=email_subject,
body=html_message,
from_email=settings.DEFAULT_FROM_EMAIL,
to=[service_data["email"], ],
to=service_data["emails"],
connection=connection,
)

msg.attach_alternative(html_message, 'text/html')
msg.send()
return {'success': True, 'email': service_data['email']}
return {'success': True}


def send_team_request(team_data):
Expand Down
4 changes: 1 addition & 3 deletions templates/event_reminder.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,8 @@
<tr style="text-align: center;">
<td style="text-align: center;">
<div style="background-color: #E8E7FF;text-align: center;padding: 20px 70px;width: fit-content;border-radius: 16px;margin: auto;margin-top: 56px;">
<p style="color: #474666;font-family: 'Estedad-SemiBold';margin-bottom: 0;">{{ name|safe }}
عزیز سلام!</p>
<p style="color: #474666;font-family: 'Estedad-SemiBold';margin-bottom: 0;">
از اینکه همراه ما هستی، بسیار خرسندیم.
دوست عزیز سلام! از اینکه همراه ما هستی بسیار خرسندیم.
</p>
<label style="color: #474666;font-family: 'Estedad-SemiBold';margin-bottom: 0;">
یادآوری رویداد: {{ title }}
Expand Down
Loading