예제 #1
0
def cinema(request, event_id):
    try:
        event = Event.objects.get(pk=event_id)
        event_rates = event.rates.all()
        can_rate = request.user.is_authenticated()
        rates_average = 0
        num_of_votes = len(event_rates)
        if num_of_votes:
            rates_sum = 0
            for rate in event_rates:
                rates_sum += rate.rate
                can_rate = can_rate and not (rate.user.id == request.user.id)
            rates_average = rates_sum / num_of_votes
        show_dates = []
        for i in event.show_times.all():
            added = False
            for j in show_dates:
                if i.date == j['date']:
                    j['org_id'] += '-' + str(i.organizer.id)
                    j['id'] += '-' + str(i.id)
                    added = True
            if not added:
                show_dates.append({'date': i.date, 'org_id': '' + str(i.organizer.id), 'id': '' + str(i.id)})
    except Event.DoesNotExist:
        raise Http404('cinema event does not exist!')
    return render(request, 'cinema.html', {
        'pageTitle': " - " + event.title,
        'event': event,
        'num_of_votes': num_of_votes,
        'rates_average_percent': rates_average * 20,
        'can_rate': can_rate,
        'show_dates': show_dates,
        'user': request.user,
        'comments': comments(event_id)
    })
예제 #2
0
def music(request, event_id):
    try:
        event = Event.objects.get(pk=event_id)
        event_rates = event.rates.all()
        can_rate = request.user.is_authenticated()
        rates_average = 0
        num_of_votes = len(event_rates)
        if num_of_votes:
            rates_sum = 0
            for rate in event_rates:
                rates_sum += rate.rate
                can_rate = can_rate and not (rate.user.id == request.user.id)
            rates_average = rates_sum / num_of_votes
        event_organizer = event.event_organizers.all()[0]
        return render(request, 'music.html', {
            'pageTitle': " - " + event.title,
            'event': event,
            'organizer': event_organizer,
            'show_time': event.show_times.all()[0],
            'price': event.position_prices.all()[0].price,
            'num_of_votes': num_of_votes,
            'rates_average_percent': rates_average * 20,
            'can_rate': can_rate,
            'comments': comments(event_id)
        })
    except Event.DoesNotExist:
        return Http404('event not found!')
예제 #3
0
def sport(request, event_id):
    try:
        event = Event.objects.get(pk=event_id)
        show_time = event.show_times.all()[0]
        event_date_time = datetime.datetime.combine(show_time.date, show_time.from_time)
    except Event.DoesNotExist:
        raise Http404("sport event does not exist!")
    return render(request, 'sport.html', {
        'pageTitle': " - " + event.title,
        'event': event,
        'show_time': show_time,
        'remaining_time': int((event_date_time - datetime.datetime.now()).total_seconds() * 1000),
        'organizer': event.event_organizers.all()[0],
        'price': event.position_prices.all()[0],
        'user': request.user,
        'comments': comments(event_id)
    })