]> git.openstreetmap.org Git - osqa.git/blobdiff - forum/views/meta.py
Migrate to Django 1.6
[osqa.git] / forum / views / meta.py
index 8f924feb02e8589ef740dc5ae42e0e3134583e9e..a47cf1d8bbc5f04ffbae53c942c41d4e0842e414 100644 (file)
@@ -1,28 +1,28 @@
 import os
 from itertools import groupby
 import os
 from itertools import groupby
-from django.shortcuts import render_to_response, get_object_or_404
-from django.core.urlresolvers import reverse
-from django.template import RequestContext, loader
-from django.http import HttpResponseRedirect, HttpResponse, Http404
+
+from django.shortcuts import render_to_response
+from django.template import RequestContext
+from django.http import HttpResponseRedirect, HttpResponse
 from django.views.static import serve
 from django.views.static import serve
-from forum import settings
-from forum.modules import decorate
 from django.views.decorators.cache import cache_page
 from django.views.decorators.cache import cache_page
+from django.utils.translation import ugettext as _
+from django.utils.safestring import mark_safe
+
+from django.contrib import messages
+
+from forum import settings
 from forum.views.decorators import login_required
 from forum.forms import FeedbackForm
 from forum.views.decorators import login_required
 from forum.forms import FeedbackForm
-from django.core.urlresolvers import reverse
-from django.utils.translation import ugettext as _
-from django.db.models import Count
+from forum.modules import decorate
 from forum.forms import get_next_url
 from forum.models import Badge, Award, User, Page
 from forum.forms import get_next_url
 from forum.models import Badge, Award, User, Page
-from forum.badges.base import BadgesMeta
 from forum.http_responses import HttpResponseNotFound, HttpResponseIntServerError
 from forum.http_responses import HttpResponseNotFound, HttpResponseIntServerError
-from forum import settings
 from forum.utils.mail import send_template_email
 from forum.utils.mail import send_template_email
-from django.utils.safestring import mark_safe
 from forum.templatetags.extra_filters import or_preview
 from forum.templatetags.extra_filters import or_preview
+
 import decorators
 import decorators
-import re, sys, logging, traceback
+import logging, traceback
 
 def favicon(request):
     return HttpResponseRedirect(str(settings.APP_FAVICON))
 
 def favicon(request):
     return HttpResponseRedirect(str(settings.APP_FAVICON))
@@ -69,7 +69,7 @@ def feedback(request):
             send_template_email(recipients, "notifications/feedback.html", context)
 
             msg = _('Thanks for the feedback!')
             send_template_email(recipients, "notifications/feedback.html", context)
 
             msg = _('Thanks for the feedback!')
-            request.user.message_set.create(message=msg)
+            messages.info(request, msg)
             return HttpResponseRedirect(get_next_url(request))
     else:
         form = FeedbackForm(request.user, initial={'next':get_next_url(request)})
             return HttpResponseRedirect(get_next_url(request))
     else:
         form = FeedbackForm(request.user, initial={'next':get_next_url(request)})
@@ -89,10 +89,11 @@ def logout(request):
 
 @decorators.render('badges.html', 'badges', _('badges'), weight=300)
 def badges(request):
 
 @decorators.render('badges.html', 'badges', _('badges'), weight=300)
 def badges(request):
+    from forum.badges.base import BadgesMeta
     badges = sorted([Badge.objects.get(id=id) for id in BadgesMeta.by_id.keys()], lambda b1, b2: cmp(b1.name, b2.name))
 
     if request.user.is_authenticated():
     badges = sorted([Badge.objects.get(id=id) for id in BadgesMeta.by_id.keys()], lambda b1, b2: cmp(b1.name, b2.name))
 
     if request.user.is_authenticated():
-        my_badges = Award.objects.filter(user=request.user).values('badge_id').distinct()
+        my_badges = Award.objects.filter(user=request.user).values_list('badge_id', flat=True).distinct()
     else:
         my_badges = []
 
     else:
         my_badges = []