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

[DEV] CSV report dev #12

Merged
merged 14 commits into from
Nov 25, 2022
Merged
Prev Previous commit
Next Next commit
Getting all data using one argument
  • Loading branch information
miladsade96 committed Nov 24, 2022
commit 162f96be1ec30e1eb6f8846ce81269e911c3dc09
16 changes: 9 additions & 7 deletions petition/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,17 @@ def csv_generator(data):


@shared_task
def send_successful_petition_report(
title, owner, recipient_name, recipient_email, report_file_data
):
def send_successful_petition_report(data):
email = EmailMessage(
template_name="email/successful_petition_report.tpl",
from_email="[email protected]",
to=[recipient_email],
context={"title": title, "owner": owner, "recipient_name": recipient_name},
to=[data.get("petition_recipient_email")],
context={
"title": data.get("petition_title"),
"owner": data.get("petition_owner_name"),
"recipient_name": data.get("petition_recipient_name"),
},
)
pdf = pdf_generator(report_file_data)
email.attach("petition_report.pdf", pdf, "application/pdf")
csv_file = csv_generator(data=data.get("petition_signatures"))
email.attach("report.csv", csv_file.read(), "text/csv")
email.send()