~sircmpwn/todo.sr.ht

a78ae0fdd6054117db690873a6e06ae2f9265723 — Drew DeVault 2 months ago 395c3a6 0.64.15
Replace pystache with string.Template
M setup.py => setup.py +0 -1
@@ 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',

M todosrht/email.py => todosrht/email.py +8 -8
@@ 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)

M todosrht/emails/new_ticket => todosrht/emails/new_ticket +2 -3
@@ 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

M todosrht/emails/ticket_assigned => todosrht/emails/ticket_assigned +2 -3
@@ 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

M todosrht/emails/ticket_comment => todosrht/emails/ticket_comment +2 -6
@@ 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

M todosrht/emails/ticket_mention => todosrht/emails/ticket_mention +3 -4
@@ 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

M todosrht/tickets.py => todosrht/tickets.py +3 -2
@@ 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):