From c04d4abc88cdf0891bff2b1ce6d1d746c5b9b3c9 Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Sat, 8 Jan 2011 11:47:11 -0600 Subject: Add developer world clocks page This should make it easier for everyone to figure out whether someone is awake, sleeping, and all that fun stuff. It does require everyone to update their profile and fill in the field, but that shouldn't be too hard of a task. Don't suggest jokes to me Saturday morning on IRC unless you really want to see them implemented. Thanks, Pierre! Signed-off-by: Dan McGee --- devel/views.py | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'devel/views.py') diff --git a/devel/views.py b/devel/views.py index 710bfff5..b26c7af0 100644 --- a/devel/views.py +++ b/devel/views.py @@ -13,6 +13,8 @@ from packages.models import PackageRelation from .utils import get_annotated_maintainers +import datetime +import pytz import random from string import ascii_letters, digits @@ -38,10 +40,31 @@ def index(request): 'maintainers': maintainers, 'flagged' : flagged, 'todopkgs' : todopkgs, - } + } return direct_to_template(request, 'devel/index.html', page_dict) +@login_required +@never_cache +def clock(request): + devs = User.objects.filter(is_active=True).order_by( + 'username').select_related('userprofile') + + # now annotate each dev object with their current time + now = datetime.datetime.now() + utc_now = datetime.datetime.utcnow().replace(tzinfo=pytz.utc) + for dev in devs: + tz = pytz.timezone(dev.userprofile.time_zone) + dev.current_time = utc_now.astimezone(tz) + + page_dict = { + 'developers': devs, + 'now': now, + 'utc_now': utc_now, + } + + return direct_to_template(request, 'devel/clock.html', page_dict) + @login_required def change_notify(request): maint = User.objects.get(username=request.user.username) -- cgit v1.2.3-54-g00ecf