Skip to content

Commit 265e343

Browse files
committed
Fix passbook dependency for deployment
- Updated base.txt to use devartis/passbook fork for better compatibility - Added fallback mechanism in AppleTicket.py to handle missing passbook gracefully - Prevents deployment failures due to missing passbook module - Apple Wallet functionality will raise informative error if dependency unavailable
1 parent 46bafe4 commit 265e343

2 files changed

Lines changed: 49 additions & 10 deletions

File tree

apps/root/ticketing/AppleTicket.py

Lines changed: 48 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,54 @@
11
from typing import Optional
22

33
from django.conf import settings
4-
from passbook.models import (
5-
Alignment,
6-
Barcode,
7-
BarcodeFormat,
8-
EventTicket,
9-
Field,
10-
Location,
11-
Pass,
12-
)
134
import requests
145
import tempfile
156

7+
try:
8+
from passbook.models import (
9+
Alignment,
10+
Barcode,
11+
BarcodeFormat,
12+
EventTicket,
13+
Field,
14+
Location,
15+
Pass,
16+
)
17+
PASSBOOK_AVAILABLE = True
18+
except ImportError:
19+
# If passbook is not available, create dummy classes to prevent import errors
20+
PASSBOOK_AVAILABLE = False
21+
22+
class Alignment:
23+
RIGHT = "right"
24+
25+
class BarcodeFormat:
26+
QR = "QR"
27+
28+
class EventTicket:
29+
def __init__(self):
30+
self.headerFields = []
31+
def addPrimaryField(self, *args): pass
32+
def addSecondaryField(self, *args): pass
33+
def addAuxiliaryField(self, *args): pass
34+
def addBackField(self, *args): pass
35+
36+
class Field:
37+
def __init__(self, *args): pass
38+
39+
class Location:
40+
def __init__(self, *args): pass
41+
42+
class Barcode:
43+
def __init__(self, *args): pass
44+
45+
class Pass:
46+
def __init__(self, *args, **kwargs): pass
47+
def addFile(self, *args): pass
48+
def create(self, *args): pass
49+
def writetofile(self, *args): pass
50+
def read(self): return b""
51+
1652

1753
class AppleTicket:
1854
"""
@@ -101,6 +137,9 @@ def set_icon(self, path):
101137
self.icon = path
102138

103139
def generate_pass(self) -> Pass:
140+
if not PASSBOOK_AVAILABLE:
141+
raise Exception("Apple Wallet functionality is not available. Please install the passbook dependency.")
142+
104143
# creates passfile object
105144
self.passfile = Pass(
106145
passInformation=self.event_info,

config/requirements/base.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ PyJWT==2.9.0 #https://github.com/jpadilla/pyjwt
1313

1414
# Django
1515
# ------------------------------------------------------------------------------
16-
# git+https://github.com/SocialPass/passbook.git@7a3614e974c1862a24e7b02ced11313c8320c14b # Commented out for Mac M1 compatibility
16+
git+https://github.com/devartis/passbook.git # Using devartis fork for better compatibility
1717
crispy-bootstrap5==2024.2 # https://github.com/django-crispy-forms/crispy-bootstrap5/stargazers
1818
django==5.1 # https://www.djangoproject.com/
1919
django-allauth==64.0.0 # https://github.com/pennersr/django-allauth

0 commit comments

Comments
 (0)