Beispiel #1
0
def online(request, page=0):
    queryset = get_online_queryset(request.user).order_by('user__slug')
    queryset = queryset.select_related('user__rank')

    template = "misago/userslists/online.html"
    return list_view(request, template, queryset, page, {
        'data_from': timezone.now()
    })
Beispiel #2
0
def online(request, page=0):
    queryset = get_online_queryset(request.user).order_by("user__slug")
    queryset = queryset.select_related("user__rank")

    template = "misago/userslists/online.html"
    try:
        return list_view(request, template, queryset, page, {"data_from": timezone.now()})
    except Http404:
        return redirect("misago:users_online")
Beispiel #3
0
def real_online(request):
    queryset = get_online_queryset(request.user).order_by('last_click')
    queryset = queryset[:settings.MISAGO_ONLINE_LIST_SIZE]

    users_online = []
    for result in queryset:
        result.user.last_click = result.last_click
        users_online.append(result.user)

    return {'results': OnlineUserSerializer(users_online, many=True).data}
Beispiel #4
0
def real_online(request):
    queryset = get_online_queryset(request.user).order_by('last_click')
    queryset = queryset[:settings.MISAGO_ONLINE_LIST_SIZE]

    users_online = []
    for result in queryset:
        result.user.last_click = result.last_click
        users_online.append(result.user)

    return {'results': OnlineUserSerializer(users_online, many=True).data}
Beispiel #5
0
def online(request, page=0):
    queryset = get_online_queryset(request.user).order_by('user__slug')
    queryset = queryset.select_related('user__rank')

    template = "misago/userslists/online.html"
    try:
        return list_view(request, template, queryset, page,
                         {'data_from': timezone.now()})
    except Http404:
        return redirect('misago:users_online')
Beispiel #6
0
def get_ranks_from_db(include_viewer):
    displayed_ranks = []

    ranks_dict = {}
    for rank in Rank.objects.filter(is_on_index=True).order_by('order'):
        ranks_dict[rank.pk] = {
            'id': rank.id,
            'pk': rank.pk,
            'name': rank.name,
            'slug': rank.slug,
            'description': rank.description,
            'title': rank.title,
            'css_class': rank.css_class,
            'has_ninjas': False,
            'online': []
        }
        displayed_ranks.append(ranks_dict[rank.pk])

    queryset = get_online_queryset().filter(is_visible_on_index=True)
    for tracker in queryset.iterator():
        if tracker.user.rank_id in ranks_dict:
            ranks_dict[tracker.user.rank_id]['online'].append({
                'id': tracker.user.id,
                'pk': tracker.user.pk,
                'username': tracker.user.username,
                'slug': tracker.user.slug,
                'title': tracker.user.title,
                'is_hiding_presence': tracker.user.is_hiding_presence
            })

            if tracker.user.is_hiding_presence:
                ranks_dict[tracker.user.rank_id]['has_ninjas'] = True

    if include_viewer and include_viewer.rank_id in ranks_dict:
        viewer_rank = ranks_dict[include_viewer.rank_id]
        if include_viewer.is_hiding_presence:
            viewer_rank['has_ninjas'] = True
        for online in viewer_rank['online']:
            if online['pk'] == include_viewer.pk:
                break
        else:
            viewer_rank['online'].append({
                'id': include_viewer.id,
                'pk': include_viewer.pk,
                'username': include_viewer.username,
                'slug': include_viewer.slug,
                'title': include_viewer.title,
                'is_hiding_presence': include_viewer.is_hiding_presence
            })

    ranks_online = []
    for rank in displayed_ranks:
        if rank['online']:
            ranks_online.append(rank)
    return ranks_online