mirror of
https://github.com/pretix/pretix.git
synced 2026-08-02 09:27:50 +00:00
WIP
This commit is contained in:
+2
-1
@@ -56,7 +56,8 @@ const props = defineProps<{
|
||||
/* center content */
|
||||
display: flex;
|
||||
align-items: center;
|
||||
text-align: center;
|
||||
text-align: center;
|
||||
justify-content: center;
|
||||
padding: 1em;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ def get_object_id(op: OrderPosition):
|
||||
instance_uuid = _get_instance_uuid()
|
||||
issuer_id = op.order.event.settings.get("wallet_google_issuer_id")
|
||||
|
||||
return "%s.pretix-%s-%s-%s-%s-%s" % (
|
||||
return "%s.pretix-%s-%s-%s-%s-%s-1" % (
|
||||
issuer_id,
|
||||
instance_uuid,
|
||||
op.order.event.organizer.slug,
|
||||
@@ -105,6 +105,7 @@ class GooglePlatform(WalletPlatform):
|
||||
"locales": event.settings.locales,
|
||||
"issuerName": event.organizer.name,
|
||||
"eventName": event.name,
|
||||
# TODO: use other classId and objectId in preview mode
|
||||
"classId": get_class_id(event),
|
||||
"objectId": get_object_id(op),
|
||||
"homepageUrl": eventreverse_absolute(event, "presale:event.index"),
|
||||
@@ -113,21 +114,133 @@ class GooglePlatform(WalletPlatform):
|
||||
}
|
||||
|
||||
data = layout.generate(context)
|
||||
return "pass", "text/plain", data
|
||||
return "url", "text/plain", data
|
||||
|
||||
|
||||
class GoogleWalletStyle(PassStyle):
|
||||
platform = GooglePlatform
|
||||
|
||||
@classmethod
|
||||
def _comms(cls, event: Event):
|
||||
return Comms()
|
||||
def _generate_class(self, layout: PassLayout, context, fields):
|
||||
output_class = EventTicketClass(
|
||||
context["issuerName"],
|
||||
context["classId"],
|
||||
MultipleDevicesAndHoldersAllowedStatus.multipleHolders, # TODO: Make configurable
|
||||
context["eventName"],
|
||||
ReviewStatus.underReview,
|
||||
context["locale"],
|
||||
)
|
||||
|
||||
def _generate_class(self, layout, context, fields):
|
||||
raise NotImplementedError()
|
||||
output_class.homepage_uri(
|
||||
context["homepageUrl"],
|
||||
get_translated_string("Website", context["locale"]),
|
||||
get_translated_dict("Website", context["locales"]),
|
||||
)
|
||||
# TODO: add webhook view & register in pass
|
||||
# output_class.callback_url(context['webhookUrl'])
|
||||
|
||||
def _generate_object(self, layout, context, fields):
|
||||
raise NotImplementedError()
|
||||
# TODO: move to pass settings or set defaults
|
||||
# if (event.settings.get('ticketoutput_googlepaypasses_latitude')
|
||||
# and event.settings.get('ticketoutput_googlepaypasses_longitude')):
|
||||
# output_class.locations(
|
||||
# event.settings.get('ticketoutput_googlepaypasses_latitude'),
|
||||
# event.settings.get('ticketoutput_googlepaypasses_longitude')
|
||||
# )
|
||||
# elif event.geo_lat and event.geo_lon:
|
||||
# output_class.locations(
|
||||
# event.geo_lat,
|
||||
# event.geo_lon
|
||||
# )
|
||||
|
||||
# output_class.country_code(event.settings.locale)
|
||||
|
||||
# if event.settings.get('ticketoutput_googlepaypasses_hero'):
|
||||
# output_class.hero_image(
|
||||
# urljoin(django_settings.SITE_URL, event.settings.get('ticketoutput_googlepaypasses_hero').url),
|
||||
# str(event.name),
|
||||
# event.name,
|
||||
# )
|
||||
|
||||
# output_class.hex_background_color(event.settings.get('primary_color'))
|
||||
# output_class.event_id('pretix-%s-%s-%s' % (gs.settings.get('update_check_id'), event.organizer.id, event.id))
|
||||
|
||||
# if event.settings.get('ticketoutput_googlepaypasses_logo'):
|
||||
# output_class.logo(
|
||||
# urljoin(django_settings.SITE_URL, event.settings.get('ticketoutput_googlepaypasses_logo').url),
|
||||
# str(event.name),
|
||||
# event.name,
|
||||
# )
|
||||
|
||||
# if event.location:
|
||||
# name = {}
|
||||
# address = {}
|
||||
|
||||
# for key, value in event.location.data.items():
|
||||
# lines = value.splitlines()
|
||||
# name[key] = lines[0]
|
||||
# # We must provide at least one address line each for the name and address - no way around it.
|
||||
# if len(lines) > 1:
|
||||
# address[key] = '\n'.join(value.splitlines()[1:])
|
||||
# else:
|
||||
# address[key] = lines[0]
|
||||
|
||||
# output_class.venue(name, address)
|
||||
|
||||
# if event.date_from and event.date_to and event.date_admission:
|
||||
# output_class.date_time(
|
||||
# DoorsOpen.doorsOpen,
|
||||
# event.date_admission.isoformat(),
|
||||
# event.date_from.isoformat(),
|
||||
# event.date_to.isoformat(),
|
||||
# )
|
||||
|
||||
# output_class.confirmation_code_label(ConfirmationCode.orderNumber)
|
||||
|
||||
# if event.seating_plan_id is not None:
|
||||
# output_class.seat_label(Seat.seat)
|
||||
|
||||
# return self._comms().put_item(ClassType.eventTicketClass, class_name, output_class)
|
||||
return output_class
|
||||
|
||||
def _generate_object(self, layout: PassLayout, context, fields):
|
||||
class_id = context["classId"]
|
||||
object_id = context["objectId"]
|
||||
output_object = EventTicketObject(
|
||||
object_id, class_id, ObjectState.active, context["locale"]
|
||||
)
|
||||
|
||||
# output_object.barcode(Barcode.qrCode, op.secret, op.secret)
|
||||
|
||||
# output_object.reservation_info("%s-%s" % (op.order.event.slug, op.order.code))
|
||||
# output_object.ticket_holder_name(op.attendee_name or (op.addon_to.attendee_name if op.addon_to else ''))
|
||||
# output_object.ticket_number(op.secret)
|
||||
# output_object.ticket_type(
|
||||
# get_translated_dict(
|
||||
# str(op.item) + (" – " + str(op.variation.value) if op.variation else ""),
|
||||
# op.order.event.settings.get('locales')
|
||||
# )
|
||||
# )
|
||||
|
||||
# places = django_settings.CURRENCY_PLACES.get(op.order.event.currency, 2)
|
||||
# output_object.face_value(int(op.price * 1000 ** places), op.order.event.currency)
|
||||
|
||||
# if op.order.event.seating_plan_id is not None:
|
||||
# if op.seat:
|
||||
# output_object.seat(
|
||||
# get_translated_dict(
|
||||
# _(str(op.seat)),
|
||||
# op.order.event.settings.get('locales')
|
||||
# )
|
||||
# )
|
||||
# else:
|
||||
# output_object.seat(
|
||||
# get_translated_dict(
|
||||
# _('General admission'),
|
||||
# op.order.event.settings.get('locales')
|
||||
# )
|
||||
# )
|
||||
|
||||
# return self._comms().put_item(ObjectType.eventTicketObject, object_name, output_object)
|
||||
return output_object
|
||||
|
||||
def generate(self, layout, context):
|
||||
comms = Comms(context["credentials"])
|
||||
@@ -244,99 +357,17 @@ class GoogleWalletEventTicket(GoogleWalletStyle):
|
||||
]
|
||||
]
|
||||
|
||||
def _generate_class(self, layout: PassLayout, context, fields):
|
||||
output_class = EventTicketClass(
|
||||
context["issuerName"],
|
||||
context["classId"],
|
||||
MultipleDevicesAndHoldersAllowedStatus.multipleHolders, # TODO: Make configurable
|
||||
context["eventName"],
|
||||
ReviewStatus.underReview,
|
||||
context["locale"],
|
||||
)
|
||||
|
||||
output_class.homepage_uri(
|
||||
context["homepageUrl"],
|
||||
get_translated_string("Website", context["locale"]),
|
||||
get_translated_dict("Website", context["locales"]),
|
||||
)
|
||||
# TODO: add webhook view & register in pass
|
||||
# output_class.callback_url(context['webhookUrl'])
|
||||
|
||||
# TODO: move to pass settings or set defaults
|
||||
# if (event.settings.get('ticketoutput_googlepaypasses_latitude')
|
||||
# and event.settings.get('ticketoutput_googlepaypasses_longitude')):
|
||||
# output_class.locations(
|
||||
# event.settings.get('ticketoutput_googlepaypasses_latitude'),
|
||||
# event.settings.get('ticketoutput_googlepaypasses_longitude')
|
||||
# )
|
||||
# elif event.geo_lat and event.geo_lon:
|
||||
# output_class.locations(
|
||||
# event.geo_lat,
|
||||
# event.geo_lon
|
||||
# )
|
||||
|
||||
# output_class.country_code(event.settings.locale)
|
||||
|
||||
# if event.settings.get('ticketoutput_googlepaypasses_hero'):
|
||||
# output_class.hero_image(
|
||||
# urljoin(django_settings.SITE_URL, event.settings.get('ticketoutput_googlepaypasses_hero').url),
|
||||
# str(event.name),
|
||||
# event.name,
|
||||
# )
|
||||
|
||||
# output_class.hex_background_color(event.settings.get('primary_color'))
|
||||
# output_class.event_id('pretix-%s-%s-%s' % (gs.settings.get('update_check_id'), event.organizer.id, event.id))
|
||||
|
||||
# if event.settings.get('ticketoutput_googlepaypasses_logo'):
|
||||
# output_class.logo(
|
||||
# urljoin(django_settings.SITE_URL, event.settings.get('ticketoutput_googlepaypasses_logo').url),
|
||||
# str(event.name),
|
||||
# event.name,
|
||||
# )
|
||||
|
||||
# if event.location:
|
||||
# name = {}
|
||||
# address = {}
|
||||
|
||||
# for key, value in event.location.data.items():
|
||||
# lines = value.splitlines()
|
||||
# name[key] = lines[0]
|
||||
# # We must provide at least one address line each for the name and address - no way around it.
|
||||
# if len(lines) > 1:
|
||||
# address[key] = '\n'.join(value.splitlines()[1:])
|
||||
# else:
|
||||
# address[key] = lines[0]
|
||||
|
||||
# output_class.venue(name, address)
|
||||
|
||||
# if event.date_from and event.date_to and event.date_admission:
|
||||
# output_class.date_time(
|
||||
# DoorsOpen.doorsOpen,
|
||||
# event.date_admission.isoformat(),
|
||||
# event.date_from.isoformat(),
|
||||
# event.date_to.isoformat(),
|
||||
# )
|
||||
|
||||
# output_class.confirmation_code_label(ConfirmationCode.orderNumber)
|
||||
|
||||
# if event.seating_plan_id is not None:
|
||||
# output_class.seat_label(Seat.seat)
|
||||
|
||||
# return self._comms().put_item(ClassType.eventTicketClass, class_name, output_class)
|
||||
return output_class._eventTicketClass
|
||||
|
||||
def _generate_object(self, layout: PassLayout, context, fields):
|
||||
class_id = context["classId"]
|
||||
object_id = context["objectId"]
|
||||
output_object = EventTicketObject(
|
||||
object_id, class_id, ObjectState.active, context["locale"]
|
||||
)
|
||||
output_object = super()._generate_object(layout, context, fields)
|
||||
|
||||
# output_object.barcode(Barcode.qrCode, op.secret, op.secret)
|
||||
if fields["code"]:
|
||||
output_object.barcode(Barcode.qrCode, fields["code"][0]["value"], fields["code"][0]["value"])
|
||||
|
||||
# output_object.reservation_info("%s-%s" % (op.order.event.slug, op.order.code))
|
||||
# output_object.ticket_holder_name(op.attendee_name or (op.addon_to.attendee_name if op.addon_to else ''))
|
||||
# output_object.ticket_number(op.secret)
|
||||
output_object.ticket_holder_name("Some name")
|
||||
output_object.ticket_number(fields["code"][0]["value"])
|
||||
# output_object.ticket_type(
|
||||
# get_translated_dict(
|
||||
# str(op.item) + (" – " + str(op.variation.value) if op.variation else ""),
|
||||
@@ -364,4 +395,4 @@ class GoogleWalletEventTicket(GoogleWalletStyle):
|
||||
# )
|
||||
|
||||
# return self._comms().put_item(ObjectType.eventTicketObject, object_name, output_object)
|
||||
return output_object._eventTicketObject
|
||||
return output_object
|
||||
|
||||
@@ -196,9 +196,10 @@ class LayoutPreviewView(EventPermissionRequiredMixin, View):
|
||||
fname, mimet, data = platform.generate(layout, p)
|
||||
resp = HttpResponse(data, content_type=mimet)
|
||||
ftype = fname.split(".")[-1]
|
||||
resp["Content-Disposition"] = (
|
||||
'attachment; filename="ticket-preview.{}"'.format(ftype)
|
||||
)
|
||||
if not mimet.startswith("text/"):
|
||||
resp["Content-Disposition"] = (
|
||||
'attachment; filename="ticket-preview.{}"'.format(ftype)
|
||||
)
|
||||
return resp
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user