summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--packages/views.py25
-rw-r--r--settings.py4
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',