diff --git a/src/pretix/plugins/wallet/styles/base.py b/src/pretix/base/wallet/base.py similarity index 97% rename from src/pretix/plugins/wallet/styles/base.py rename to src/pretix/base/wallet/base.py index ea0670f365..0be23dc1fc 100644 --- a/src/pretix/plugins/wallet/styles/base.py +++ b/src/pretix/base/wallet/base.py @@ -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): diff --git a/src/pretix/plugins/wallet/models.py b/src/pretix/plugins/wallet/models.py index f7a42df202..678c3c3939 100644 --- a/src/pretix/plugins/wallet/models.py +++ b/src/pretix/plugins/wallet/models.py @@ -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) \ No newline at end of file +# 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() \ No newline at end of file diff --git a/src/pretix/plugins/wallet/ticketoutput.py b/src/pretix/plugins/wallet/ticketoutput.py index 15a600db52..790c048a6c 100644 --- a/src/pretix/plugins/wallet/ticketoutput.py +++ b/src/pretix/plugins/wallet/ticketoutput.py @@ -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):