Poul Sysolyatin avatar Poul Sysolyatin committed 25ac594

Use message framework

Comments (0)

Files changed (2)

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:

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')
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.