Code reference › domain › mail

class

UntrustedSpeakerNameMailTextPlaceholder

pretalx.mail.domain.placeholders.UntrustedSpeakerNameMailTextPlaceholder source

This placeholder resolves a user's name in an event context if possible, falling back to the global name if no event is present.

Inherited attributes 1
account_requiredFalseBaseMailTextPlaceholder

Properties 4

Defined here

required_contextsource

on pretalx.mail.domain.placeholders.UntrustedSpeakerNameMailTextPlaceholder source

@property
def required_context(self):
    return ["user"]

on pretalx.mail.domain.placeholders.BaseRichMailTextPlaceholder source

@property
def required_context(self):
    return self._args

on pretalx.mail.domain.placeholders.BaseMailTextPlaceholder source

Keys this placeholder needs in the render context.

@property
def required_context(self):
    """Keys this placeholder needs in the render context."""
    return ["event"]

From BaseRichMailTextPlaceholder pretalx.mail.domain.placeholders

explanationsource

on pretalx.mail.domain.placeholders.BaseRichMailTextPlaceholder source

@property
def explanation(self):
    return self._explanation or ""

on pretalx.mail.domain.placeholders.BaseMailTextPlaceholder source

@property
def explanation(self):
    return ""
identifiersource

on pretalx.mail.domain.placeholders.BaseRichMailTextPlaceholder source

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

on pretalx.mail.domain.placeholders.BaseMailTextPlaceholder source

Unique key the placeholder is referenced by in templates.

@property
def identifier(self):
    """Unique key the placeholder is referenced by in templates."""
    raise NotImplementedError
is_visiblesource

on pretalx.mail.domain.placeholders.BaseRichMailTextPlaceholder source

@property
def is_visible(self):
    return self._is_visible

on pretalx.mail.domain.placeholders.BaseMailTextPlaceholder source

Set False to hide from the placeholder picker (e.g. aliases).

@property
def is_visible(self):
    """Set ``False`` to hide from the placeholder picker (e.g. aliases)."""
    return True

Methods 7

Defined here

render(context)sourceReturn the rendered value given a context dict.

on pretalx.mail.domain.placeholders.UntrustedSpeakerNameMailTextPlaceholder source

def render(self, context):
    kwargs = {"user": context["user"], "event": context.get("event")}
    return EmailAlternativeString(
        self.render_plain(**kwargs), self.render_html(**kwargs)
    )

on pretalx.mail.domain.placeholders.BaseRichMailTextPlaceholder source

Return the rendered value given a context dict.

def render(self, context):
    kwargs = {key: context[key] for key in self._args}
    return EmailAlternativeString(
        self.render_plain(**kwargs), self.render_html(**kwargs)
    )

on pretalx.mail.domain.placeholders.BaseMailTextPlaceholder source

Return the rendered value given a context dict.

def render(self, context):
    """Return the rendered value given a context dict."""
    raise NotImplementedError

From UntrustedPlainMailTextPlaceholder pretalx.mail.domain.placeholders

__init__(identifier, args, func, sample, explanation=None, is_visible=True)sourceInitialize self.

on pretalx.mail.domain.placeholders.UntrustedPlainMailTextPlaceholder source

See help(type(self)) for accurate signature.

def __init__(
    self, identifier, args, func, sample, explanation=None, is_visible=True
):
    super().__init__(
        identifier, args, sample, explanation=explanation, is_visible=is_visible
    )
    self._func = func

on pretalx.mail.domain.placeholders.BaseRichMailTextPlaceholder source

Initialize self. See help(type(self)) for accurate signature.

def __init__(self, identifier, args, sample, explanation=None, is_visible=True):
    self._identifier = identifier
    self._args = args
    self._sample = sample
    self._explanation = explanation
    self._is_visible = is_visible
__repr__()sourceReturn repr(self).
def __repr__(self):
    return f"UntrustedPlainMailTextPlaceholder({self._identifier})"

From BaseRichMailTextPlaceholder pretalx.mail.domain.placeholders

render_html(**kwargs)source
def render_html(self, **kwargs):
    return self._render_html_value(self._func(**kwargs))
render_plain(**kwargs)source
def render_plain(self, **kwargs):
    return self._render_plain_value(self._func(**kwargs))
render_sample(event)sourceReturn a preview value that depends only on event.

on pretalx.mail.domain.placeholders.BaseRichMailTextPlaceholder source

def render_sample(self, event):
    if callable(self._sample):
        return self._sample(event)
    return self._sample

on pretalx.mail.domain.placeholders.BaseMailTextPlaceholder source

Return a preview value that depends only on event.

def render_sample(self, event):
    """Return a preview value that depends only on ``event``."""
    raise NotImplementedError
render_sample_for_preview(event)sourceShape the sample like render's output so the preview pipeline matches delivery.

on pretalx.mail.domain.placeholders.BaseRichMailTextPlaceholder source

def render_sample_for_preview(self, event):
    # Coerce to ``str`` so lazy i18n samples match the plain-string
    # shape ``self._func`` returns in production and satisfy
    # ``EmailAlternativeString``'s type guard.
    sample = str(self.render_sample(event) or "")
    return EmailAlternativeString(
        self._render_plain_value(sample), self._render_html_value(sample)
    )

on pretalx.mail.domain.placeholders.BaseMailTextPlaceholder source

Shape the sample like render()'s output so the preview pipeline matches delivery.

def render_sample_for_preview(self, event):
    """Shape the sample like :meth:`render`'s output so the preview
    pipeline matches delivery."""
    return self.render_sample(event)