mirror of
https://github.com/pretix/pretix.git
synced 2026-05-06 15:24:02 +00:00
Improvements to PDF text placeholders (#2562)
This commit is contained in:
@@ -372,7 +372,9 @@
|
||||
<label>{% trans "Content" %}</label><br>
|
||||
<select class="input-block-level form-control" id="toolbox-content">
|
||||
{% for varname, var in variables.items %}
|
||||
<option data-sample="{{ var.editor_sample }}" value="{{ varname }}">{{ var.label }}</option>
|
||||
{% if not var.hidden %}
|
||||
<option data-sample="{{ var.editor_sample }}" {% if var.migrate_from %}data-old-value="{{ var.migrate_from }}"{% endif %} value="{{ varname }}">{{ var.label }}</option>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% for p in request.organizer.meta_properties.all %}
|
||||
<option value="meta:{{ p.name }}">
|
||||
@@ -394,6 +396,9 @@
|
||||
<textarea id="toolbox-content-other-{{ l }}" rows="3" class="input-block-level form-control" title="{{ l }}" lang="{{ l }}"></textarea>
|
||||
{% endfor %}
|
||||
</div>
|
||||
<p class="help-block" id="toolbox-content-other-help">
|
||||
<a href="?placeholders=true" target="_blank">{% trans "Show available placeholders" %}</a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
{% extends "pretixcontrol/event/base.html" %}
|
||||
{% load i18n %}
|
||||
{% load static %}
|
||||
{% load compress %}
|
||||
{% block title %}{% trans "PDF Editor" %}{% endblock %}
|
||||
{% block custom_header %}
|
||||
{{ block.super }}
|
||||
{% compress css %}
|
||||
<link type="text/css" rel="stylesheet" href="{% static "pretixcontrol/scss/pdfeditor.css" %}">
|
||||
{% endcompress %}
|
||||
<link type="text/css" rel="stylesheet" href="{% url "control:pdf.css" %}">
|
||||
{% endblock %}
|
||||
{% block content %}
|
||||
<h1>
|
||||
{% trans "PDF Editor" %}
|
||||
<small>{% trans "Available placeholders" %}</small>
|
||||
</h1>
|
||||
<p>
|
||||
{% blocktrans trimmed %}
|
||||
You can use placeholders in custom texts on tickets to enrich your text with individual data. Which
|
||||
placeholders are available depends on your event settings, activated plugins, the selected product,
|
||||
as well as user input.
|
||||
This page lists all placeholders technically available for your event, however most of them can also
|
||||
be empty in some cases depending on configuration.
|
||||
{% endblocktrans %}
|
||||
</p>
|
||||
<div class="table-responsive">
|
||||
<table class="table table-hover table-condensed">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>{% trans "Placeholder" %}</th>
|
||||
<th>{% trans "Description" %}</th>
|
||||
<th>{% trans "Formatting example" %}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for varname, var in variables.items %}
|
||||
{% if not var.hidden %}
|
||||
<tr>
|
||||
<td><code>{{ "{" }}{{ varname }}{{ "}" }}</code></td>
|
||||
<td>{{ var.label }}</td>
|
||||
<td>{{ var.editor_sample }}</td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% for p in request.organizer.meta_properties.all %}
|
||||
<tr>
|
||||
<td><code>{{ "{" }}meta:{{ p.name }}{{ "}" }}</code></td>
|
||||
<td>
|
||||
{% trans "Event attribute:" %} {{ p.name }}
|
||||
</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
{% for p in request.event.item_meta_properties.all %}
|
||||
<tr>
|
||||
<td><code>{{ "{" }}itemmeta:{{ p.name }}{{ "}" }}</code></td>
|
||||
<td>
|
||||
{% trans "Item attribute:" %} {{ p.name }}
|
||||
</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
@@ -33,7 +33,7 @@ from django.core.files.storage import default_storage
|
||||
from django.http import (
|
||||
FileResponse, HttpResponse, HttpResponseBadRequest, JsonResponse,
|
||||
)
|
||||
from django.shortcuts import get_object_or_404
|
||||
from django.shortcuts import get_object_or_404, render
|
||||
from django.urls import reverse
|
||||
from django.utils.crypto import get_random_string
|
||||
from django.utils.timezone import now
|
||||
@@ -65,10 +65,17 @@ class BaseEditorView(EventPermissionRequiredMixin, TemplateView):
|
||||
title = None
|
||||
|
||||
def get(self, request, *args, **kwargs):
|
||||
if 'placeholders' in request.GET:
|
||||
return self.get_placeholders_help(request)
|
||||
resp = super().get(request, *args, **kwargs)
|
||||
resp._csp_ignore = True
|
||||
return resp
|
||||
|
||||
def get_placeholders_help(self, request):
|
||||
ctx = {}
|
||||
ctx['variables'] = self.get_variables()
|
||||
return render(request, 'pretixcontrol/pdf/placeholders.html', ctx)
|
||||
|
||||
def process_upload(self):
|
||||
f = self.request.FILES.get('background')
|
||||
error = False
|
||||
|
||||
Reference in New Issue
Block a user