summaryrefslogtreecommitdiff
path: root/devel/views.py
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2012-03-23 20:19:34 -0500
committerDan McGee <dan@archlinux.org>2012-03-23 20:19:34 -0500
commit822898e57bc6d4e008ef58da309857e9ef8c98e6 (patch)
tree1af0836c927b87e2249628d47cdfefe77c3b18fd /devel/views.py
parentea87160c397fe1daf63851f0ed0be146bea79196 (diff)
parent8e10699d53281be53c88a3695de6aa496e084dc6 (diff)
Merge branch 'django14'
Conflicts: templates/releng/result_section.html
Diffstat (limited to 'devel/views.py')
-rw-r--r--devel/views.py33
1 files changed, 13 insertions, 20 deletions
diff --git a/devel/views.py b/devel/views.py
index 328d52e4..3a9be757 100644
--- a/devel/views.py
+++ b/devel/views.py
@@ -1,3 +1,10 @@
+from datetime import datetime, timedelta
+import operator
+import pytz
+import random
+from string import ascii_letters, digits
+import time
+
from django import forms
from django.http import HttpResponseRedirect
from django.contrib.auth.decorators import \
@@ -16,19 +23,13 @@ from django.views.generic.simple import direct_to_template
from django.utils.http import http_date
from main.models import Package, PackageDepend, PackageFile, TodolistPkg
-from main.models import Arch, Repo
-from main.models import UserProfile
+from main.models import Arch, Repo, UserProfile
+from main.utils import utc_now
from packages.models import PackageRelation
from packages.utils import get_signoff_groups
from todolists.utils import get_annotated_todolists
from .utils import get_annotated_maintainers
-from datetime import datetime, timedelta
-import operator
-import pytz
-import random
-from string import ascii_letters, digits
-import time
@login_required
def index(request):
@@ -85,22 +86,14 @@ def clock(request):
devs = User.objects.filter(is_active=True).order_by(
'first_name', 'last_name').select_related('userprofile')
- now = datetime.now()
- utc_now = datetime.utcnow().replace(tzinfo=pytz.utc)
- # now annotate each dev object with their current time
- for dev in devs:
- tz = pytz.timezone(dev.userprofile.time_zone)
- dev.current_time = utc_now.astimezone(tz)
-
+ now = utc_now()
page_dict = {
'developers': devs,
- 'now': now,
- 'utc_now': utc_now,
+ 'utc_now': now,
}
response = direct_to_template(request, 'devel/clock.html', page_dict)
if not response.has_header('Expires'):
- # why this works only with the non-UTC date I have no idea...
expire_time = now.replace(second=0, microsecond=0)
expire_time += timedelta(minutes=1)
expire_time = time.mktime(expire_time.timetuple())
@@ -168,12 +161,12 @@ def report(request, report_name, username=None):
if report_name == 'old':
title = 'Packages last built more than two years ago'
- cutoff = datetime.utcnow() - timedelta(days=365 * 2)
+ cutoff = utc_now() - timedelta(days=365 * 2)
packages = packages.filter(
build_date__lt=cutoff).order_by('build_date')
elif report_name == 'long-out-of-date':
title = 'Packages marked out-of-date more than 90 days ago'
- cutoff = datetime.utcnow() - timedelta(days=90)
+ cutoff = utc_now() - timedelta(days=90)
packages = packages.filter(
flag_date__lt=cutoff).order_by('flag_date')
elif report_name == 'big':