summaryrefslogtreecommitdiffstats
path: root/devel
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2012-07-24 16:19:48 +0200
committerDan McGee <dan@archlinux.org>2012-07-25 02:57:20 +0200
commitc0bf9e20660cfae7ea8994472555bba23398b598 (patch)
tree889351fc02d4930233acf3dace3ececda4833c88 /devel
parent61b4098c611592d62b40a9ee941976a869dff4fc (diff)
downloadarchweb-c0bf9e20660cfae7ea8994472555bba23398b598.tar.gz
archweb-c0bf9e20660cfae7ea8994472555bba23398b598.tar.xz
Remove custom utc_now() function, use django.utils.timezone.now()
This was around from the time when we handled timezones sanely and Django did not; now that we are on 1.4 we no longer need our own code to handle this. Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'devel')
-rw-r--r--devel/management/commands/reporead.py9
-rw-r--r--devel/models.py5
-rw-r--r--devel/views.py12
3 files changed, 14 insertions, 12 deletions
diff --git a/devel/management/commands/reporead.py b/devel/management/commands/reporead.py
index 2d9b68b..e69691d 100644
--- a/devel/management/commands/reporead.py
+++ b/devel/management/commands/reporead.py
@@ -28,10 +28,11 @@ from pytz import utc
from django.core.management.base import BaseCommand, CommandError
from django.db import connections, router, transaction
from django.db.utils import IntegrityError
+from django.utils.timezone import now
from devel.utils import UserFinder
from main.models import Arch, Package, PackageFile, Repo
-from main.utils import utc_now, database_vendor
+from main.utils import database_vendor
from packages.models import Depend, Conflict, Provision, Replacement, Update
@@ -318,7 +319,7 @@ def populate_files(dbpkg, repopkg, force=False):
filename=filename)
pkg_files.append(pkgfile)
batched_bulk_create(PackageFile, pkg_files)
- dbpkg.files_last_update = utc_now()
+ dbpkg.files_last_update = now()
dbpkg.save()
@@ -388,7 +389,7 @@ def db_update(archname, reponame, pkgs, force=False):
dbpkg = Package(pkgname=pkg.name, arch=architecture, repo=repository)
try:
with transaction.commit_on_success():
- populate_pkg(dbpkg, pkg, timestamp=utc_now())
+ populate_pkg(dbpkg, pkg, timestamp=now())
Update.objects.log_update(None, dbpkg)
except IntegrityError:
logger.warning("Could not add package %s; "
@@ -417,7 +418,7 @@ def db_update(archname, reponame, pkgs, force=False):
if not force and pkg_same_version(pkg, dbpkg):
continue
elif not force:
- timestamp = utc_now()
+ timestamp = now()
# The odd select_for_update song and dance here are to ensure
# simultaneous updates don't happen on a package, causing
diff --git a/devel/models.py b/devel/models.py
index fd5df00..9b6f07a 100644
--- a/devel/models.py
+++ b/devel/models.py
@@ -4,10 +4,11 @@ import pytz
from django.db import models
from django.db.models.signals import pre_save
from django.contrib.auth.models import User
+from django.utils.timezone import now
from django_countries import CountryField
from .fields import PGPKeyField
-from main.utils import make_choice, utc_now
+from main.utils import make_choice
class UserProfile(models.Model):
@@ -105,7 +106,7 @@ def set_last_modified(sender, **kwargs):
signal handler.'''
obj = kwargs['instance']
if hasattr(obj, 'last_modified'):
- obj.last_modified = utc_now()
+ obj.last_modified = now()
# connect signals needed to keep cache in line with reality
diff --git a/devel/views.py b/devel/views.py
index 78ed26f..143b12b 100644
--- a/devel/views.py
+++ b/devel/views.py
@@ -24,11 +24,11 @@ from django.views.decorators.cache import never_cache
from django.views.generic.simple import direct_to_template
from django.utils.encoding import force_unicode
from django.utils.http import http_date
+from django.utils.timezone import now
from .models import UserProfile
from main.models import Package, PackageFile, TodolistPkg
from main.models import Arch, Repo
-from main.utils import utc_now
from news.models import News
from packages.models import PackageRelation, Signoff, Depend
from packages.utils import get_signoff_groups
@@ -122,15 +122,15 @@ def clock(request):
else:
dev.last_action = None
- now = utc_now()
+ current_time = now()
page_dict = {
'developers': devs,
- 'utc_now': now,
+ 'utc_now': current_time,
}
response = direct_to_template(request, 'devel/clock.html', page_dict)
if not response.has_header('Expires'):
- expire_time = now.replace(second=0, microsecond=0)
+ expire_time = current_time.replace(second=0, microsecond=0)
expire_time += timedelta(minutes=1)
expire_time = time.mktime(expire_time.timetuple())
response['Expires'] = http_date(expire_time)
@@ -198,12 +198,12 @@ def report(request, report_name, username=None):
if report_name == 'old':
title = 'Packages last built more than one year ago'
- cutoff = utc_now() - timedelta(days=365)
+ cutoff = now() - timedelta(days=365)
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 = utc_now() - timedelta(days=90)
+ cutoff = now() - timedelta(days=90)
packages = packages.filter(
flag_date__lt=cutoff).order_by('flag_date')
elif report_name == 'big':