widelands-dev team mailing list archive
-
widelands-dev team
-
Mailing list archive
-
Message #07942
[Merge] lp:~widelands-dev/widelands-website/rework_http500_error into lp:widelands-website
kaputtnik has proposed merging lp:~widelands-dev/widelands-website/rework_http500_error into lp:widelands-website.
Requested reviews:
Widelands Developers (widelands-dev)
For more details, see:
https://code.launchpad.net/~widelands-dev/widelands-website/rework_http500_error/+merge/301112
Currently when a http 500 error is raised all css is missing and the relevant information is shown at the bottom of the page.
This branch changes this behavior so that a http 500 error is shown like a normal content. The Information to inform the webmasters/administrators is changed and give the user 2 options to inform the webmasters. I am not sure if we should add additionally a E-mail option here.
This branch contains also a redirect: If one is trying to get wl.widelands.org/docs (which through currently a http500 error) he is redirected to wl.widelands/docs/wl. This should eliminate the server errors caused by some web spiders who found an old link to /docs.
Most changes to mainpage/views.py are caused by pyformat, the relevant change is the new view "custom_http_500" at the bottom of the file.
--
Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands-website/rework_http500_error into lp:widelands-website.
=== modified file 'mainpage/views.py'
--- mainpage/views.py 2016-06-25 14:22:15 +0000
+++ mainpage/views.py 2016-07-25 20:13:30 +0000
@@ -18,36 +18,40 @@
return render_to_response('mainpage.html',
context_instance=RequestContext(request))
+
def legal_notice(request):
"""The legal notice page to fullfill law."""
if request.method == 'POST':
form = ContactForm(request.POST)
if form.is_valid():
- name = form.cleaned_data['forename'] + ' ' + form.cleaned_data['surname']
- subject = 'An inquiry over the webpage'
+ name = form.cleaned_data['forename'] + \
+ ' ' + form.cleaned_data['surname']
+ subject = 'An inquiry over the webpage'
message = '\n'.join(['From: ' + name,
- 'EMail: ' + form.cleaned_data['email'],
- 'Inquiry:',
- form.cleaned_data['inquiry']])
+ 'EMail: ' + form.cleaned_data['email'],
+ 'Inquiry:',
+ form.cleaned_data['inquiry']])
sender = 'legal_note@xxxxxxxxxxxxx'
- ## get email addresses which are in form of ('name','email'),
+ # get email addresses which are in form of ('name','email'),
recipients = []
for recipient in INQUIRY_RECIPIENTS:
recipients.append(recipient[1])
print('recipeients: ', recipients)
send_mail(subject, message, sender,
- recipients, fail_silently=False)
- return HttpResponseRedirect('/legal_notice_thanks/') # Redirect after POST
+ recipients, fail_silently=False)
+ # Redirect after POST
+ return HttpResponseRedirect('/legal_notice_thanks/')
else:
- form = ContactForm() # An unbound form
-
+ form = ContactForm() # An unbound form
+
return render(request, 'mainpage/legal_notice.html', {
'form': form,
'inquiry_recipients': INQUIRY_RECIPIENTS,
- })
+ })
+
def legal_notice_thanks(request):
return render(request, 'mainpage/legal_notice_thanks.html')
@@ -56,14 +60,13 @@
from registration.backends.hmac.views import RegistrationView
from django.contrib.auth.models import User
+
class OwnRegistrationView(RegistrationView):
- """
- Overwriting the default function to save also the extended User model (wlprofile)
- """
+ """Overwriting the default function to save also the extended User model
+ (wlprofile)"""
+
def create_inactive_user(self, form):
- """
- Additionally save the custom enxtended user data.
- """
+ """Additionally save the custom enxtended user data."""
new_user = form.save(commit=False)
new_user.is_active = False
new_user.save()
@@ -74,7 +77,8 @@
self.send_activation_email(new_user)
return new_user
-
+
+
def developers(request):
"""This reads out some json files in the SVN directory, and returns it as a
wl_markdown_object.
@@ -167,3 +171,9 @@
{'changelog': data},
context_instance=RequestContext(request)
)
+
+
+def custom_http_500(request):
+ """A custom http 500 error page to get the last request path available in
+ the view and to not loose css styling."""
+ return render(request, '500.html', status=500)
=== modified file 'settings.py'
--- settings.py 2016-06-26 11:30:10 +0000
+++ settings.py 2016-07-25 20:13:30 +0000
@@ -315,7 +315,7 @@
u'img',
u'hr',
u'table', u'tbody', u'thead', u'th', u'tr', u'td',
- u'sup',
+ u'sup',
]
BLEACH_ALLOWED_ATTRIBUTES = {'img': ['src', 'alt'], 'a': ['href'], '*': ['class', 'id', 'title']}
=== modified file 'templates/500.html'
--- templates/500.html 2012-05-04 16:52:39 +0000
+++ templates/500.html 2016-07-25 20:13:30 +0000
@@ -7,10 +7,13 @@
{% block content %}
<h1>Internal server error</h1>
<div class="blogEntry">
- <p>
- If you think you didn't make any mistake, please inform
- <a href="mailto:sirver@xxxxxx?subject=[Widelands Homepage] bug in {{ request.path }}">SirVer</a>
- about the error you've received.
+ <p> If you think you didn't make any mistake, please inform the administrators:
+ <ul>
+ <li>If you have an account on widelands.org, send a PM to: <a href="/profile/kaputtnik/">kaputtnik</a> </li>
+ <li>Use the form on the <a href="/legal_notice">Legal Notice Page</a></li>
+ </ul>
+ <p><strong>In any case add the following information to your post:</strong></p><br />
+ <p>Error in {{ request.path }}</p>
</p>
</div>
{% endblock %}
=== modified file 'urls.py'
--- urls.py 2016-07-20 09:06:47 +0000
+++ urls.py 2016-07-25 20:13:30 +0000
@@ -32,9 +32,11 @@
url (r'^messages/', include('django_messages.urls')),
url (r'^threadedcomments/', include('threadedcomments.urls')),
# url(r'^articles/comments/', include('django_comments.urls')),
-
+
+ # Redirect old urls to docs to docs/wl
+ url(r'^docs/$', RedirectView.as_view( url='/docs/wl' ), name='docs'),
url (r'^docs/', include('sphinxdoc.urls')),
-
+
# 3rd party, modified for widelands
url (r'^wiki/', include('wiki.urls')),
url (r'^news/', include('news.urls')),
@@ -64,3 +66,4 @@
except ImportError:
pass
+handler500 = 'mainpage.views.custom_http_500'
Follow ups