eschutho commented on code in PR #35014:
URL: https://github.com/apache/superset/pull/35014#discussion_r2325963197
##########
superset/reports/notifications/email.py:
##########
@@ -132,19 +133,124 @@ def _get_content(self) -> EmailContent:
attributes=ALLOWED_ATTRIBUTES,
)
- # Strip malicious HTML from embedded data, allowing only table elements
- if self._content.embedded_data is not None:
+ pdf_data = None
+ html_table = ""
+
+ # Check if the report format is PDF and embedded data is available
+ # Assuming self._content.report_format exists and holds the report
format string
+ if hasattr(self._content, 'report_format') and \
+ self._content.report_format == "PDF" and \
+ self._content.embedded_data is not None:
df = self._content.embedded_data
- # pylint: disable=no-member
- html_table = nh3.clean(
- df.to_html(na_rep="", index=True, escape=True),
- # pandas will escape the HTML in cells already, so passing
- # more allowed tags here will not work
- tags=TABLE_TAGS,
- attributes=ALLOWED_TABLE_ATTRIBUTES,
- )
- else:
+ report_name_val = self._name # Renamed to avoid clash with CSS
variable name
+ generation_date_val = self.now.strftime('%Y-%m-%d %H:%M:%S UTC')
+
+ # Retrieve PDF export configurations
+ pdf_headers_footers_enabled =
app.config.get("PDF_EXPORT_HEADERS_FOOTERS_ENABLED", True)
+ pdf_header_template = app.config.get("PDF_EXPORT_HEADER_TEMPLATE",
"Report: {report_name} - Page {page_number} of {total_pages}")
+ pdf_footer_template = app.config.get("PDF_EXPORT_FOOTER_TEMPLATE",
"Generated: {generation_date}")
+ pdf_page_size = app.config.get("PDF_EXPORT_PAGE_SIZE", "A4")
+ pdf_orientation = app.config.get("PDF_EXPORT_ORIENTATION",
"portrait")
Review Comment:
The config file has defaults, so there's no need to set them again here.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]