← Back to team overview

widelands-dev team mailing list archive

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

 

kaputtnik has proposed merging lp:~widelands-dev/widelands-website/auto_copyr_year into lp:widelands-website.

Requested reviews:
  Widelands Developers (widelands-dev)

For more details, see:
https://code.launchpad.net/~widelands-dev/widelands-website/auto_copyr_year/+merge/337911

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

Some cleanups.
-- 
Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands-website/auto_copyr_year into lp:widelands-website.
=== modified file 'mainpage/context_processors.py'
--- mainpage/context_processors.py	2016-12-15 12:55:44 +0000
+++ mainpage/context_processors.py	2018-02-17 11:33:36 +0000
@@ -2,6 +2,5 @@
 
 
 def settings_for_templates(request):
-    context = {'USE_GOOGLE_ANALYTICS': settings.USE_GOOGLE_ANALYTICS,
-               'LOGO_FILE': settings.LOGO_FILE}
+    context = {'USE_GOOGLE_ANALYTICS': settings.USE_GOOGLE_ANALYTICS,}
     return context

=== removed file 'mainpage/templatetags/all_users.py'
--- mainpage/templatetags/all_users.py	2017-11-06 17:50:17 +0000
+++ mainpage/templatetags/all_users.py	1970-01-01 00:00:00 +0000
@@ -1,12 +0,0 @@
-#!/usr/bin/env python -tt
-# encoding: utf-8
-
-from django import template
-from django.contrib.auth.models import User
-
-register = template.Library()
-
-@register.simple_tag
-def all_users():
-    """Provide a list of all users"""
-    return [str(u.username) for u in User.objects.all()]

=== removed file 'mainpage/templatetags/forum_navigation.py'
--- mainpage/templatetags/forum_navigation.py	2016-12-15 12:55:44 +0000
+++ mainpage/templatetags/forum_navigation.py	1970-01-01 00:00:00 +0000
@@ -1,18 +0,0 @@
-from pybb.models import Category
-from django import template
-
-
-register = template.Library()
-
-@register.inclusion_tag('mainpage/forum_navigation.html')
-def forum_navigation():
-    """Makes the forum list available to the navigation, even
-    if it is not loaded directly.
-
-    Ordering:
-    1.: value of 'Position' in pybb.Category
-    2.: value of 'Position' of pybb.Forum.
-
-    """
-    categories = Category.objects.all()
-    return {'categories': categories}

=== removed file 'mainpage/templatetags/get_model_name.py'
--- mainpage/templatetags/get_model_name.py	2017-08-16 22:18:21 +0000
+++ mainpage/templatetags/get_model_name.py	1970-01-01 00:00:00 +0000
@@ -1,8 +0,0 @@
-from django import template
-
-register = template.Library()
-
-@register.filter
-def get_model_name(object):
-    """Returns the name of an objects model"""
-    return object.__class__.__name__
\ No newline at end of file

=== added file 'mainpage/templatetags/wl_extras.py'
--- mainpage/templatetags/wl_extras.py	1970-01-01 00:00:00 +0000
+++ mainpage/templatetags/wl_extras.py	2018-02-17 11:33:36 +0000
@@ -0,0 +1,52 @@
+#!/usr/bin/env python -tt
+# encoding: utf-8
+
+from django import template
+
+register = template.Library()
+
+
+@register.simple_tag
+def current_year():
+    """Just return the current year."""
+
+    from datetime import date
+    return date.today().year
+
+
+@register.simple_tag
+def wl_logo():
+    """Just return the name of the logo."""
+
+    from django.conf import settings
+    return settings.LOGO_FILE
+
+
+@register.simple_tag
+def all_users():
+    """Provide a list of all users."""
+
+    from django.contrib.auth.models import User
+    return [str(u.username) for u in User.objects.all()]
+
+
+@register.inclusion_tag('mainpage/forum_navigation.html')
+def forum_navigation():
+    """Makes the forum list available to the navigation.
+
+    Ordering:
+    1.: value of 'Position' in pybb.Category
+    2.: value of 'Position' of pybb.Forum.
+
+    """
+
+    from pybb.models import Category
+    categories = Category.objects.all()
+    return {'categories': categories}
+
+
+@register.filter
+def get_model_name(object):
+    """Returns the name of an objects model."""
+
+    return object.__class__.__name__

=== modified file 'mainpage/views.py'
--- mainpage/views.py	2017-10-30 11:58:00 +0000
+++ mainpage/views.py	2018-02-17 11:33:36 +0000
@@ -1,4 +1,3 @@
-from django.shortcuts import render_to_response
 from django.template import RequestContext
 from settings import WIDELANDS_SVN_DIR, INQUIRY_RECIPIENTS
 from templatetags.wl_markdown import do_wl_markdown
@@ -7,7 +6,6 @@
 from mainpage.forms import ContactForm
 from django.shortcuts import render
 from django.http import HttpResponseRedirect, HttpResponse
-from django.core.urlresolvers import reverse
 import sys
 import json
 import os
@@ -17,8 +15,7 @@
 
 
 def mainpage(request):
-    return render_to_response('mainpage.html',
-                              context_instance=RequestContext(request))
+    return render(request, 'mainpage.html',)
 
 
 def legal_notice(request):
@@ -132,10 +129,9 @@
 
     txt = do_wl_markdown(txt, custom=False)
 
-    return render_to_response('mainpage/developers.html',
-                              {'developers': txt},
-                              context_instance=RequestContext(request)
-                              )
+    return render(request, 'mainpage/developers.html',
+                  {'developers': txt}
+                  )
 
 
 def changelog(request):
@@ -146,10 +142,9 @@
 
     """
     data = codecs.open(WIDELANDS_SVN_DIR + 'ChangeLog', encoding='utf-8', mode='r').read()
-    return render_to_response('mainpage/changelog.html',
-                              {'changelog': data},
-                              context_instance=RequestContext(request)
-                              )
+    return render(request, 'mainpage/changelog.html',
+                  {'changelog': data},
+                  )
 
 
 def custom_http_500(request):

=== modified file 'templates/base.html'
--- templates/base.html	2017-11-08 08:32:10 +0000
+++ templates/base.html	2018-02-17 11:33:36 +0000
@@ -1,3 +1,4 @@
+{% load wl_extras %}
 
 <!DOCTYPE html>
 {% comment %}
@@ -51,7 +52,7 @@
 				<div class="loginBox posRight">
 					{% include "login_box.html" %}
 				</div>
-				<a href="{% url 'mainpage' %}"><img src="{{ MEDIA_URL }}img/{{ LOGO_FILE }}" class="posLeft" alt="Widelands Logo" /></a>
+				<a href="{% url 'mainpage' %}"><img src="{{ MEDIA_URL }}img/{% wl_logo %}" class="posLeft" alt="Widelands Logo" /></a>
 			</div>
 			<div id="topmenu">
 				<!-- Navigation -->

=== modified file 'templates/django_messages/compose.html'
--- templates/django_messages/compose.html	2017-11-08 08:38:00 +0000
+++ templates/django_messages/compose.html	2018-02-17 11:33:36 +0000
@@ -1,6 +1,6 @@
 {% extends "django_messages/base.html" %} 
 {% load i18n %}
-{% load all_users %}
+{% load wl_extras %}
 
 {% block title %}
 Compose - {{ block.super }}

=== modified file 'templates/footer.html'
--- templates/footer.html	2017-01-23 13:01:31 +0000
+++ templates/footer.html	2018-02-17 11:33:36 +0000
@@ -2,13 +2,11 @@
  vim:ft=htmldjango:
 
  This file is included by mainpage and contains the footer
-
- (which contains nothing at the moment)
 {% endcomment %}
 
-
+{% load wl_extras %}
 
 <div id="footer">
-	Copyright &copy; 2009 - 2017 By the Widelands Development Team<br />
+	Copyright &copy; 2009 - {% current_year %} By the Widelands Development Team<br />
 	<a class="small" href="{% url 'legal_notice' %}">Legal notice (contact)</a>
 </div>

=== modified file 'templates/login_box.html'
--- templates/login_box.html	2018-02-16 15:38:34 +0000
+++ templates/login_box.html	2018-02-17 11:33:36 +0000
@@ -2,73 +2,28 @@
 
 <!-- Login form / User information -->
 {% if user.is_authenticated %}
-<div class="small posLeft">
-	Welcome {{ user|user_link }},<br/>
-    <a href="{% url 'scheduling_main' %}">Playtime Scheduler</a>
-</div>
-<div class="right small posRight">
-	<ul>
-		<li>
-			{% if messages_inbox_count %}
-			<a href="{% url 'messages_inbox' %}" title="You have {{ messages_inbox_count }} new messages">Messages ({{ messages_inbox_count }})</a>
-			{% else %}
-			<a href="{% url 'messages_inbox' %}" title="No new message">Messages</a>
-			{% endif %}
-		</li>
-		<li><a href="{% url 'notification_notices' %}">Notifications</a></li>
-		<li><a href="{% url 'profile_edit' %}">Edit Profile</a></li>
-		<li><a href="{% url 'auth_logout' %}?next={{ request.path|iriencode }}">Logout</a></li>
-	</ul>
-</div>
+	<div class="small posLeft">
+		Welcome {{ user|user_link }},<br/>
+		<a href="{% url 'scheduling_main' %}">Playtime Scheduler</a>
+	</div>
+	<div class="right small posRight">
+		<ul>
+			<li>
+				{% if messages_inbox_count %}
+				<a href="{% url 'messages_inbox' %}" title="You have {{ messages_inbox_count }} new messages">Messages ({{ messages_inbox_count }})</a>
+				{% else %}
+				<a href="{% url 'messages_inbox' %}" title="No new message">Messages</a>
+				{% endif %}
+			</li>
+			<li><a href="{% url 'notification_notices' %}">Notifications</a></li>
+			<li><a href="{% url 'profile_edit' %}">Edit Profile</a></li>
+			<li><a href="{% url 'auth_logout' %}?next={{ request.path|iriencode }}">Logout</a></li>
+		</ul>
+	</div>
 {% else %}
-<h4>Login</h4>
-{% comment %}
-<form method="post" action="https://{{ request.META.HTTP_HOST }}/accounts/login/" id="login_box">
-	<input id="id_login_username" type="text" name="username" maxlength="30" placeholder="Username" />
-	<input id="id_login_password" type="password" name="password" />
-	<input type="hidden" id="submitted" value="false" />
-	<button type="submit">login</button>
-	<input type="hidden" name="next" value="{{ request.path|iriencode }}" />
-	{% csrf_token %}
-</form>
-{% endcomment %}
-<div class="small center">
-	<a href="{% url 'auth_login' %}?next={{ request.path|iriencode }}">Click here to login</a><br />
-	<a href="{% url 'auth_password_reset' %}">Lost password?</a> | <a href="{% url 'registration_register' %}">Register now!</a>
-</div>
+	<h4>Login</h4>
+	<div class="small center">
+		<a href="{% url 'auth_login' %}?next={{ request.path|iriencode }}">Click here to login</a><br />
+		<a href="{% url 'auth_password_reset' %}">Lost password?</a> | <a href="{% url 'registration_register' %}">Register now!</a>
+	</div>
 {% endif %}
-{% comment %}
-{# Login via iframe does not work between http and https #}
-<script type="text/javascript">
-$("#login_box").submit( function(data) {
-	var frameName = "login_frame" + (new Date()).getTime();
-	var frameSrc = "https://{{ request.META.HTTP_HOST }}/accounts/login/?next="
-					+ window.location.pathname + window.location.search + window.location.hash;
-	var loginFrame = $("<iframe name=\"" + frameName + "\" src=\"" + frameSrc + "\" />");
-
-	$("#login_box input[type='submit']").attr("disabled", "disabled")
-	loginFrame.css("display", "none");
-	loginFrame.load(function(data){
-		// get required fields
-		my_user_field = $(window.frames[ frameName ].document.getElementById("id_username"));
-		my_pass_field = $(window.frames[ frameName ].document.getElementById("id_password"));
-		parent_user_field = $("#id_login_username");
-		parent_pass_field = $("#id_login_password");
-		submitted_field = $("#submitted");
-
-		if (submitted_field.val() != "true") {
-			// copy login information and submit
-			my_user_field.val(parent_user_field.val() == "Username" ? "" : parent_user_field.val());
-			my_pass_field.val(parent_pass_field.val());
-			// submit form to parent
-			submitted_field.val("true");
-			login_form = $(window.frames[ frameName ].document.getElementById("login_form"));
-			login_form.attr('target', "_parent");
-			login_form.submit();
-		}
-	});
-	jQuery('body:first').append(loginFrame);
-	return false;
-});
-</script>
-{% endcomment %}

=== modified file 'templates/navigation.html'
--- templates/navigation.html	2018-02-09 16:48:48 +0000
+++ templates/navigation.html	2018-02-17 11:33:36 +0000
@@ -2,7 +2,7 @@
    vim:ft=htmldjango
 {% endcomment %}
 
-{% load forum_navigation %}
+{% load wl_extras %}
 
 <script type="text/javascript">
 	/* Enable dropdown menus on touch devices */

=== modified file 'templates/pagination/pagination_mod.html'
--- templates/pagination/pagination_mod.html	2017-08-16 22:18:21 +0000
+++ templates/pagination/pagination_mod.html	2018-02-17 11:33:36 +0000
@@ -7,7 +7,7 @@
 {% endcomment %}
 
 {% load i18n %}
-{% load get_model_name %}
+{% load wl_extras %}
   {% block previouslink %}
 	<span class="summary">
 		<strong>{{ page_obj.start_index }}</strong> &mdash;


Follow ups