X-Git-Url: https://git.openstreetmap.org./osqa.git/blobdiff_plain/3236874239f091690f47e1c8b076e21ec0b142d1..923d5f9317209295b254f9b72095104ed236652a:/forum/views/meta.py?ds=sidebyside diff --git a/forum/views/meta.py b/forum/views/meta.py index 932c627..3330a3b 100644 --- a/forum/views/meta.py +++ b/forum/views/meta.py @@ -17,6 +17,7 @@ from forum import settings from forum.utils.mail import send_template_email from django.utils.safestring import mark_safe from forum.templatetags.extra_filters import or_preview +import decorators import re def favicon(request): @@ -43,15 +44,15 @@ def opensearch(request): def feedback(request): if request.method == "POST": - form = FeedbackForm(request.POST) + form = FeedbackForm(request.user, data=request.POST) if form.is_valid(): - context = {'user': request.user} - - if not request.user.is_authenticated: - context['email'] = form.cleaned_data.get('email', None) - context['message'] = form.cleaned_data['message'] - context['name'] = form.cleaned_data.get('name', None) - context['ip'] = request.META['REMOTE_ADDR'] + context = { + 'user': request.user, + 'email': request.user.is_authenticated() and request.user.email or form.cleaned_data.get('email', None), + 'message': form.cleaned_data['message'], + 'name': request.user.is_authenticated() and request.user.username or form.cleaned_data.get('name', None), + 'ip': request.META['REMOTE_ADDR'], + } recipients = User.objects.filter(is_superuser=True) send_template_email(recipients, "notifications/feedback.html", context) @@ -60,7 +61,7 @@ def feedback(request): request.user.message_set.create(message=msg) return HttpResponseRedirect(get_next_url(request)) else: - form = FeedbackForm(initial={'next':get_next_url(request)}) + form = FeedbackForm(request.user, initial={'next':get_next_url(request)}) return render_to_response('feedback.html', {'form': form}, context_instance=RequestContext(request)) @@ -74,6 +75,7 @@ def logout(request): 'next' : get_next_url(request), }, context_instance=RequestContext(request)) +@decorators.render('badges.html', 'badges', _('badges'), weight=300) def badges(request): badges = [b.ondb for b in sorted(BadgesMeta.by_id.values(), lambda b1, b2: cmp(b1.name, b2.name))] @@ -82,10 +84,10 @@ def badges(request): else: my_badges = [] - return render_to_response('badges.html', { - 'badges' : badges, - 'mybadges' : my_badges, - }, context_instance=RequestContext(request)) + return { + 'badges' : badges, + 'mybadges' : my_badges, + } def badge(request, id, slug): badge = Badge.objects.get(id=id)