Example #1
0
def view_bets(request):
    completed_matches = Match.objects.filter(paid_out=True)
    completed_bets = Bet.objects.filter(match__in=completed_matches, user=request.user).order_by('-match__date')
    pending_matches = Match.objects.filter(paid_out=False)
    pending_bets = Bet.objects.filter(match__in=pending_matches, user=request.user).order_by('match__date')
    for bet in pending_bets:
        bet.locked = bet.match.date <= scrape.get_current_date()
    return render(request, 'view_bets.html', {
        'completed_bets': completed_bets,
        'pending_bets': pending_bets,
    })
Example #2
0
def upcoming_matches(request):
    upcoming_matches = Match.objects.filter(date__lt=(scrape.get_current_date() + datetime.timedelta(days=7)), date__gt=(scrape.get_current_date())).order_by('date')
    upcoming_matches = upcoming_matches[:20]
    for upcoming_match in upcoming_matches:
        if not upcoming_match.has_rating():
            scrape.set_prediction(upcoming_match)
        if request.user.is_authenticated():
            bet = Bet.objects.filter(user=request.user, match=upcoming_match)
            if bet.exists():
                upcoming_match.current_users_bet = bet.first()
    return render(request, 'upcoming_matches.html', {
        'upcoming_matches': upcoming_matches
    })
Example #3
0
def flush_users(request):
    if request.user.is_authenticated() and request.user.is_staff:
        User.objects.filter(is_staff=False).delete()

        matches = Match.objects.filter(date__lte=(scrape.get_current_date()) + datetime.timedelta(days=2),date__gte=(scrape.get_current_date() - datetime.timedelta(days=2)))
        for match in matches:
            match.team1_score = None
            match.team2_score = None
            match.paid_out = False
            match.save()

        Bet.objects.all().delete()

        users = User.objects.all()
        for user in users:
            user.profile.balance = 10000000000
            user.profile.save()

        scrape.update_day_forward(False)

        scrape.generate_historical_predictions()
        return redirect('admin:index')
    return HttpResponseForbidden()
Example #4
0
def match_history(request):
    return render(request, 'match_history.html', {
        'past_matches': Match.objects.filter(date__lte=scrape.get_current_date()).order_by('-date'),
    })