Пример #1
0
def event_signup(request, year, event_pk):
    event = get_object_or_404(Event, pk=event_pk)

    if not event.published:
        raise Http404

    payment_url = reverse('events_api:payment', args=[event_pk])
    signup_url = reverse('events_api:signup', args=[event_pk])

    # Will be populated if user has completed signup before
    participant = Participant.objects.filter(user_s=request.user,
                                             event=event).first()

    open_student_teams = Team.objects.filter(event=event, allow_join_s=True)

    react_props = {
        'event':
        serializers.event(event, request),
        'teams': [serializers.team(team) for team in open_student_teams],
        'payment_url':
        payment_url,
        'signup_url':
        signup_url,
        'stripe_publishable':
        settings.STRIPE_PUBLISHABLE,
        'participant':
        serializers.participant(participant) if participant else None
    }

    return render(
        request, 'events/event_signup.html', {
            'event': event,
            'participant': participant,
            'react_props': json.dumps(react_props, cls=DjangoJSONEncoder)
        })
Пример #2
0
def show(request, event_pk):
    """
    Returns a single published event
    """

    event = Event.objects.get(pk=event_pk)

    data = serializers.event(event, request)

    return JsonResponse(data, safe=False)
Пример #3
0
def index(request):
    """
    Returns all published events for this years fair
    """

    fair = Fair.objects.get(current=True)
    events = Event.objects.filter(fair=fair, published=True).prefetch_related('signupquestion_set')

    data = [serializers.event(event, request) for event in events]

    return JsonResponse(data, safe=False)