Commits

Poul Sysolyatin  committed 25ac594

Use message framework

  • Participants
  • Parent commits f000fd4

Comments (0)

Files changed (2)

File admin_tools/dashboard/views.py

 from django.http import HttpResponse
 from django.template import RequestContext
 from django.shortcuts import render_to_response
+from django.contrib import messages
 
 try:
     from django.views.decorators.csrf import csrf_exempt
             preferences = form.save()
             if request.is_ajax():
                 return HttpResponse('true')
-            request.user.message_set.create(message='Preferences saved')
+            messages.success(request, 'Preferences saved')
         elif request.is_ajax():
             return HttpResponse('false')
     else:

File admin_tools/menu/views.py

 from django.http import HttpResponse, HttpResponseRedirect
 from django.shortcuts import get_object_or_404, render_to_response
 from django.template import RequestContext
+from django.contrib import messages
 
 try:
     from django.views.decorators.csrf import csrf_exempt
         if form.is_valid():
             bookmark = form.save()
             if not request.is_ajax():
-                request.user.message_set.create(message='Bookmark added')
+                messages.success(request, 'Bookmark added')
                 if request.POST.get('next'):
                     return HttpResponseRedirect(request.POST.get('next'))
                 return HttpResponse('Added')
         if form.is_valid():
             form.save()
             if not request.is_ajax():
-                request.user.message_set.create(message='Bookmark updated')
+                messages.success(request, 'Bookmark updated')
                 if request.POST.get('next'):
                     return HttpResponseRedirect(request.POST.get('next'))
             return HttpResponse('Saved')
     if request.method == "POST":
         bookmark.delete()
         if not request.is_ajax():
-            request.user.message_set.create(message='Bookmark removed')
+            messages.success(request, 'Bookmark removed')
             if request.POST.get('next'):
                 return HttpResponseRedirect(request.POST.get('next'))
             return HttpResponse('Deleted')