From 0c6ee81eb469734dae380f428149f316fdbf75bd Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Mon, 7 Mar 2011 21:06:04 -0600 Subject: Work around unicode/str issue in pytz Signed-off-by: Dan McGee --- devel/views.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'devel/views.py') diff --git a/devel/views.py b/devel/views.py index 311922ca..c926c5a4 100644 --- a/devel/views.py +++ b/devel/views.py @@ -55,7 +55,9 @@ def clock(request): now = datetime.datetime.now() utc_now = datetime.datetime.utcnow().replace(tzinfo=pytz.utc) for dev in devs: - tz = pytz.timezone(dev.userprofile.time_zone) + # Work around https://bugs.launchpad.net/pytz/+bug/718673 + timezone = str(dev.userprofile.time_zone) + tz = pytz.timezone(timezone) dev.current_time = utc_now.astimezone(tz) page_dict = { -- cgit v1.2.3-54-g00ecf From 1dc867587da6b66ca575eb26f4f65cb9d67ffdb3 Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Tue, 4 Jan 2011 08:45:15 -0600 Subject: Add Admin log overview page This puts the admin log functionality to a bit more use and allows seeing the last 100 overall entries. You can also drill down to see actions on a per-user basis. Signed-off-by: Dan McGee --- devel/urls.py | 2 ++ devel/views.py | 16 ++++++++++- templates/admin/index.html | 8 ++++++ templates/devel/admin_log.html | 62 ++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 87 insertions(+), 1 deletion(-) create mode 100644 templates/devel/admin_log.html (limited to 'devel/views.py') diff --git a/devel/urls.py b/devel/urls.py index bcf9c071..41be2b31 100644 --- a/devel/urls.py +++ b/devel/urls.py @@ -5,6 +5,8 @@ (r'^clock/$', 'clock'), (r'^profile/$', 'change_profile'), (r'^newuser/$', 'new_user_form'), + (r'^admin_log/(?P.*)/$','admin_log'), + (r'^admin_log/$','admin_log'), ) # vim: set ts=4 sw=4 et: diff --git a/devel/views.py b/devel/views.py index c926c5a4..46387f7a 100644 --- a/devel/views.py +++ b/devel/views.py @@ -1,9 +1,11 @@ from django import forms from django.http import HttpResponseRedirect -from django.contrib.auth.decorators import login_required, permission_required +from django.contrib.auth.decorators import \ + login_required, permission_required, user_passes_test from django.contrib.auth.models import User from django.contrib.sites.models import Site from django.core.mail import send_mail +from django.shortcuts import get_object_or_404 from django.template import loader, Context from django.views.decorators.cache import never_cache from django.views.generic.simple import direct_to_template @@ -169,4 +171,16 @@ def new_user_form(request): } return direct_to_template(request, 'general_form.html', context) +@user_passes_test(lambda u: u.is_superuser) +@never_cache +def admin_log(request, username=None): + user = None + if username: + user = get_object_or_404(User, username=username) + context = { + 'title': "Admin Action Log", + 'log_user': user, + } + return direct_to_template(request, 'devel/admin_log.html', context) + # vim: set ts=4 sw=4 et: diff --git a/templates/admin/index.html b/templates/admin/index.html index 6f7f98ee..93cf258d 100644 --- a/templates/admin/index.html +++ b/templates/admin/index.html @@ -14,10 +14,18 @@
+ {% if perms.auth.add_user %} + {% endif %} + {% if user.is_superuser %} + + + + + {% endif %}
Custom Admin Pages
Create New User
Admin Actions Log
diff --git a/templates/devel/admin_log.html b/templates/devel/admin_log.html new file mode 100644 index 00000000..2de15bad --- /dev/null +++ b/templates/devel/admin_log.html @@ -0,0 +1,62 @@ +{% extends "admin/base_site.html" %} +{% load i18n %} + +{% block extrastyle %}{{ block.super }}{% endblock %} + +{% block breadcrumbs %}{% endblock %} + +{% block content %} +
+
+{% load log %} +{% if log_user %} +{% get_admin_log 100 as admin_log for_user log_user %} +{% else %} +{% get_admin_log 100 as admin_log %} +{% endif %} +{% if not admin_log %} +

{% trans 'None available' %}

+{% else %} + + + + + + + + + + + + {% for entry in admin_log %} + + + {% if log_user %} + + {% else %} + + {% endif %} + + + + + {% endfor %} + +
{% trans 'Date/time' %}{% trans 'User' %}TypeObject{% trans 'Action' %}
{{ entry.action_time|date:"DATETIME_FORMAT" }}{{ entry.user.username }}{% if entry.user.get_full_name %} ({{ entry.user.get_full_name }}){% endif %}{{ entry.user.username }}{% if entry.user.get_full_name %} ({{ entry.user.get_full_name }}){% endif %} + {% if entry.content_type %} + {% filter capfirst %}{% trans entry.content_type.name %}{% endfilter %} + {% else %} + {% trans 'Unknown content' %} + {% endif %} + + + {% if entry.is_deletion %} + {{ entry.object_repr }} + {% else %} + {{ entry.object_repr }} + {% endif %} + {{ entry.change_message }}
+{% endif %} +
+
+{% endblock %} -- cgit v1.2.3-54-g00ecf From ad2a9ac23af0d4610e079741070c4408a4c6ce16 Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Fri, 11 Mar 2011 17:13:25 -0600 Subject: Show orphan package counts in maintainer dashboard table Signed-off-by: Dan McGee --- devel/views.py | 11 +++++++++++ templates/devel/index.html | 9 +++++++++ 2 files changed, 20 insertions(+) (limited to 'devel/views.py') diff --git a/devel/views.py b/devel/views.py index 46387f7a..5b8965d8 100644 --- a/devel/views.py +++ b/devel/views.py @@ -36,11 +36,22 @@ def index(request): maintainers = get_annotated_maintainers() + maintained = PackageRelation.objects.filter( + type=PackageRelation.MAINTAINER).values('pkgbase') + total_orphans = Package.objects.exclude(pkgbase__in=maintained).count() + total_flagged_orphans = Package.objects.filter( + flag_date__isnull=False).exclude(pkgbase__in=maintained).count() + orphan = { + 'package_count': total_orphans, + 'flagged_count': total_flagged_orphans, + } + page_dict = { 'todos': Todolist.objects.incomplete().order_by('-date_added'), 'repos': Repo.objects.all(), 'arches': Arch.objects.all(), 'maintainers': maintainers, + 'orphan': orphan, 'flagged' : flagged, 'todopkgs' : todopkgs, } diff --git a/templates/devel/index.html b/templates/devel/index.html index 08ca249a..fb4ed4ab 100644 --- a/templates/devel/index.html +++ b/templates/devel/index.html @@ -166,6 +166,15 @@

Package Todo Lists

# Packages # Flagged + + Orphan + + {{ orphan.package_count }} packages + + {{ orphan.flagged_count }} packages + {% for maint in maintainers %} -- cgit v1.2.3-54-g00ecf