示例#1
0
def reserve_ticket(user, request_data):
    if 'is_public' and 'event_id' not in request_data:
        return False
    event = SponsoredEvent.objects.get(pk=int(request_data['event_id']))
    is_public = bool(int(request_data['is_public']))
    tip = get_tip_from_request(request_data)
    event_status = get_event_status_and_check_to_charge_user(user, event, EVENT_STATUS.GOING, is_public, tip)

    if event_status:
        user_contacts = get_all_filtered_contacts_for_user(user)
        all_event_statuses = EventStatus.objects.filter(event=event, status=EVENT_STATUS.GOING).distinct('user')
        event_statuses = EventStatus.objects.filter(user__in=user_contacts, event=event, status=EVENT_STATUS.GOING).distinct('user')
        event.social_message = get_social_message(user, event, user_contacts, event_statuses)
        event.status_message = get_status_message(user, event, all_event_statuses, True)
        event.is_sold_out = is_event_sold_out(all_event_statuses)
        event.event_status = event_status
        event.place.photos = get_photos_for_venue(event.place)
        event = add_presale_property(event)
        send_app_order_confirmation(event_status)

        if is_public:
            notify_friends_of_user_for_event.delay(event_status)
    else:
        event = False

    return event
示例#2
0
def toggle_interested(user, request_data):
    if 'event_id' not in request_data:
        return False
    event = SponsoredEvent.objects.get(pk=int(request_data['event_id']))
    event_status = get_event_status_and_check_to_charge_user(user, event, EVENT_STATUS.INTERESTED)

    user_contacts = get_all_filtered_contacts_for_user(user)
    all_event_statuses = EventStatus.objects.filter(event=event, status=EVENT_STATUS.GOING).distinct('user')
    event_statuses = EventStatus.objects.filter(user__in=user_contacts, event=event, status=EVENT_STATUS.GOING).distinct('user')
    event.social_message = get_social_message(user, event, user_contacts, event_statuses)
    event.status_message = get_status_message(user, event, all_event_statuses, True)
    event.is_sold_out = is_event_sold_out(all_event_statuses)
    event.event_status = event_status
    event.place.photos = get_photos_for_venue(event.place)
    event = add_presale_property(event)

    return event
示例#3
0
def get_event(user, event_id):
    sponsored_event = SponsoredEvent.objects.get(pk=event_id)
    # user_event_statuses = EventStatus.objects.filter(user=user, status=EVENT_STATUS.GOING)
    user_contacts = get_all_filtered_contacts_for_user(user)
    all_event_statuses = EventStatus.objects.filter(event=sponsored_event, status=EVENT_STATUS.GOING).distinct('user')
    event_statuses = EventStatus.objects.filter(user__in=user_contacts, event=sponsored_event, status=EVENT_STATUS.GOING).distinct('user')
    if EventStatus.objects.filter(event=sponsored_event, user=user).exists():
        event_status = EventStatus.objects.filter(event=sponsored_event, user=user)[0]
        sponsored_event.event_status = event_status
    else:
        sponsored_event.event_status = None
    sponsored_event.status_message = get_status_message(user, sponsored_event, all_event_statuses, True)
    sponsored_event.social_message = get_social_message(user, sponsored_event, user_contacts, event_statuses)
    sponsored_event.is_sold_out = is_event_sold_out(all_event_statuses)
    sponsored_event.place.photos = get_photos_for_venue(sponsored_event.place)
    sponsored_event = add_presale_property(sponsored_event)
    return sponsored_event
示例#4
0
def redeem_ticket(user, request_data):
    event_status_id = int(request_data['event_status_id'])
    event_status = EventStatus.objects.get(pk=event_status_id)
    event_status.status = EVENT_STATUS.REDEEMED
    event_status.save()
    event = event_status.event

    user_contacts = get_all_filtered_contacts_for_user(user)
    all_event_statuses = EventStatus.objects.filter(event=event, status=EVENT_STATUS.GOING).distinct('user')
    event_statuses = EventStatus.objects.filter(user__in=user_contacts, event=event, status=EVENT_STATUS.GOING).distinct('user')
    event.social_message = get_social_message(user, event, user_contacts, event_statuses)
    event.status_message = get_status_message(user, event, all_event_statuses, True)
    event.is_sold_out = is_event_sold_out(all_event_statuses)
    event.place.photos = get_photos_for_venue(event.place)
    event.event_status = event_status
    event = add_presale_property(event)

    return event
示例#5
0
def add_extra_properties_to_sponsored_events(user, sponsored_events):
    user_event_statuses = EventStatus.objects.filter(user=user, status=EVENT_STATUS.GOING)
    user_contacts = get_all_filtered_contacts_for_user(user)
    for sponsored_event in sponsored_events:
        friend_event_statuses = EventStatus.objects.filter(user__in=user_contacts, event=sponsored_event, status=EVENT_STATUS.GOING).distinct('user')
        all_event_statuses = EventStatus.objects.filter(event=sponsored_event, status=EVENT_STATUS.GOING).distinct('user')
        if EventStatus.objects.filter(user=user, event=sponsored_event, refund_authorization__isnull=True).exists():
            user_event_status = EventStatus.objects.filter(user=user, event=sponsored_event, refund_authorization__isnull=True)[0]
            sponsored_event.event_status = user_event_status
            sponsored_event.status_message = get_status_message(user, sponsored_event, all_event_statuses, True)
        else:
            sponsored_event.event_status = None
            sponsored_event.status_message = get_status_message(user, sponsored_event, all_event_statuses, False)

        sponsored_event.place.photos = get_photos_for_venue(sponsored_event.place)
        sponsored_event.is_sold_out = is_event_sold_out(all_event_statuses)
        sponsored_event.social_message = get_social_message(user, sponsored_event, user_contacts, friend_event_statuses)
        sponsored_event = add_presale_property(sponsored_event)

    return sponsored_events