- "keywords" : suser,\r
- "tab_id" : sortby,\r
- "context" : {\r
- 'is_paginated' : is_paginated,\r
- 'pages': objects_list.num_pages,\r
- 'page': page,\r
- 'has_previous': users.has_previous(),\r
- 'has_next': users.has_next(),\r
- 'previous': users.previous_page_number(),\r
- 'next': users.next_page_number(),\r
- 'base_url' : base_url\r
- }\r
- }\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