summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2011-01-08 11:47:11 -0600
committerDan McGee <dan@archlinux.org>2011-01-08 11:47:11 -0600
commitc04d4abc88cdf0891bff2b1ce6d1d746c5b9b3c9 (patch)
tree210c401bf07a8bbd79d9b49e1f034bc04a144fb3
parent9a1971e24fe15ccdb74f3a8a59d735504f2797be (diff)
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 <dan@archlinux.org>
-rw-r--r--devel/urls.py1
-rw-r--r--devel/views.py25
-rw-r--r--templates/devel/clock.html49
3 files changed, 74 insertions, 1 deletions
diff --git a/devel/urls.py b/devel/urls.py
index 23dd2d9f..0a050a92 100644
--- a/devel/urls.py
+++ b/devel/urls.py
@@ -2,6 +2,7 @@ from django.conf.urls.defaults import patterns
urlpatterns = patterns('devel.views',
(r'^$', 'index'),
+ (r'^clock/$', 'clock'),
(r'^notify/$', 'change_notify'),
(r'^profile/$', 'change_profile'),
(r'^newuser/$', 'new_user_form'),
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 main.models import UserProfile
from packages.models import PackageRelation
from .utils import get_annotated_maintainers
+import datetime
+import pytz
import random
from string import ascii_letters, digits
@@ -38,11 +40,32 @@ 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)
notify = request.POST.get('notify', 'no')
diff --git a/templates/devel/clock.html b/templates/devel/clock.html
new file mode 100644
index 00000000..ec567c2d
--- /dev/null
+++ b/templates/devel/clock.html
@@ -0,0 +1,49 @@
+{% extends "base.html" %}
+
+{% block title %}Arch Linux - Developer World Clocks{% endblock %}
+
+{% block content %}
+<div id="dev-clocks-box" class="box">
+ <h2>Developer World Clocks</h2>
+
+ <p>This page helps prevent you from waking a sleeping developer. It also
+ depends on developers keeping the time zone information up to date, so if
+ you see 'UTC' listed, pester them to update their settings.</p>
+ <p>
+ Arch Server Time: {{ now|date:"Y-m-d H:i" }}<br/>
+ UTC Time: {{ utc_now|date:"Y-m-d H:i" }}
+ </p>
+
+ <table id="clocks-table" class="results dash-stats">
+ <thead>
+ <tr>
+ <th>Developer</th>
+ <th>Username</th>
+ <th>Location</th>
+ <th>Time Zone</th>
+ <th>Current Time</th>
+ </tr>
+ </thead>
+ <tbody>
+ {% for dev in developers %}
+ <tr class="{% cycle 'odd' 'even' %}">
+ <td>{{ dev.get_full_name }}</td>
+ <td>{{ dev.username }}</td>
+ <td>{{ dev.userprofile.location }}</td>
+ <td>{{ dev.userprofile.time_zone }}</td>
+ <td>{{ dev.current_time|date:"Y-m-d H:i" }}</td>
+ </tr>
+ {% endfor %}
+ </tbody>
+ </table>
+</div>
+{% load cdn %}{% jquery %}
+<script type="text/javascript" src="/media/jquery.tablesorter.min.js"></script>
+<script type="text/javascript" src="/media/archweb.js"></script>
+<script type="text/javascript">
+$(document).ready(function() {
+ $("#clocks-table:has(tbody tr)").tablesorter(
+ {widgets: ['zebra'], sortList: [[1,0]]});
+});
+</script>
+{% endblock %}