Exemple #1
0
    def run(self):
        #
        # if you change these, change ticket_forms in views/tickets.py as well.
        #

        data = [
            #(order, code, name, capacity, max per person, GBP, EUR, Description)
            (5, 'full', 'Full Camp Ticket', 200, 10, 95.00, 120.00, None),
            (6, 'full_supporter', 'Full Camp Ticket (Supporter)', 200, 10,
             125.00, 160.00,
             "Support this non-profit event by paying a little more. "
             "All money will go towards making EMF more awesome."),
            (10, 'kids_u16', 'Under-16 Camp Ticket', 500, 10, 40.00, 50.00,
             "For visitors born after August 28th, 1998. "
             "All under-16s  must be accompanied by an adult."),
            (15, 'kids_u5', 'Under-5 Camp Ticket', 200, 4, 0, 0,
             "For children born after August 28th, 2009. "
             "All children must be accompanied by an adult."),
            (30, 'parking', 'Parking Ticket', 200, 4, 15.00, 20.00,
             "We're trying to keep cars on-site to a minimum. "
             "Please take public transport or find someone to share with if possible."
             ),
            (35, 'campervan', 'Caravan/Campervan Ticket', 30, 1, 30.00, 40.00,
             "If you bring a caravan, you won't need a separate parking ticket for the towing car."
             ),
        ]

        types = []
        for row in data:
            tt = TicketType(*row[1:5], order=row[0], notice=row[7])
            tt.prices = [
                TicketPrice('GBP', row[5]),
                TicketPrice('EUR', row[6])
            ]
            types.append(tt)

        for tt in types:
            existing_tt = TicketType.query.get(tt.code)
            if existing_tt:
                print 'Refreshing TicketType %s' % tt.code
                for f in ['name', 'capacity', 'limit', 'order', 'notice']:
                    cur_val = getattr(existing_tt, f)
                    new_val = getattr(tt, f)
                    if cur_val != new_val:
                        print ' %10s: %r -> %r' % (f, cur_val, new_val)
                        setattr(existing_tt, f, new_val)
            else:
                print 'Adding TicketType %s' % tt.code
                db.session.add(tt)

            db.session.commit()

        print 'Tickets created'
Exemple #2
0
def get_main_ticket_types():
    #
    # Update the DB consistently without breaking existing tickets.
    #
    # Ticket prices are immutable, so to change prices, create a new type
    # with a unique id, and set the type limit for the previous one to the
    # number of guaranteed paid tickets (which might be 0).
    #
    # This is fiddly. It should probably be moved out to a json file.

    type_data = [
        # (fixed_id, order, admits, name, type limit, personal limit, GBP, EUR, badge, description, [token, expiry, transferable])
        # Leave order 0 & 1 free for discount tickets
        (12, 1, 'full', 'Full Camp Ticket (Discount Template)', 0, 1, 105.00,
         142.00, True, None, 'example', datetime(2016, 8, 1, 12, 0), False),
        (0, 2, 'full', 'Full Camp Ticket', 193, 10, 100.00, 140.00, True, None,
         None, datetime(2016, 1, 10, 20, 24), True),
        (1, 3, 'full', 'Full Camp Ticket', 350, 10, 110.00, 145.00, True, None,
         None, datetime(2016, 3, 6, 13, 5), True),
        (2, 4, 'full', 'Full Camp Ticket', 636, 10, 120.00, 158.00, True, None,
         None, datetime(2016, 6, 7, 0, 0), True),
        (3, 8, 'full', 'Full Camp Ticket (Supporter)', 56, 10, 130.00, 180.00,
         True, "Support this non-profit event by paying a bit more. "
         "All money will go towards making EMF more awesome.", None,
         datetime(2016, 6, 8, 0, 0), True),
        (9, 8, 'full', 'Full Camp Ticket (Supporter)', 1100, 10, 130.00,
         170.00, True, "Support this non-profit event by paying a bit more. "
         "All money will go towards making EMF more awesome.", None,
         datetime(2016, 6, 8, 0, 0), True),
        (4, 9, 'full', 'Full Camp Ticket (Gold Supporter)', 6, 10, 150.00,
         210.00, True, "Pay even more, receive our undying gratitude.", None,
         datetime(2016, 6, 8, 0, 0), True),
        (10, 9, 'full', 'Full Camp Ticket (Gold Supporter)', 1100, 10, 150.00,
         195.00, True, "Pay even more, receive our undying gratitude.", None,
         datetime(2016, 6, 8, 0, 0), True),
        (5, 10, 'kid', 'Under-16 Camp Ticket', 11, 10, 45.00, 64.00, True,
         "For visitors born after August 5th, 2000. "
         "All under-16s must be accompanied by an adult.", None,
         datetime(2016, 6, 8, 0, 0), True),
        (11, 10, 'kid', 'Under-16 Camp Ticket', 500, 10, 45.00, 60.00, True,
         "For visitors born after August 5th, 2000. "
         "All under-16s must be accompanied by an adult.", None,
         datetime(2016, 6, 8, 0, 0), True),
        (6, 15, 'kid', 'Under-5 Camp Ticket', 200, 4, 0, 0, False,
         "For children born after August 5th, 2011. "
         "All children must be accompanied by an adult.", None,
         datetime(2016, 6, 8, 0, 0), True),
        (13, 25, 'other', 'Tent (Template)', 0, 1, 300.00, 400.00, False,
         "Pre-ordered village tents will be placed on site before the event starts.",
         'example', datetime(2016, 7, 1, 12, 0), True),
        (14, 30, 'other', "Semi-fitted T-Shirt - S", 200, 10, 10.00, 12.00,
         False,
         "Pre-order the official Electromagnetic Field t-shirt. T-shirts will be available to collect during the event.",
         None, datetime(2016, 7, 15, 0, 0), False),
        (15, 31, 'other', "Semi-fitted T-Shirt - M", 200, 10, 10.00, 12.00,
         False, None, None, datetime(2016, 7, 15, 0, 0), False),
        (16, 32, 'other', "Semi-fitted T-Shirt - L", 200, 10, 10.00, 12.00,
         False, None, None, datetime(2016, 7, 15, 0, 0), False),
        (17, 33, 'other', "Semi-fitted T-Shirt - XL", 200, 10, 10.00, 12.00,
         False, None, None, datetime(2016, 7, 15, 0, 0), False),
        (18, 34, 'other', "Semi-fitted T-Shirt - XXL", 200, 10, 10.00, 12.00,
         False, None, None, datetime(2016, 7, 15, 0, 0), False),
        (19, 35, 'other', "Unfitted T-Shirt - S", 200, 10, 10.00, 12.00, False,
         None, None, datetime(2016, 7, 15, 0, 0), False),
        (20, 36, 'other', "Unfitted T-Shirt - M", 200, 10, 10.00, 12.00, False,
         None, None, datetime(2016, 7, 15, 0, 0), False),
        (21, 37, 'other', "Unfitted T-Shirt - L", 200, 10, 10.00, 12.00, False,
         None, None, datetime(2016, 7, 15, 0, 0), False),
        (22, 38, 'other', "Unfitted T-Shirt - XL", 200, 10, 10.00, 12.00,
         False, None, None, datetime(2016, 7, 15, 0, 0), False),
        (23, 39, 'other', "Unfitted T-Shirt - XXL", 200, 10, 10.00, 12.00,
         False, None, None, datetime(2016, 7, 15, 0, 0), False),
        (7, 50, 'car', 'Parking Ticket', 450, 4, 15.00, 21.00, False,
         "We're trying to keep cars to a minimum. "
         "Please take public transport or car-share if you can.", None, None,
         True),
        (8, 55, 'campervan', u'Caravan/\u200cCampervan Ticket', 60, 2, 30.00,
         42.00, False,
         "If you bring a caravan, you won't need a separate parking ticket for the towing car.",
         None, None, True),
    ]
    # most of these tickets have no tokens or expiry dates
    assert all([len(t) == 13 for t in type_data])

    types = []
    for row in type_data:
        tt = TicketType(*row[1:5],
                        personal_limit=row[5],
                        description=row[9],
                        has_badge=row[8],
                        discount_token=row[10],
                        expires=row[11],
                        is_transferable=row[12])
        tt.fixed_id = row[0]
        tt.prices = [TicketPrice('GBP', row[6]), TicketPrice('EUR', row[7])]
        types.append(tt)

    return types