summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--devel/views.py43
-rw-r--r--templates/devel/clock.html21
2 files changed, 54 insertions, 10 deletions
diff --git a/devel/views.py b/devel/views.py
index cf0d8ad2..85acda74 100644
--- a/devel/views.py
+++ b/devel/views.py
@@ -1,4 +1,4 @@
-from datetime import date, datetime, timedelta
+from datetime import timedelta
import operator
import pytz
import random
@@ -9,24 +9,28 @@ from django import forms
from django.http import HttpResponseRedirect
from django.contrib.auth.decorators import \
login_required, permission_required, user_passes_test
+from django.contrib.admin.models import LogEntry, ADDITION
from django.contrib.auth.models import User, Group
+from django.contrib.contenttypes.models import ContentType
from django.contrib.sites.models import Site
from django.core.mail import send_mail
from django.db import transaction
-from django.db.models import F, Count
+from django.db.models import F, Count, Max
from django.http import Http404
from django.shortcuts import get_object_or_404
from django.template import loader, Context
from django.template.defaultfilters import filesizeformat
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 .models import UserProfile
from main.models import Package, PackageDepend, PackageFile, TodolistPkg
from main.models import Arch, Repo
from main.utils import utc_now
-from packages.models import PackageRelation
+from news.models import News
+from packages.models import PackageRelation, Signoff
from packages.utils import get_signoff_groups
from todolists.utils import get_annotated_todolists
from .utils import get_annotated_maintainers, UserFinder
@@ -91,6 +95,33 @@ def clock(request):
devs = User.objects.filter(is_active=True).order_by(
'first_name', 'last_name').select_related('userprofile')
+ latest_news = dict(News.objects.filter(
+ author__is_active=True).values_list('author').order_by(
+ ).annotate(last_post=Max('postdate')))
+ latest_package = dict(Package.objects.filter(
+ packager__is_active=True).values_list('packager').order_by(
+ ).annotate(last_build=Max('build_date')))
+ latest_signoff = dict(Signoff.objects.filter(
+ user__is_active=True).values_list('user').order_by(
+ ).annotate(last_signoff=Max('created')))
+ latest_log = dict(LogEntry.objects.filter(
+ user__is_active=True).values_list('user').order_by(
+ ).annotate(last_log=Max('action_time')))
+
+ for dev in devs:
+ dates = [
+ latest_news.get(dev.id, None),
+ latest_package.get(dev.id, None),
+ latest_signoff.get(dev.id, None),
+ latest_log.get(dev.id, None),
+ dev.last_login,
+ ]
+ dates = [d for d in dates if d is not None]
+ if dates:
+ dev.last_action = max(dates)
+ else:
+ dev.last_action = None
+
now = utc_now()
page_dict = {
'developers': devs,
@@ -135,7 +166,8 @@ class UserProfileForm(forms.ModelForm):
def change_profile(request):
if request.POST:
form = ProfileForm(request.POST)
- profile_form = UserProfileForm(request.POST, request.FILES, instance=request.user.get_profile())
+ profile_form = UserProfileForm(request.POST, request.FILES,
+ instance=request.user.get_profile())
if form.is_valid() and profile_form.is_valid():
request.user.email = form.cleaned_data['email']
if form.cleaned_data['passwd1']:
@@ -331,9 +363,6 @@ class NewUserForm(forms.ModelForm):
def log_addition(request, obj):
"""Cribbed from ModelAdmin.log_addition."""
- from django.contrib.admin.models import LogEntry, ADDITION
- from django.contrib.contenttypes.models import ContentType
- from django.utils.encoding import force_unicode
LogEntry.objects.log_action(
user_id = request.user.pk,
content_type_id = ContentType.objects.get_for_model(obj).pk,
diff --git a/templates/devel/clock.html b/templates/devel/clock.html
index bdb7341d..6a3f0a69 100644
--- a/templates/devel/clock.html
+++ b/templates/devel/clock.html
@@ -11,8 +11,18 @@
<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>The "Last Action" column shows the last time this developer has done
+ something we know about. Considered dates for each developer include:</p>
+ <ul>
+ <li>Build date of a package in the repositories</li>
+ <li>Last login to the developer side of this site</li>
+ <li>Admin log entry on this site (e.g., adding a donor, modifying a
+ mirror)</li>
+ <li>Post date of a news item</li>
+ <li>Signing off on a package</li>
+ </ul>
<p>
- UTC Time: {{ utc_now|date:"Y-m-d H:i T" }}
+ Current UTC Time: {{ utc_now|date:"Y-m-d H:i T" }}
</p>
<table id="clocks-table" class="results">
@@ -21,6 +31,7 @@
<th>Developer</th>
<th>Username</th>
<th>Alias</th>
+ <th>Last Action</th>
<th>Location</th>
<th>Time Zone</th>
<th>Current Time</th>
@@ -32,6 +43,7 @@
<td><a href="mailto:{{ dev.email }}">{{ dev.get_full_name }}</a></td>
<td>{{ dev.username }}</td>
<td>{{ dev.userprofile.alias }}</td>
+ <td>{{ dev.last_action }}</td>
<td>{% if dev.userprofile.country %}<img src="{{ dev.userprofile.country.flag }}" alt="{{ dev.userprofile.country.name }}"/> {% endif %}{{ dev.userprofile.location }}</td>
<td>{{ dev.userprofile.time_zone }}</td>
<td>{{ utc_now|timezone:dev.userprofile.time_zone|date:"Y-m-d H:i T" }}<span class="hide"> {{ dev.userprofile.time_zone }}</span></td>
@@ -45,8 +57,11 @@
<script type="text/javascript" src="{% static "archweb.js" %}"></script>
<script type="text/javascript">
$(document).ready(function() {
- $("#clocks-table:has(tbody tr)").tablesorter(
- {widgets: ['zebra'], sortList: [[0,0]]});
+ $("#clocks-table:has(tbody tr)").tablesorter({
+ widgets: ['zebra'],
+ sortList: [[0,0]],
+ headers: { 4: { sorter: false } }
+ });
});
</script>
{% endblock %}