← Back to team overview

widelands-dev team mailing list archive

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

 

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

Requested reviews:
  Widelands Developers (widelands-dev)

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

Removed hard coded Forum list in navigation bar, instead using categories/forums which are stored in the database. This makes it possible to reorder the forums/categories over the admin page and reflects the same order as shown in https://wl.widelands.org/forum/

The first ordering relies on the field 'position' in category:

1.: Show all Forums in Category -> position 0
2.: Show all Forums in Category -> position 1
3.: Show all Forums in Category -> position 2

The order of Forum entries relies on the field 'position' set for each forum. An image may be the best to clarify, each forum has a unique value of 'position' inside the category: http://www.directupload.net/file/d/4570/xuucc2ln_png.htm

When merging this we may want to give each Forum an explicit value for 'position' (currently each forum has value 0 for position).

Additional changes:
- Modified the admin page for forum
- Prevent a failure when one is using the code with a fresh database and no sphinxdoc-app is set
-- 
Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands-website/forum_list into lp:widelands-website.
=== added file 'mainpage/templatetags/forum_navigation.py'
--- mainpage/templatetags/forum_navigation.py	1970-01-01 00:00:00 +0000
+++ mainpage/templatetags/forum_navigation.py	2016-12-15 13:21:29 +0000
@@ -0,0 +1,18 @@
+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}

=== modified file 'pybb/admin.py'
--- pybb/admin.py	2016-12-13 18:28:51 +0000
+++ pybb/admin.py	2016-12-15 13:21:29 +0000
@@ -34,7 +34,7 @@
 class ForumAdmin(admin.ModelAdmin):
     list_display = ['name', 'category', 'position', 'topic_count']
     list_per_page = 20
-    ordering = ['-category']
+    ordering = ['category__position', 'position']
     search_fields = ['name', 'category__name']
     fieldsets = (
         (None, {
@@ -42,7 +42,8 @@
         }
         ),
         (_('Additional options'), {
-            'classes': ('collapse',),
+            'description': 'Position is the position inside the category. \
+            This has effect on ordering in forums overview and the navigation bar.',
             'fields': ('position', 'description', 'moderators')
         }
         ),

=== modified file 'settings.py'
--- settings.py	2016-12-13 18:28:51 +0000
+++ settings.py	2016-12-15 13:21:29 +0000
@@ -149,7 +149,7 @@
                 'django.template.context_processors.static',
                 'django.template.context_processors.tz',
                 'django_messages.context_processors.inbox',
-                'mainpage.context_processors.settings_for_templates'
+                'mainpage.context_processors.settings_for_templates',
             ],
         },
     },

=== modified file 'sphinxdoc/sitemap.py'
--- sphinxdoc/sitemap.py	2016-11-07 19:49:40 +0000
+++ sphinxdoc/sitemap.py	2016-12-15 13:21:29 +0000
@@ -3,7 +3,10 @@
 import datetime
 import os
 
-app = App.objects.get(slug='wl')
+try:
+    app = App.objects.get(slug='wl')
+except:
+    pass
 
 
 class DocumentationSitemap(Sitemap):

=== added file 'templates/mainpage/forum_navigation.html'
--- templates/mainpage/forum_navigation.html	1970-01-01 00:00:00 +0000
+++ templates/mainpage/forum_navigation.html	2016-12-15 13:21:29 +0000
@@ -0,0 +1,9 @@
+{% comment %}
+Showing the forum navigation ordered by category position and forum position
+{% endcomment %}
+
+{% for category in categories %}
+	{% for forum in category.forums.all %}
+		<li><a href="{% url 'pybb_forum' forum.id %}">{{ forum.name }}</a></li>
+	{% endfor %}
+{% endfor %}
\ No newline at end of file

=== modified file 'templates/navigation.html'
--- templates/navigation.html	2016-07-02 12:38:06 +0000
+++ templates/navigation.html	2016-12-15 13:21:29 +0000
@@ -2,7 +2,7 @@
    vim:ft=htmldjango
 {% endcomment %}
 
-
+{% load forum_navigation %}
 
 <script type="text/javascript">
 	/* Enable dropdown menus on touch devices */
@@ -44,18 +44,12 @@
 	</li>
 	<li><a href="{% url 'pybb_index' %}">Forums</a>
 		<ul>
-			<li><a href="{% url 'pybb_forum' 1 %}">Technical Help</a></li>
-			<li><a href="{% url 'pybb_forum' 2 %}">Game Suggestions</a></li>
-			<li><a href="{% url 'pybb_forum' 3 %}">Playing Widelands</a></li>
-			<li><a href="{% url 'pybb_forum' 4 %}">Editor Forum</a></li>
-			<li><a href="{% url 'pybb_forum' 5 %}">[Deutsch] - Spielerforum</a></li>
-			<li><a href="{% url 'pybb_forum' 6 %}">[Español] - Foro de jugadores</a></li>
-			<li><a href="{% url 'pybb_forum' 7 %}">[Français] - Forum de joueurs</a></li>
-			<li><a href="{% url 'pybb_forum' 13 %}">[English] - Player Forum</a></li>
-			<li><a href="{% url 'pybb_forum' 9 %}">Graphic Development</a></li>
-			<li><a href="{% url 'pybb_forum' 10 %}">Sound &amp; Music Development</a></li>
-			<li><a href="{% url 'pybb_forum' 11 %}">Homepage</a></li>
-			<li><a href="{% url 'pybb_forum' 12 %}">Translations &amp; Internationalization</a></li>
+			{% forum_navigation %}
+			<!--{% for category in categories %}
+				{% for forum in category.forums.all %}
+					<li><a href="{% url 'pybb_forum' forum.id %}">{{ forum.name }}</a></li>
+				{% endfor %}
+			{% endfor %}-->
 		</ul>
 	</li>
 	<li><a href="{% url 'webchat_index' %}">Chat</a></li>


Follow ups