forked from CGM_Public/pretix_original
PDF renderer: Fix placeholers using meta: and itemmeta:
This commit is contained in:
@@ -713,11 +713,17 @@ class Renderer:
|
|||||||
text = o['text']
|
text = o['text']
|
||||||
|
|
||||||
def replace(x):
|
def replace(x):
|
||||||
if x.group(1) not in self.variables:
|
print(x.group(1))
|
||||||
|
if x.group(1).startswith('itemmeta:'):
|
||||||
|
return op.item.meta_data.get(x.group(1)[9:]) or ''
|
||||||
|
elif x.group(1).startswith('meta:'):
|
||||||
|
return ev.meta_data.get(x.group(1)[5:]) or ''
|
||||||
|
elif x.group(1) not in self.variables:
|
||||||
return x.group(0)
|
return x.group(0)
|
||||||
if x.group(1) == 'secret':
|
if x.group(1) == 'secret':
|
||||||
# Do not use shortened version
|
# Do not use shortened version
|
||||||
return op.secret
|
return op.secret
|
||||||
|
|
||||||
try:
|
try:
|
||||||
return self.variables[x.group(1)]['evaluate'](op, order, ev)
|
return self.variables[x.group(1)]['evaluate'](op, order, ev)
|
||||||
except:
|
except:
|
||||||
@@ -726,7 +732,7 @@ class Renderer:
|
|||||||
|
|
||||||
# We do not use str.format like in emails so we (a) can evaluate lazily and (b) can re-implement this
|
# We do not use str.format like in emails so we (a) can evaluate lazily and (b) can re-implement this
|
||||||
# 1:1 on other platforms that render PDFs through our API (libpretixprint)
|
# 1:1 on other platforms that render PDFs through our API (libpretixprint)
|
||||||
return re.sub(r'\{([a-zA-Z0-9_]+)\}', replace, text)
|
return re.sub(r'\{([a-zA-Z0-9:_]+)\}', replace, text)
|
||||||
|
|
||||||
elif o['content'].startswith('itemmeta:'):
|
elif o['content'].startswith('itemmeta:'):
|
||||||
return op.item.meta_data.get(o['content'][9:]) or ''
|
return op.item.meta_data.get(o['content'][9:]) or ''
|
||||||
|
|||||||
Reference in New Issue
Block a user