forked from CGM_Public/pretix_original
PDF editor: Allow arbitrary fields in QR codes
This commit is contained in:
committed by
Raphael Michel
parent
c2f2e157d7
commit
4ae7cc9f50
@@ -202,6 +202,11 @@ DEFAULT_VARIABLES = OrderedDict((
|
|||||||
"editor_sample": 'foo@bar.com',
|
"editor_sample": 'foo@bar.com',
|
||||||
"evaluate": lambda op, order, ev: op.attendee_email or (op.addon_to.attendee_email if op.addon_to else '')
|
"evaluate": lambda op, order, ev: op.attendee_email or (op.addon_to.attendee_email if op.addon_to else '')
|
||||||
}),
|
}),
|
||||||
|
("pseudonymization_id", {
|
||||||
|
"label": _("Pseudonymization ID (lead scanning)"),
|
||||||
|
"editor_sample": "GG89JUJDTA",
|
||||||
|
"evaluate": lambda orderposition, order, event: orderposition.pseudonymization_id,
|
||||||
|
}),
|
||||||
("event_name", {
|
("event_name", {
|
||||||
"label": _("Event name"),
|
"label": _("Event name"),
|
||||||
"editor_sample": _("Sample event name"),
|
"editor_sample": _("Sample event name"),
|
||||||
@@ -616,12 +621,12 @@ class Renderer:
|
|||||||
preserveAspectRatio=True, anchor='n',
|
preserveAspectRatio=True, anchor='n',
|
||||||
mask='auto')
|
mask='auto')
|
||||||
|
|
||||||
def _draw_barcodearea(self, canvas: Canvas, op: OrderPosition, o: dict):
|
def _draw_barcodearea(self, canvas: Canvas, op: OrderPosition, order: Order, o: dict):
|
||||||
content = o.get('content', 'secret')
|
content = o.get('content', 'secret')
|
||||||
if content == 'secret':
|
if content == 'secret':
|
||||||
content = op.secret
|
content = op.secret
|
||||||
elif content == 'pseudonymization_id':
|
else:
|
||||||
content = op.pseudonymization_id
|
content = self._get_text_content(op, order, o)
|
||||||
|
|
||||||
level = 'H'
|
level = 'H'
|
||||||
if len(content) > 32:
|
if len(content) > 32:
|
||||||
@@ -767,7 +772,7 @@ class Renderer:
|
|||||||
if o.get('page', 1) != page + 1:
|
if o.get('page', 1) != page + 1:
|
||||||
continue
|
continue
|
||||||
if o['type'] == "barcodearea":
|
if o['type'] == "barcodearea":
|
||||||
self._draw_barcodearea(canvas, op, o)
|
self._draw_barcodearea(canvas, op, order, o)
|
||||||
elif o['type'] == "imagearea":
|
elif o['type'] == "imagearea":
|
||||||
self._draw_imagearea(canvas, op, order, o)
|
self._draw_imagearea(canvas, op, order, o)
|
||||||
elif o['type'] == "textarea":
|
elif o['type'] == "textarea":
|
||||||
|
|||||||
@@ -367,9 +367,9 @@
|
|||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row control-group text">
|
<div class="row control-group text textcontent">
|
||||||
<div class="col-sm-12">
|
<div class="col-sm-12">
|
||||||
<label>{% trans "Text content" %}</label><br>
|
<label>{% trans "Content" %}</label><br>
|
||||||
<select class="input-block-level form-control" id="toolbox-content">
|
<select class="input-block-level form-control" id="toolbox-content">
|
||||||
{% for varname, var in variables.items %}
|
{% for varname, var in variables.items %}
|
||||||
<option data-sample="{{ var.editor_sample }}" value="{{ varname }}">{{ var.label }}</option>
|
<option data-sample="{{ var.editor_sample }}" value="{{ varname }}">{{ var.label }}</option>
|
||||||
@@ -411,6 +411,12 @@
|
|||||||
<span class="fa fa-qrcode"></span>
|
<span class="fa fa-qrcode"></span>
|
||||||
{% trans "QR code for Lead Scanning" %}
|
{% trans "QR code for Lead Scanning" %}
|
||||||
</button>
|
</button>
|
||||||
|
<button class="btn btn-default btn-block" id="editor-add-qrcode-other"
|
||||||
|
data-content="secret"
|
||||||
|
disabled>
|
||||||
|
<span class="fa fa-qrcode"></span>
|
||||||
|
{% trans "Other QR code" %}
|
||||||
|
</button>
|
||||||
<button class="btn btn-default btn-block" id="editor-add-poweredby"
|
<button class="btn btn-default btn-block" id="editor-add-poweredby"
|
||||||
data-content="dark"
|
data-content="dark"
|
||||||
disabled>
|
disabled>
|
||||||
|
|||||||
@@ -66,9 +66,11 @@ fabric.Barcodearea = fabric.util.createClass(fabric.Rect, {
|
|||||||
ctx.font = '16px Helvetica';
|
ctx.font = '16px Helvetica';
|
||||||
ctx.fillStyle = '#fff';
|
ctx.fillStyle = '#fff';
|
||||||
if (this.content === "pseudonymization_id") {
|
if (this.content === "pseudonymization_id") {
|
||||||
ctx.fillText(gettext('Lead Scan QR'), -this.width / 2, -this.height / 2 + 20);
|
ctx.fillText(this.content, -this.width / 2, -this.height / 2 + 20);
|
||||||
} else {
|
} else if (!this.content || this.content === "secret") {
|
||||||
ctx.fillText(gettext('Check-in QR'), -this.width / 2, -this.height / 2 + 20);
|
ctx.fillText(gettext('Check-in QR'), -this.width / 2, -this.height / 2 + 20);
|
||||||
|
} else {
|
||||||
|
ctx.fillText(this.content, -this.width / 2, -this.height / 2 + 20);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
@@ -478,14 +480,18 @@ var editor = {
|
|||||||
$("#toolbox").find("button[data-action=right]").toggleClass('active', o.textAlign === 'right');
|
$("#toolbox").find("button[data-action=right]").toggleClass('active', o.textAlign === 'right');
|
||||||
$("#toolbox-textwidth").val(editor._px2mm(o.width).toFixed(2));
|
$("#toolbox-textwidth").val(editor._px2mm(o.width).toFixed(2));
|
||||||
$("#toolbox-textrotation").val((o.angle || 0.0).toFixed(1));
|
$("#toolbox-textrotation").val((o.angle || 0.0).toFixed(1));
|
||||||
if (o.type === "textarea") {
|
}
|
||||||
$("#toolbox-content").val(o.content);
|
|
||||||
$("#toolbox-content-other").toggle($("#toolbox-content").val() === "other");
|
if (o.type === "textarea" || o.type === "barcodearea") {
|
||||||
if (o.content === "other") {
|
if (!o.content && o.type == "barcodearea") {
|
||||||
$("#toolbox-content-other").val(o.text);
|
o.content = "secret";
|
||||||
} else {
|
}
|
||||||
$("#toolbox-content-other").val("");
|
$("#toolbox-content").val(o.content);
|
||||||
}
|
$("#toolbox-content-other").toggle($("#toolbox-content").val() === "other");
|
||||||
|
if (o.content === "other") {
|
||||||
|
$("#toolbox-content-other").val(o.text);
|
||||||
|
} else {
|
||||||
|
$("#toolbox-content-other").val("");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -517,6 +523,14 @@ var editor = {
|
|||||||
o.setScaleY(1);
|
o.setScaleY(1);
|
||||||
o.set('top', new_top)
|
o.set('top', new_top)
|
||||||
o.nowhitespace = $("#toolbox-qrwhitespace").prop("checked") || false;
|
o.nowhitespace = $("#toolbox-qrwhitespace").prop("checked") || false;
|
||||||
|
|
||||||
|
$("#toolbox-content-other").toggle($("#toolbox-content").val() === "other");
|
||||||
|
o.content = $("#toolbox-content").val();
|
||||||
|
if ($("#toolbox-content").val() === "other") {
|
||||||
|
o.text = $("#toolbox-content-other").val();
|
||||||
|
} else {
|
||||||
|
o.text = editor._get_text_sample($("#toolbox-content").val());
|
||||||
|
}
|
||||||
} else if (o.type === "imagearea") {
|
} else if (o.type === "imagearea") {
|
||||||
var new_w = editor._mm2px($("#toolbox-width").val());
|
var new_w = editor._mm2px($("#toolbox-width").val());
|
||||||
var new_h = editor._mm2px($("#toolbox-height").val());
|
var new_h = editor._mm2px($("#toolbox-height").val());
|
||||||
@@ -674,6 +688,7 @@ var editor = {
|
|||||||
lockUniScaling: true,
|
lockUniScaling: true,
|
||||||
fill: '#666',
|
fill: '#666',
|
||||||
content: $(this).attr("data-content"),
|
content: $(this).attr("data-content"),
|
||||||
|
text: '',
|
||||||
nowhitespace: true,
|
nowhitespace: true,
|
||||||
});
|
});
|
||||||
rect.setControlsVisibility({'mtr': false});
|
rect.setControlsVisibility({'mtr': false});
|
||||||
@@ -931,7 +946,7 @@ var editor = {
|
|||||||
editor.$fcv = $("#fabric-canvas");
|
editor.$fcv = $("#fabric-canvas");
|
||||||
editor.$cva = $("#editor-canvas-area");
|
editor.$cva = $("#editor-canvas-area");
|
||||||
editor._load_pdf();
|
editor._load_pdf();
|
||||||
$("#editor-add-qrcode, #editor-add-qrcode-lead").click(editor._add_qrcode);
|
$("#editor-add-qrcode, #editor-add-qrcode-lead, #editor-add-qrcode-other").click(editor._add_qrcode);
|
||||||
$("#editor-add-image").click(editor._add_imagearea);
|
$("#editor-add-image").click(editor._add_imagearea);
|
||||||
$("#editor-add-text").click(editor._add_text);
|
$("#editor-add-text").click(editor._add_text);
|
||||||
$("#editor-add-poweredby").click(function() {editor._add_poweredby("dark")});
|
$("#editor-add-poweredby").click(function() {editor._add_poweredby("dark")});
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ body {
|
|||||||
}
|
}
|
||||||
#toolbox[data-type] .position,
|
#toolbox[data-type] .position,
|
||||||
#toolbox[data-type=barcodearea] .squaresize,
|
#toolbox[data-type=barcodearea] .squaresize,
|
||||||
|
#toolbox[data-type=barcodearea] .textcontent,
|
||||||
#toolbox[data-type=imagearea] .rectsize,
|
#toolbox[data-type=imagearea] .rectsize,
|
||||||
#toolbox[data-type=imagearea] .imagecontent,
|
#toolbox[data-type=imagearea] .imagecontent,
|
||||||
#toolbox[data-type=poweredby] .poweredby,
|
#toolbox[data-type=poweredby] .poweredby,
|
||||||
|
|||||||
Reference in New Issue
Block a user