Web-based check-in interface (#1985)

This commit is contained in:
Raphael Michel
2021-03-30 09:34:11 +02:00
committed by GitHub
parent b06cded172
commit 92a50cb2d1
56 changed files with 3578 additions and 58 deletions

View File

@@ -0,0 +1,42 @@
import os
import re
import shlex
from compressor.exceptions import FilterError
from compressor.filters import CompilerFilter
from django.conf import settings
class VueCompiler(CompilerFilter):
# Based on work (c) Laura Klünder in https://github.com/codingcatgirl/django-vue-rollup
# Released under Apache License 2.0
def __init__(self, content, attrs, **kwargs):
config_dir = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), 'static', 'npm_dir')
node_path = os.path.join(settings.STATIC_ROOT, 'node_prefix', 'node_modules')
self.rollup_bin = os.path.join(node_path, 'rollup', 'dist', 'bin', 'rollup')
rollup_config = os.path.join(config_dir, 'rollup.config.js')
if not os.path.exists(self.rollup_bin) and not settings.DEBUG:
raise FilterError("Rollup not installed or pretix not built properly, please run 'make npminstall' in source root.")
command = (
' '.join((
'NODE_PATH=' + shlex.quote(node_path),
shlex.quote(self.rollup_bin),
'-c',
shlex.quote(rollup_config))
) +
' --input {infile} -n {export_name} --file {outfile}'
)
super().__init__(content, command=command, **kwargs)
def input(self, **kwargs):
if self.filename is None:
raise FilterError('VueCompiler can only compile files, not inline code.')
if not os.path.exists(self.rollup_bin):
raise FilterError("Rollup not installed, please run 'make npminstall' in source root.")
self.options += (('export_name', re.sub(
r'^([a-z])|[^a-z0-9A-Z]+([a-zA-Z0-9])?',
lambda s: s.group(0)[-1].upper(),
os.path.basename(self.filename).split('.')[0]
)),)
return super().input(**kwargs)

View File

@@ -0,0 +1,59 @@
import logging
from datetime import timedelta
from django.db.models import Func, Value
logger = logging.getLogger(__name__)
class Equal(Func):
arg_joiner = ' = '
arity = 2
function = ''
class GreaterThan(Func):
arg_joiner = ' > '
arity = 2
function = ''
class GreaterEqualThan(Func):
arg_joiner = ' >= '
arity = 2
function = ''
class LowerEqualThan(Func):
arg_joiner = ' < '
arity = 2
function = ''
class LowerThan(Func):
arg_joiner = ' < '
arity = 2
function = ''
class InList(Func):
arity = 2
def as_sql(self, compiler, connection, function=None, template=None, arg_joiner=None, **extra_context):
connection.ops.check_expression_support(self)
# This ignores the special case for databases which limit the number of
# elements which can appear in an 'IN' clause, which hopefully is only Oracle.
lhs, lhs_params = compiler.compile(self.source_expressions[0])
if not isinstance(self.source_expressions[1], Value) and not isinstance(self.source_expressions[1].value, (list, tuple)):
raise TypeError(f'Dynamic right-hand-site currently not implemented, found {type(self.source_expressions[1])}')
rhs, rhs_params = ['%s' for _ in self.source_expressions[1].value], [d for d in self.source_expressions[1].value]
return '%s IN (%s)' % (lhs, ', '.join(rhs)), lhs_params + rhs_params
def tolerance(b, tol=None, sign=1):
if tol:
return b + timedelta(minutes=sign * float(tol))
return b