diff options
author | Dan McGee <dan@archlinux.org> | 2010-06-21 06:56:01 +0200 |
---|---|---|
committer | Dan McGee <dan@archlinux.org> | 2010-06-21 06:56:03 +0200 |
commit | f123348c7dfb50353a6a555bfe44d11defa60269 (patch) | |
tree | 9d282ebab1013033c20a11d68511d15f57f5b8e9 | |
parent | 67f6bc546ec20bd1912aae385220855f9a41a93d (diff) | |
download | archweb-f123348c7dfb50353a6a555bfe44d11defa60269.tar.gz archweb-f123348c7dfb50353a6a555bfe44d11defa60269.tar.xz |
Update to the new messages framework
This is also another step in making sure we don't unnecessarily access the
Django session object and thus add a Vary cache control header we don't
want.
Signed-off-by: Dan McGee <dan@archlinux.org>
-rw-r--r-- | packages/views.py | 25 | ||||
-rw-r--r-- | settings.py | 4 |
2 files changed, 18 insertions, 11 deletions
diff --git a/packages/views.py b/packages/views.py index c3a6c2b..f085c91 100644 --- a/packages/views.py +++ b/packages/views.py @@ -1,4 +1,5 @@ from django import forms +from django.contrib import messages from django.core.mail import send_mail from django.shortcuts import render_to_response from django.template import loader, Context, RequestContext @@ -59,15 +60,14 @@ def update(request): user=request.user) rels.delete() - request.user.message_set.create(message="%d packages %sed" % ( - len(pkgs), mode)) + messages.info(request, "%d packages %sed." % (count, mode)) if disallowed_pkgs: - request.user.message_set.create( - message="You do not have permission to adopt: %s" % ( - ' '.join([p.pkgname for p in disallowed_pkgs]) + messages.warning(request, + "You do not have permission to %s: %s" % ( + mode, ' '.join([p.pkgname for p in disallowed_pkgs]) )) else: - request.user.message_set.create(message="update called without adopt/disown") + messages.error(request, "Are you trying to adopt or disown?") return HttpResponseRedirect('/packages/') def details(request, name='', repo='', arch=''): @@ -247,11 +247,14 @@ def signoff_package(request, arch, pkgname): pkgrel=pkg.pkgrel, packager=request.user) - message = "You have successfully" if created else "You have already" - request.user.message_set.create( - message="%s signed off for %s on %s" % ( - message, pkg.pkgname, pkg.arch)) - + if created: + messages.info(request, + "You have successfully signed off for %s on %s." % \ + (pkg.pkgname, pkg.arch)) + else: + messages.warning(request, + "You have already signed off for %s on %s." % \ + (pkg.pkgname, pkg.arch)) return signoffs(request) def flaghelp(request): diff --git a/settings.py b/settings.py index 68eaaad..13c6cc8 100644 --- a/settings.py +++ b/settings.py @@ -46,6 +46,7 @@ TEMPLATE_LOADERS = ( MIDDLEWARE_CLASSES = ( 'main.middleware.UpdateCacheMiddleware', "django.contrib.sessions.middleware.SessionMiddleware", + 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', "django.contrib.auth.middleware.AuthenticationMiddleware", 'django.middleware.http.ConditionalGetMiddleware', @@ -68,9 +69,12 @@ TEMPLATE_DIRS = ( # format is app.model AUTH_PROFILE_MODULE = 'main.UserProfile' +MESSAGE_STORAGE = 'django.contrib.messages.storage.session.SessionStorage' + INSTALLED_APPS = ( 'django.contrib.auth', 'django.contrib.contenttypes', + 'django.contrib.messages', 'django.contrib.sessions', 'django.contrib.sites', 'django.contrib.sitemaps', |