- is_paginated = True\r
- sortby = request.GET.get('sort', 'reputation')\r
- suser = request.REQUEST.get('q', "")\r
- try:\r
- page = int(request.GET.get('page', '1'))\r
- except ValueError:\r
- page = 1\r
-\r
- if suser == "":\r
- if sortby == "newest":\r
- objects_list = Paginator(User.objects.all().order_by('-date_joined'), USERS_PAGE_SIZE)\r
- elif sortby == "last":\r
- objects_list = Paginator(User.objects.all().order_by('date_joined'), USERS_PAGE_SIZE)\r
- elif sortby == "user":\r
- objects_list = Paginator(User.objects.all().order_by('username'), USERS_PAGE_SIZE)\r
- # default\r
- else:\r
- objects_list = Paginator(User.objects.all().order_by('-reputation'), USERS_PAGE_SIZE)\r
- base_url = reverse('users') + '?sort=%s&' % sortby\r
+ suser = request.REQUEST.get('q', "")\r
+ users = User.objects.all()\r
+\r
+ if suser != "":\r
+ users = users.filter(username__icontains=suser)\r
+\r
+ return pagination.paginated(request, ('users', UserListPaginatorContext()), {\r
+ "users" : users,\r
+ "suser" : suser,\r
+ })\r
+\r
+\r
+@decorators.render('users/online_users.html', 'online_users', _('Online Users'), weight=200, tabbed=False)\r
+def online_users(request):\r
+ suser = request.REQUEST.get('q', "")\r
+\r
+ sort = ""\r
+ if request.GET.get("sort", None):\r
+ try:\r
+ sort = int(request.GET["sort"])\r
+ except ValueError:\r
+ logging.error('Found invalid sort "%s", loading %s, refered by %s' % (\r
+ request.GET.get("sort", ''), request.path, request.META.get('HTTP_REFERER', 'UNKNOWN')\r
+ ))\r
+ raise Http404()\r
+\r
+ page = 0\r
+ if request.GET.get("page", None):\r
+ try:\r
+ page = int(request.GET["page"])\r
+ except ValueError:\r
+ logging.error('Found invalid page "%s", loading %s, refered by %s' % (\r
+ request.GET.get("page", ''), request.path, request.META.get('HTTP_REFERER', 'UNKNOWN')\r
+ ))\r
+ raise Http404()\r
+\r
+ pagesize = 10\r
+ if request.GET.get("pagesize", None):\r
+ try:\r
+ pagesize = int(request.GET["pagesize"])\r
+ except ValueError:\r
+ logging.error('Found invalid pagesize "%s", loading %s, refered by %s' % (\r
+ request.GET.get("pagesize", ''), request.path, request.META.get('HTTP_REFERER', 'UNKNOWN')\r
+ ))\r
+ raise Http404()\r
+\r
+\r
+ users = None\r
+ if sort == "reputation":\r
+ users = sorted(ONLINE_USERS.sets.keys(), key=lambda user: user.reputation)\r
+ elif sort == "newest" :\r
+ users = sorted(ONLINE_USERS.sets.keys(), key=lambda user: user.newest)\r
+ elif sort == "last":\r
+ users = sorted(ONLINE_USERS.sets.keys(), key=lambda user: user.last)\r
+ elif sort == "name":\r
+ users = sorted(ONLINE_USERS.sets.keys(), key=lambda user: user.name)\r
+ elif sort == "oldest":\r
+ users = sorted(ONLINE_USERS.sets.keys(), key=lambda user: user.oldest)\r
+ elif sort == "newest":\r
+ users = sorted(ONLINE_USERS.sets.keys(), key=lambda user: user.newest)\r
+ elif sort == "votes":\r
+ users = sorted(ONLINE_USERS.sets.keys(), key=lambda user: user.votes)\r