- 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'],
+ }