Ejemplo n.º 1
0
def make_passbook_file(args={}):
	cardInfo = EventTicket()
	cardInfo.addPrimaryField('eventName', args['ticket'], 'Ticket')
	cardInfo.addSecondaryField('doorsOpen', args['from'], 'From')
	cardInfo.addSecondaryField('doorsClose', args['to'], 'To')

	passfile = Pass(cardInfo, passTypeIdentifier=args['identifier'], organizationName=args['organisation'], teamIdentifier=args['teamidentifier'])

	passfile.description = args['desc']
	passfile.backgroundColor = args['bgcolor']
	passfile.foregroundColor = args['fgcolor']
	passfile.logoText = args['logotext']
	passfile.serialNumber = args['uuid']
	passfile.barcode = Barcode(message=args['uuid'], format=BarcodeFormat.QR)
	passfile.barcode.altText = args['uuid'][:13]

	loc = Location(args['lat'], args['long'])
	passfile.locations = [loc,]
	passfile.relevantDate = args['relevant_date']

	passfile.addFile('icon.png', open('%s/icon.png' % args['filespath'], 'r'))
	passfile.addFile('logo.png', open('%s/logo.png' % args['filespath'], 'r'))
	passfile.addFile('*****@*****.**', open('%s/[email protected]' % args['filespath'], 'r'))
	passfile.addFile('background.png', open('%s/background.png' % args['filespath'], 'r'))
	passfile.addFile('*****@*****.**', open('%s/[email protected]' % args['filespath'], 'r'))

	return passfile.create('%s/certificate.pem' % args['filespath'], '%s/key.pem' % args['filespath'], '%s/wwdr.pem' % args['filespath'], args['password'])
Ejemplo n.º 2
0
def create_apple_pass(user):
    card_info = EventTicket()
    header_field = Field('date', 'Oct 7-9', 'MASONIC TEMPLE')
    header_field.textAlignment = Alignment.RIGHT
    card_info.headerFields.append(header_field)
    card_info.addPrimaryField('name', user.get_full_name(), 'HACKER')
    card_info.addBackField('name', user.get_full_name(), 'NAME')
    card_info.addBackField('email', user.email, 'EMAIL')

    app = user.application_or_none()

    school_name = user.cleaned_school_name(app)
    card_info.addSecondaryField('school', school_name, 'SCHOOL')
    card_info.addBackField('school', school_name, 'SCHOOL')

    if app:
        if app.user_is_minor():
            card_info.addAuxiliaryField('minor', 'YES', 'MINOR')
            card_info.addBackField('minor', 'YES', 'MINOR')

    registration = user.registration_or_none()
    if registration:
        card_info.addBackField('tshirt', registration.t_shirt_size, 'T-SHIRT SIZE')
        card_info.addBackField('dietary', registration.dietary_restrictions if registration.dietary_restrictions else 'None', 'DIETARY RESTRICTIONS')

    pass_file = Pass(card_info, passTypeIdentifier='pass.com.MPowered.MHacks.UserPass',
                     organizationName='MHacks', teamIdentifier='478C74MJ7T')
    pass_file.description = 'MHacks Ticket'
    pass_file.serialNumber = str(user.pk)
    pass_file.barcode = Barcode(message=user.email, format=BarcodeFormat.QR)
    pass_file.backgroundColor = 'rgb(0, 188, 212)'
    pass_file.foregroundColor = 'rgb(250, 250, 250)'
    pass_file.labelColor = 'rgba(0, 0, 0, 0.6)'
    pass_file.associatedStoreIdentifiers = [955659359]

    pass_file.locations = [{'longitude': 42.3415958, 'latitude': -83.0606906},
                           {'longitude': 42.3420320, 'latitude': -83.0596780},
                           {'longitude': 42.3415800, 'latitude': -83.0607620}]
    i_beacon = IBeacon('5759985C-B037-43B4-939D-D6286CE9C941', 0, 0)
    i_beacon.relevantText = 'You are near a scanner.'
    pass_file.ibeacons = [i_beacon]

    # Including the icon is necessary for the passbook to be valid.
    pass_file.addFile('icon.png', open(STATICFILES_DIRS[0] + '/assets/app_icon.png', 'r'))
    pass_file.addFile('*****@*****.**', open(STATICFILES_DIRS[0] + '/assets/app_icon.png', 'r'))
    pass_file.addFile('*****@*****.**', open(STATICFILES_DIRS[0] + '/assets/app_icon.png', 'r'))
    pass_file.addFile('logo.png', open(STATICFILES_DIRS[0] + '/assets/apple_pass_logo.png', 'r'))
    pass_file.addFile('*****@*****.**', open(STATICFILES_DIRS[0] + '/assets/apple_pass_logo.png', 'r'))
    pass_file.addFile('*****@*****.**', open(STATICFILES_DIRS[0] + '/assets/apple_pass_logo.png', 'r'))

    # Create and return the Passbook file (.pkpass)
    return pass_file.create('config/apple_wallet_certificate.pem',
                            'config/apple_wallet_key.pem',
                            'config/apple_wallet_wwdr.pem',
                            APPLE_WALLET_PASSPHRASE)
Ejemplo n.º 3
0

organizationName = 'InterSystems'
passTypeIdentifier = 'pass.com.intersystems.trakcare.apptPassDemo'
teamIdentifier = '5HLUDG9M34'

passfile = Pass(cardInfo, \
    passTypeIdentifier=passTypeIdentifier, \
    organizationName=organizationName, \
    teamIdentifier=teamIdentifier)
passfile.description = "This is the appointment pass powered by InterSystems"
passfile.backgroundColor='#87CEFA'
passfile.foregroundColor='#000000'
passfile.labelColor='#000000'
#passfile.stripColor='#000000'
passfile.logoText= 'InterSystems'
passfile.serialNumber = '1234567'
passfile.barcode = Barcode(message = Globalmrn ,format=BarcodeFormat.PDF417)
passfile.locations = []
location = Location(-12.3559002,130.8807508)
passfile.locations.append(location)

# Including the icon and logo is necessary for the passbook to be valid.
passfile.addFile('icon.png', open('/irisdev/app/apple/test.pass/icon.png', 'rb'))
passfile.addFile('logo.png', open('/irisdev/app/apple/test.pass/logo.png', 'rb'))
#passfile.addFile('background.png', open('/irisdev/app/apple/test.pass/background.png', 'rb'))

# Create and output the Passbook file (.pkpass)
password = '******'
passfile.create('/irisdev/app/apple/certs/certificate.pem', '/irisdev/app/apple/certs/private.key', '/irisdev/app/apple/certs/wwdr.pem', password , 'apple.pkpass')