Skip to content

Commit

Permalink
added attendee_email placeholder
Browse files Browse the repository at this point in the history
  • Loading branch information
rrrliu committed Oct 9, 2024
1 parent c521dfb commit 06f6836
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 3 deletions.
5 changes: 2 additions & 3 deletions pretix_email_template_plugin/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,15 @@
except ImportError:
raise RuntimeError("Please use pretix 2.7 or above to run this plugin!")


class PluginApp(PluginConfig):
default = True
name = "pretix_email_template_plugin"
verbose_name = "Email Template"
verbose_name = "Email template helper"

class PretixPluginMeta:
name = gettext_lazy("Email Template")
author = "Your name"
description = gettext_lazy("Short description")
description = gettext_lazy("More email template placeholders, such as {attendee_email}")
visible = True
version = __version__
category = "FEATURE"
Expand Down
30 changes: 30 additions & 0 deletions pretix_email_template_plugin/signals.py
Original file line number Diff line number Diff line change
@@ -1 +1,31 @@
# Register your receivers here
from django.dispatch import receiver

from pretix.base.signals import register_text_placeholders
from pretix.base.email import BaseMailTextPlaceholder

class AttendeeEmailPlaceholder(BaseMailTextPlaceholder):
def __init__(self):
self._identifier = "attendee_email"

@property
def required_context(self):
return ["order", "position"]

@property
def identifier(self):
return self._identifier

def render(self, context):
position = context["position"]
# TODO: print statement for sanity check -- remove
print(f"attendee_email: {position.attendee_email}")
return position.attendee_email

def render_sample(self, context):
return "[email protected]"


@receiver(register_text_placeholders, dispatch_uid="placeholder_custom")
def register_placeholder_renderers(sender, **kwargs):
return AttendeeEmailPlaceholder()

0 comments on commit 06f6836

Please sign in to comment.