Example #1
0
 def do_tiers(self, tiers):
     for tier in tiers:
         start = datetime.strptime(tier.start, '%m/%d/%Y').date()
         end = datetime.strptime(tier.end if tier.end != 'rollover' else '12/21/2016', '%m/%d/%Y').date()
         with as_user(get_robot_user()):
             t = TicketTier.objects.filter(
                 name=tier.name,
                 ticket_type=TicketType.objects.get(pk=int(tier.ticket_type)),
                 capacity=tier.capacity,
                 price=int(tier.price),
                 start_date=start,
                 end_date=end,
             )
             self.stdout.write(str(t))
Example #2
0
    def do_addons(self, addons):
        for i, addon in enumerate(addons):
            if not addon.name:
                continue

            is_partnered = bool(addon.max_leaders or addon.max_followers)

            start = datetime.strptime(addon.start_date, '%m/%d/%Y').date()
            end = datetime.strptime(addon.end_date, '%m/%d/%Y').date()

            with as_user(get_robot_user()):
                self.stdout(
                    'name', addon.name,
                    'is_partnered', is_partnered,
                    'room', addon.room,
                    'capacity', addon.capacity or 1000,
                    'description', addon.description,
                    'price', addon.price,
                    'start_date', start,
                    'end_date', end,
                )
                addon_obj, created = TicketAddOnType.objects.get_or_create(
                    name=addon.name,
                    capacity=addon.capacity or 1000,
                    price=addon.price
                )
                addon_obj.is_partnered = is_partnered
                addon_obj.room = addon.room
                addon_obj.group = addon.category
                addon_obj.description = addon.description
                addon_obj.start_date = start
                addon_obj.end_date = end
                addon_obj.timeslots = addon.timeslots
                addon_obj.save()

            addons[i] = addon._replace(id=addon_obj.id)

        for addon in addons:
            addon_obj = TicketAddOnType.objects.get(name__iexact=addon.name)
            addon_obj.tickettypes.add(1)
            addon_obj.tickettypes.add(2)
            # addon_obj.tickettypes.add(3)  # music pass is no more

            for name in addon.cannot_be_purchased_with.split('\n'):
                if name:
                    # raises and exception if there are none or more than one
                    xor = TicketAddOnType.objects.get(name__iexact=name)
                    addon_obj.mutually_exclusive.add(xor)
Example #3
0
def userness(request, db):
    ctx = as_user(get_robot_user())
    ctx.__enter__()
    request.addfinalizer(lambda: ctx.__exit__(None, None, None))