Merge lp:~widelands-dev/widelands-website/auto_copyr_year into lp:widelands-website

Proposed by kaputtnik
Status: Merged
Merged at revision: 481
Proposed branch: lp:~widelands-dev/widelands-website/auto_copyr_year
Merge into: lp:widelands-website
Diff against target: 354 lines (+90/-128)
12 files modified
mainpage/context_processors.py (+1/-2)
mainpage/templatetags/all_users.py (+0/-12)
mainpage/templatetags/forum_navigation.py (+0/-18)
mainpage/templatetags/get_model_name.py (+0/-8)
mainpage/templatetags/wl_extras.py (+52/-0)
mainpage/views.py (+7/-12)
templates/base.html (+2/-1)
templates/django_messages/compose.html (+1/-1)
templates/footer.html (+2/-4)
templates/login_box.html (+23/-68)
templates/navigation.html (+1/-1)
templates/pagination/pagination_mod.html (+1/-1)
To merge this branch: bzr merge lp:~widelands-dev/widelands-website/auto_copyr_year
Reviewer Review Type Date Requested Status
GunChleoc Approve
Review via email: mp+337911@code.launchpad.net

Description of the change

Set the last year of copyright notice in the footer automatically to current year.

Some cleanups.

To post a comment you must log in.
Revision history for this message
GunChleoc (gunchleoc) wrote :

Code LGTM, not tested.

review: Approve
Revision history for this message
kaputtnik (franku) wrote :

I have tested it a lot. Merged and deployed.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'mainpage/context_processors.py'
2--- mainpage/context_processors.py 2016-12-15 12:55:44 +0000
3+++ mainpage/context_processors.py 2018-02-17 11:33:36 +0000
4@@ -2,6 +2,5 @@
5
6
7 def settings_for_templates(request):
8- context = {'USE_GOOGLE_ANALYTICS': settings.USE_GOOGLE_ANALYTICS,
9- 'LOGO_FILE': settings.LOGO_FILE}
10+ context = {'USE_GOOGLE_ANALYTICS': settings.USE_GOOGLE_ANALYTICS,}
11 return context
12
13=== removed file 'mainpage/templatetags/all_users.py'
14--- mainpage/templatetags/all_users.py 2017-11-06 17:50:17 +0000
15+++ mainpage/templatetags/all_users.py 1970-01-01 00:00:00 +0000
16@@ -1,12 +0,0 @@
17-#!/usr/bin/env python -tt
18-# encoding: utf-8
19-
20-from django import template
21-from django.contrib.auth.models import User
22-
23-register = template.Library()
24-
25-@register.simple_tag
26-def all_users():
27- """Provide a list of all users"""
28- return [str(u.username) for u in User.objects.all()]
29
30=== removed file 'mainpage/templatetags/forum_navigation.py'
31--- mainpage/templatetags/forum_navigation.py 2016-12-15 12:55:44 +0000
32+++ mainpage/templatetags/forum_navigation.py 1970-01-01 00:00:00 +0000
33@@ -1,18 +0,0 @@
34-from pybb.models import Category
35-from django import template
36-
37-
38-register = template.Library()
39-
40-@register.inclusion_tag('mainpage/forum_navigation.html')
41-def forum_navigation():
42- """Makes the forum list available to the navigation, even
43- if it is not loaded directly.
44-
45- Ordering:
46- 1.: value of 'Position' in pybb.Category
47- 2.: value of 'Position' of pybb.Forum.
48-
49- """
50- categories = Category.objects.all()
51- return {'categories': categories}
52
53=== removed file 'mainpage/templatetags/get_model_name.py'
54--- mainpage/templatetags/get_model_name.py 2017-08-16 22:18:21 +0000
55+++ mainpage/templatetags/get_model_name.py 1970-01-01 00:00:00 +0000
56@@ -1,8 +0,0 @@
57-from django import template
58-
59-register = template.Library()
60-
61-@register.filter
62-def get_model_name(object):
63- """Returns the name of an objects model"""
64- return object.__class__.__name__
65\ No newline at end of file
66
67=== added file 'mainpage/templatetags/wl_extras.py'
68--- mainpage/templatetags/wl_extras.py 1970-01-01 00:00:00 +0000
69+++ mainpage/templatetags/wl_extras.py 2018-02-17 11:33:36 +0000
70@@ -0,0 +1,52 @@
71+#!/usr/bin/env python -tt
72+# encoding: utf-8
73+
74+from django import template
75+
76+register = template.Library()
77+
78+
79+@register.simple_tag
80+def current_year():
81+ """Just return the current year."""
82+
83+ from datetime import date
84+ return date.today().year
85+
86+
87+@register.simple_tag
88+def wl_logo():
89+ """Just return the name of the logo."""
90+
91+ from django.conf import settings
92+ return settings.LOGO_FILE
93+
94+
95+@register.simple_tag
96+def all_users():
97+ """Provide a list of all users."""
98+
99+ from django.contrib.auth.models import User
100+ return [str(u.username) for u in User.objects.all()]
101+
102+
103+@register.inclusion_tag('mainpage/forum_navigation.html')
104+def forum_navigation():
105+ """Makes the forum list available to the navigation.
106+
107+ Ordering:
108+ 1.: value of 'Position' in pybb.Category
109+ 2.: value of 'Position' of pybb.Forum.
110+
111+ """
112+
113+ from pybb.models import Category
114+ categories = Category.objects.all()
115+ return {'categories': categories}
116+
117+
118+@register.filter
119+def get_model_name(object):
120+ """Returns the name of an objects model."""
121+
122+ return object.__class__.__name__
123
124=== modified file 'mainpage/views.py'
125--- mainpage/views.py 2017-10-30 11:58:00 +0000
126+++ mainpage/views.py 2018-02-17 11:33:36 +0000
127@@ -1,4 +1,3 @@
128-from django.shortcuts import render_to_response
129 from django.template import RequestContext
130 from settings import WIDELANDS_SVN_DIR, INQUIRY_RECIPIENTS
131 from templatetags.wl_markdown import do_wl_markdown
132@@ -7,7 +6,6 @@
133 from mainpage.forms import ContactForm
134 from django.shortcuts import render
135 from django.http import HttpResponseRedirect, HttpResponse
136-from django.core.urlresolvers import reverse
137 import sys
138 import json
139 import os
140@@ -17,8 +15,7 @@
141
142
143 def mainpage(request):
144- return render_to_response('mainpage.html',
145- context_instance=RequestContext(request))
146+ return render(request, 'mainpage.html',)
147
148
149 def legal_notice(request):
150@@ -132,10 +129,9 @@
151
152 txt = do_wl_markdown(txt, custom=False)
153
154- return render_to_response('mainpage/developers.html',
155- {'developers': txt},
156- context_instance=RequestContext(request)
157- )
158+ return render(request, 'mainpage/developers.html',
159+ {'developers': txt}
160+ )
161
162
163 def changelog(request):
164@@ -146,10 +142,9 @@
165
166 """
167 data = codecs.open(WIDELANDS_SVN_DIR + 'ChangeLog', encoding='utf-8', mode='r').read()
168- return render_to_response('mainpage/changelog.html',
169- {'changelog': data},
170- context_instance=RequestContext(request)
171- )
172+ return render(request, 'mainpage/changelog.html',
173+ {'changelog': data},
174+ )
175
176
177 def custom_http_500(request):
178
179=== modified file 'templates/base.html'
180--- templates/base.html 2017-11-08 08:32:10 +0000
181+++ templates/base.html 2018-02-17 11:33:36 +0000
182@@ -1,3 +1,4 @@
183+{% load wl_extras %}
184
185 <!DOCTYPE html>
186 {% comment %}
187@@ -51,7 +52,7 @@
188 <div class="loginBox posRight">
189 {% include "login_box.html" %}
190 </div>
191- <a href="{% url 'mainpage' %}"><img src="{{ MEDIA_URL }}img/{{ LOGO_FILE }}" class="posLeft" alt="Widelands Logo" /></a>
192+ <a href="{% url 'mainpage' %}"><img src="{{ MEDIA_URL }}img/{% wl_logo %}" class="posLeft" alt="Widelands Logo" /></a>
193 </div>
194 <div id="topmenu">
195 <!-- Navigation -->
196
197=== modified file 'templates/django_messages/compose.html'
198--- templates/django_messages/compose.html 2017-11-08 08:38:00 +0000
199+++ templates/django_messages/compose.html 2018-02-17 11:33:36 +0000
200@@ -1,6 +1,6 @@
201 {% extends "django_messages/base.html" %}
202 {% load i18n %}
203-{% load all_users %}
204+{% load wl_extras %}
205
206 {% block title %}
207 Compose - {{ block.super }}
208
209=== modified file 'templates/footer.html'
210--- templates/footer.html 2017-01-23 13:01:31 +0000
211+++ templates/footer.html 2018-02-17 11:33:36 +0000
212@@ -2,13 +2,11 @@
213 vim:ft=htmldjango:
214
215 This file is included by mainpage and contains the footer
216-
217- (which contains nothing at the moment)
218 {% endcomment %}
219
220-
221+{% load wl_extras %}
222
223 <div id="footer">
224- Copyright &copy; 2009 - 2017 By the Widelands Development Team<br />
225+ Copyright &copy; 2009 - {% current_year %} By the Widelands Development Team<br />
226 <a class="small" href="{% url 'legal_notice' %}">Legal notice (contact)</a>
227 </div>
228
229=== modified file 'templates/login_box.html'
230--- templates/login_box.html 2018-02-16 15:38:34 +0000
231+++ templates/login_box.html 2018-02-17 11:33:36 +0000
232@@ -2,73 +2,28 @@
233
234 <!-- Login form / User information -->
235 {% if user.is_authenticated %}
236-<div class="small posLeft">
237- Welcome {{ user|user_link }},<br/>
238- <a href="{% url 'scheduling_main' %}">Playtime Scheduler</a>
239-</div>
240-<div class="right small posRight">
241- <ul>
242- <li>
243- {% if messages_inbox_count %}
244- <a href="{% url 'messages_inbox' %}" title="You have {{ messages_inbox_count }} new messages">Messages ({{ messages_inbox_count }})</a>
245- {% else %}
246- <a href="{% url 'messages_inbox' %}" title="No new message">Messages</a>
247- {% endif %}
248- </li>
249- <li><a href="{% url 'notification_notices' %}">Notifications</a></li>
250- <li><a href="{% url 'profile_edit' %}">Edit Profile</a></li>
251- <li><a href="{% url 'auth_logout' %}?next={{ request.path|iriencode }}">Logout</a></li>
252- </ul>
253-</div>
254+ <div class="small posLeft">
255+ Welcome {{ user|user_link }},<br/>
256+ <a href="{% url 'scheduling_main' %}">Playtime Scheduler</a>
257+ </div>
258+ <div class="right small posRight">
259+ <ul>
260+ <li>
261+ {% if messages_inbox_count %}
262+ <a href="{% url 'messages_inbox' %}" title="You have {{ messages_inbox_count }} new messages">Messages ({{ messages_inbox_count }})</a>
263+ {% else %}
264+ <a href="{% url 'messages_inbox' %}" title="No new message">Messages</a>
265+ {% endif %}
266+ </li>
267+ <li><a href="{% url 'notification_notices' %}">Notifications</a></li>
268+ <li><a href="{% url 'profile_edit' %}">Edit Profile</a></li>
269+ <li><a href="{% url 'auth_logout' %}?next={{ request.path|iriencode }}">Logout</a></li>
270+ </ul>
271+ </div>
272 {% else %}
273-<h4>Login</h4>
274-{% comment %}
275-<form method="post" action="https://{{ request.META.HTTP_HOST }}/accounts/login/" id="login_box">
276- <input id="id_login_username" type="text" name="username" maxlength="30" placeholder="Username" />
277- <input id="id_login_password" type="password" name="password" />
278- <input type="hidden" id="submitted" value="false" />
279- <button type="submit">login</button>
280- <input type="hidden" name="next" value="{{ request.path|iriencode }}" />
281- {% csrf_token %}
282-</form>
283-{% endcomment %}
284-<div class="small center">
285- <a href="{% url 'auth_login' %}?next={{ request.path|iriencode }}">Click here to login</a><br />
286- <a href="{% url 'auth_password_reset' %}">Lost password?</a> | <a href="{% url 'registration_register' %}">Register now!</a>
287-</div>
288+ <h4>Login</h4>
289+ <div class="small center">
290+ <a href="{% url 'auth_login' %}?next={{ request.path|iriencode }}">Click here to login</a><br />
291+ <a href="{% url 'auth_password_reset' %}">Lost password?</a> | <a href="{% url 'registration_register' %}">Register now!</a>
292+ </div>
293 {% endif %}
294-{% comment %}
295-{# Login via iframe does not work between http and https #}
296-<script type="text/javascript">
297-$("#login_box").submit( function(data) {
298- var frameName = "login_frame" + (new Date()).getTime();
299- var frameSrc = "https://{{ request.META.HTTP_HOST }}/accounts/login/?next="
300- + window.location.pathname + window.location.search + window.location.hash;
301- var loginFrame = $("<iframe name=\"" + frameName + "\" src=\"" + frameSrc + "\" />");
302-
303- $("#login_box input[type='submit']").attr("disabled", "disabled")
304- loginFrame.css("display", "none");
305- loginFrame.load(function(data){
306- // get required fields
307- my_user_field = $(window.frames[ frameName ].document.getElementById("id_username"));
308- my_pass_field = $(window.frames[ frameName ].document.getElementById("id_password"));
309- parent_user_field = $("#id_login_username");
310- parent_pass_field = $("#id_login_password");
311- submitted_field = $("#submitted");
312-
313- if (submitted_field.val() != "true") {
314- // copy login information and submit
315- my_user_field.val(parent_user_field.val() == "Username" ? "" : parent_user_field.val());
316- my_pass_field.val(parent_pass_field.val());
317- // submit form to parent
318- submitted_field.val("true");
319- login_form = $(window.frames[ frameName ].document.getElementById("login_form"));
320- login_form.attr('target', "_parent");
321- login_form.submit();
322- }
323- });
324- jQuery('body:first').append(loginFrame);
325- return false;
326-});
327-</script>
328-{% endcomment %}
329
330=== modified file 'templates/navigation.html'
331--- templates/navigation.html 2018-02-09 16:48:48 +0000
332+++ templates/navigation.html 2018-02-17 11:33:36 +0000
333@@ -2,7 +2,7 @@
334 vim:ft=htmldjango
335 {% endcomment %}
336
337-{% load forum_navigation %}
338+{% load wl_extras %}
339
340 <script type="text/javascript">
341 /* Enable dropdown menus on touch devices */
342
343=== modified file 'templates/pagination/pagination_mod.html'
344--- templates/pagination/pagination_mod.html 2017-08-16 22:18:21 +0000
345+++ templates/pagination/pagination_mod.html 2018-02-17 11:33:36 +0000
346@@ -7,7 +7,7 @@
347 {% endcomment %}
348
349 {% load i18n %}
350-{% load get_model_name %}
351+{% load wl_extras %}
352 {% block previouslink %}
353 <span class="summary">
354 <strong>{{ page_obj.start_index }}</strong> &mdash;

Subscribers

People subscribed via source and target branches