Skip to content

Commit

Permalink
start adding support for custom jinja filters
Browse files Browse the repository at this point in the history
  • Loading branch information
wh1te909 committed Nov 3, 2023
1 parent 8aaa273 commit a5259ba
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
5 changes: 5 additions & 0 deletions api/tacticalrmm/ee/reporting/custom_filters.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from zoneinfo import ZoneInfo


def as_tz(date_obj, tz, format="%b %d, %I:%M %p"):
return date_obj.astimezone(ZoneInfo(tz)).strftime(format)
2 changes: 2 additions & 0 deletions api/tacticalrmm/ee/reporting/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from tacticalrmm.utils import get_db_value

from .constants import REPORTING_MODELS
from .custom_filters import as_tz
from .markdown.config import Markdown
from .models import ReportAsset, ReportDataQuery, ReportHTMLTemplate, ReportTemplate

Expand Down Expand Up @@ -66,6 +67,7 @@ def db_template_loader(template_name: str) -> Optional[str]:
env.globals["datetime"] = datetime
env.globals["ZoneInfo"] = ZoneInfo
env.globals["re"] = re
env.filters["as_tz"] = as_tz


def generate_pdf(*, html: str, css: str = "") -> bytes:
Expand Down

0 comments on commit a5259ba

Please sign in to comment.