+ 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
+ else:\r
+ users = sorted(ONLINE_USERS.iteritems(), key=lambda x: x[1])\r
+\r
+ return render_to_response('users/online_users.html', {\r
+ "users" : users,\r
+ "suser" : suser,\r
+ "sort" : sort,\r
+ "page" : page,\r
+ "pageSize" : pagesize,\r
+ })\r