mirror of
https://github.com/pretix/pretix.git
synced 2026-10-02 19:24:42 +00:00
bugfixes, start moving wallet to core
This commit is contained in:
@@ -4,7 +4,7 @@ from i18nfield.strings import LazyI18nString
|
||||
import jsonschema
|
||||
from django.core.exceptions import ValidationError
|
||||
from pretix.base.models import OrderPosition
|
||||
from ..placeholders import WalletPlaceholderRenderer, get_available_context, get_wallet_placeholder_renderer, get_wallet_placeholders
|
||||
from ...plugins.wallet.placeholders import WalletPlaceholderRenderer, get_available_context, get_wallet_placeholder_renderer, get_wallet_placeholders
|
||||
from django import forms
|
||||
from pretix.api.helpers import handle_file_upload
|
||||
from django.core.files import File
|
||||
@@ -374,7 +374,7 @@ class PassStyle:
|
||||
|
||||
return None, None
|
||||
|
||||
def __init__(self, event, layout, file_settings: dict[str, File] | None = None):
|
||||
def __init__(self, event, layout = None, file_settings: dict[str, File] | None = None):
|
||||
self.event = event
|
||||
self.layout = layout
|
||||
self.file_settings = file_settings or {}
|
||||
@@ -401,6 +401,9 @@ class PassStyle:
|
||||
return res
|
||||
|
||||
def get_pass_fields(self, op: OrderPosition):
|
||||
if not self.layout:
|
||||
raise ValueError("`value` needs to be set")
|
||||
|
||||
context = get_wallet_placeholder_renderer(order_position=op)
|
||||
|
||||
fields = {}
|
||||
@@ -448,6 +451,9 @@ class PassStyle:
|
||||
return fields
|
||||
|
||||
def group_is_active(self, identifier: str):
|
||||
if not self.layout:
|
||||
raise ValueError("`value` needs to be set")
|
||||
|
||||
return self.layout["fieldgroups"].get(identifier, {}).get("active", False)
|
||||
|
||||
def generate(self, op: OrderPosition):
|
||||
@@ -70,7 +70,7 @@ class WalletPlatformLayout(LoggedModel):
|
||||
|
||||
style = get_style(self.platform, self.style)
|
||||
if style:
|
||||
file_settings = dict(self.file_settings.values_list("key", "file"))
|
||||
file_settings = {fs.key: fs.file for fs in self.file_settings.all()}
|
||||
return style(event=self.parent.event, layout=self.layout, file_settings=file_settings)
|
||||
else:
|
||||
raise RuntimeError(f"Style {self.platform}.{self.style} not found")
|
||||
@@ -94,4 +94,9 @@ class WalletLayoutFileSetting(models.Model):
|
||||
# platform_layout = models.ForeignKey(WalletPlatformLayout, on_delete=models.PROTECT)
|
||||
# order_position = models.ForeignKey(OrderPosition, on_delete=models.PROTECT)
|
||||
# content = models.BinaryField()
|
||||
# updated_at = models.DateTimeField(null=True, auto_now=True)
|
||||
# updated_at = models.DateTimeField(null=True, auto_now=True)
|
||||
# prob smth like this
|
||||
# class GoogleWalletObject(models.Model):
|
||||
# type = models.CharField(choices=["CLASS", "OBJECT"])
|
||||
# identifier = models.CharField()
|
||||
# data = models.JSONField()
|
||||
@@ -71,7 +71,7 @@ class WalletOutput(BaseTicketOutput):
|
||||
platform_layout = get_object_or_404(
|
||||
wallet_layout.platform_layouts, platform=self.platform.identifier
|
||||
)
|
||||
return self.platform.generate(platform_layout.pass_layout, op)
|
||||
return platform_layout.pass_layout.generate(op)
|
||||
|
||||
|
||||
class GoogleWalletTicketOutput(WalletOutput):
|
||||
|
||||
Reference in New Issue
Block a user