Replace pystache with string.Template
This commit is contained in:
parent
395c3a6c48
commit
a78ae0fdd6
1
setup.py
1
setup.py
|
@ -32,7 +32,6 @@ setup(
|
|||
author_email = 'sir@cmpwn.com',
|
||||
url = 'https://todo.sr.ht/~sircmpwn/todo.sr.ht',
|
||||
install_requires = [
|
||||
'pystache',
|
||||
'srht',
|
||||
],
|
||||
license = 'AGPL-3.0',
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import html.parser
|
||||
import os
|
||||
import pystache
|
||||
import textwrap
|
||||
from string import Template
|
||||
from srht.config import cfg, cfgi
|
||||
from srht.email import send_email, lookup_key
|
||||
from srht.oauth import current_user
|
||||
|
@ -26,11 +26,11 @@ def notify(sub, template, subject, headers, **kwargs):
|
|||
else:
|
||||
return
|
||||
with open(os.path.join(os.path.dirname(__file__), "emails", template)) as f:
|
||||
body = html.unescape(
|
||||
pystache.render(f.read(), {
|
||||
'user': current_user,
|
||||
'root': origin,
|
||||
'format_lines': format_lines,
|
||||
**kwargs
|
||||
}))
|
||||
tmpl = Template(f.read())
|
||||
body = tmpl.substitute(**{
|
||||
'username': current_user.username,
|
||||
'user_email': current_user.email,
|
||||
'root': origin,
|
||||
**kwargs,
|
||||
})
|
||||
send_email(body, to, subject, encrypt_key=encrypt_key, **headers)
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
{{! vim: set ft=email }}
|
||||
{{ticket.description}}
|
||||
$description
|
||||
|
||||
--
|
||||
View on the web: {{root}}{{ticket_url}}
|
||||
View on the web: $root$ticket_url
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
{{! vim: set ft=email }}
|
||||
You were assigned to {{ ticket_ref }} by {{ assigner }}.
|
||||
You were assigned to $ticket_ref by $assigner.
|
||||
|
||||
--
|
||||
View on the web: {{root}}{{ticket_url}}
|
||||
View on the web: $root$ticket_url
|
||||
|
|
|
@ -1,8 +1,4 @@
|
|||
{{! vim: set ft=email }}
|
||||
{{#resolution}}
|
||||
Ticket resolved: {{resolution}}
|
||||
|
||||
{{/resolution}}{{comment_text}}
|
||||
$resolution$comment_text
|
||||
|
||||
--
|
||||
View on the web: {{root}}{{ticket_url}}
|
||||
View on the web: $root$ticket_url
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
{{! vim: set ft=email }}
|
||||
You were mentioned in {{ ticket_ref }} by {{ submitter }}.
|
||||
You were mentioned in $ticket_ref by $submitter.
|
||||
|
||||
{{ text }}
|
||||
$text
|
||||
|
||||
--
|
||||
View on the web: {{root}}{{ticket_url}}
|
||||
View on the web: $root$ticket_url
|
||||
|
|
|
@ -190,7 +190,7 @@ def _send_comment_notification(subscription, ticket,
|
|||
ticket=ticket,
|
||||
comment=comment,
|
||||
comment_text=format_lines(comment.text) if comment else "",
|
||||
resolution=resolution.name if resolution else None,
|
||||
resolution=f"""Ticket resolved: {resolution.name}\n\n""" if resolution else None,
|
||||
ticket_url=url)
|
||||
|
||||
def _change_ticket_status(ticket, resolve, resolution, reopen):
|
||||
|
@ -474,7 +474,8 @@ def _send_new_ticket_notification(subscription, ticket, email_trigger_id):
|
|||
headers["In-Reply-To"] = email_trigger_id
|
||||
|
||||
notify(subscription, "new_ticket", subject,
|
||||
headers=headers, ticket=ticket, ticket_url=ticket_url(ticket))
|
||||
headers=headers, description=ticket.description,
|
||||
ticket_url=ticket_url(ticket))
|
||||
|
||||
def submit_ticket(tracker, submitter, title, description,
|
||||
importing=False, from_email=False, from_email_id=None):
|
||||
|
|
Loading…
Reference in New Issue