from django.http import HttpResponseRedirect, HttpResponse, Http404
from django.views.static import serve
from forum import settings
+from forum.modules import decorate
+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 _
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)
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))
def privacy(request):
return render_to_response('privacy.html', context_instance=RequestContext(request))
+@decorate.withfn(login_required)
def logout(request):
return render_to_response('logout.html', {
'next' : get_next_url(request),