Example #1
0
def mountaintop(request):
    # Copied from ywot.views.admin
    if not request.user.is_authenticated():
        raise Http404
    if not request.user.is_superuser:
        raise Http404

    end = datetime.date.today()
    start = end - datetime.timedelta(days=30)
    
    # Make User Chart

    base_users = User.objects.all()

    new_users = base_users.filter(created_at__gte=start).order_by('created_at')

    count_by_date = get_counts(new_users, lambda x: x.created_at.date())
    prev_total = base_users.filter(created_at__lt=start).count()
    user_data = []
    user_cum_data = []
    for day in date_range(start, end):
        user_data.append(count_by_date[day])
        prev_total += count_by_date[day]
        user_cum_data.append(prev_total)
    user_chart_url = month_graph(user_data, start, end)
    user_cum_chart_url = month_graph(user_cum_data, start, end)
        
    # Make Chats Chart
    base_rooms = Room.objects.order_by('created_at')
    new_rooms = base_rooms.filter(created_at__gte=start)
    count_by_date = get_counts(new_rooms, lambda x: x.created_at.date())
    prev_total = base_rooms.filter(created_at__lt=start).count()
    room_data = []
    room_data_cum = []
    for day in date_range(start, end):
        room_data.append(count_by_date[day])
        prev_total += count_by_date[day]
        room_data_cum.append(prev_total)
    room_chart_url = month_graph(room_data, start, end)
    room_cum_chart_url = month_graph(room_data_cum, start, end)
    
    return req_render_to_response(request, 'admin/stats.html', {
        'users': base_users.count(),
        'users_today': base_users.filter(created_at__gte=end).count(),
        'user_chart_url': user_chart_url,
        'user_cum_chart_url': user_cum_chart_url,
        'private_rooms': base_rooms.count(),
        'private_rooms_today': base_rooms.filter(created_at__gte=end).count(),
        'room_chart_url': room_chart_url,
        'room_cum_chart_url': room_cum_chart_url,
        })
Example #2
0
def index(request):
    return req_render_to_response(request, 'index.html')
Example #3
0
def spa_base(request, *args, **kwargs):
    return req_render_to_response(request, 'spa_base.html')
Example #4
0
def index(request):
    return req_render_to_response(request, 'index.html')