kaputtnik has proposed merging lp:~widelands-dev/widelands-website/news_rework into lp:widelands-website.
Requested reviews: Widelands Developers (widelands-dev) Related bugs: Bug #1640881 in Widelands Website: "News drafts show in news archive" https://bugs.launchpad.net/widelands-website/+bug/1640881 For more details, see: https://code.launchpad.net/~widelands-dev/widelands-website/news_rework/+merge/311345 Rework of news archive. - Fixes bug 1640881 - No changes for Mainpage - For the Archive i used a table for each filter: - Archive shows all posts in the table - Archive year, shows posts for this year in a table - Archive month, shows posts for this month in a table - Each of the list entries in this views shows an additional column 'Category' with a link to filter by category. - Post detail view is shown if one clicks on the link of a post - Some css changes which i think looks better, see https://bugs.launchpad.net/widelands-website/+bug/1640881/+attachment/4779672/+files/news_new_01.png - Code cleanups -- Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands-website/news_rework into lp:widelands-website.
=== modified file 'media/css/base.css' --- media/css/base.css 2016-07-18 17:07:44 +0000 +++ media/css/base.css 2016-11-20 12:13:26 +0000 @@ -451,3 +451,4 @@ clear: left; } + === modified file 'media/css/news.css' --- media/css/news.css 2012-05-16 22:31:25 +0000 +++ media/css/news.css 2016-11-20 12:13:26 +0000 @@ -0,0 +1,15 @@ +tbody > tr:hover { + background-color: rgba(83,83,83,0.2); +} + +div.linksBox { + background-color: #332f29; + background-image: url("../img/but1.png"); + border-radius: 4px; + border: 1px solid black; + padding: 0.2em; + padding-left: 0.5em; + margin-bottom: 1em; + box-shadow: 4px 4px 4px 0px rgba(0, 0, 0, 0.7); + display: inline-block; +} === modified file 'news/managers.py' --- news/managers.py 2016-02-29 23:14:56 +0000 +++ news/managers.py 2016-11-20 12:13:26 +0000 @@ -3,7 +3,10 @@ class PublicManager(Manager): - """Returns published posts that are not in the future.""" - + """Returns news posts that are: + + - not in the future + - not published""" + def published(self): - return self.get_queryset().filter(status__gte=2, publish__lte=datetime.datetime.now()) \ No newline at end of file + return self.get_queryset().exclude(status=1).filter(publish__lte=datetime.datetime.now()) === modified file 'news/models.py' --- news/models.py 2016-06-08 07:23:37 +0000 +++ news/models.py 2016-11-20 12:13:26 +0000 @@ -5,7 +5,7 @@ from tagging.fields import TagField from news.managers import PublicManager from django.core.urlresolvers import reverse - +import datetime import settings if settings.USE_SPHINX: from djangosphinx.models import SphinxSearch @@ -32,15 +32,11 @@ db_table = 'news_categories' ordering = ('title',) - class Admin: - pass - def __unicode__(self): return u'%s' % self.title - @permalink def get_absolute_url(self): - return ('news_category_detail', None, {'slug': self.slug}) + return reverse('category_posts', args=(self.slug,)) class Post(models.Model): @@ -52,7 +48,7 @@ title = models.CharField(_('title'), max_length=200) slug = models.SlugField(_('slug'), unique_for_date='publish') author = models.ForeignKey(User, null=True) - body = models.TextField(_('body')) + body = models.TextField(_('body'), help_text="Text entered here will be rendered using Markdown") tease = models.TextField(_('tease'), blank=True) status = models.IntegerField(_('status'), choices=STATUS_CHOICES, default=2) allow_comments = models.BooleanField(_('allow comments'), default=True) @@ -79,11 +75,6 @@ ordering = ('-publish',) get_latest_by = 'publish' - class Admin: - list_display = ('title', 'publish', 'status') - list_filter = ('publish', 'categories', 'status') - search_fields = ('title', 'body') - def __unicode__(self): return u'%s' % self.title @@ -109,18 +100,21 @@ return '' return self.categories.all()[0].title - @permalink def get_absolute_url(self): - return ('news_detail', None, { - 'slug': self.slug, - 'year': self.publish.year, - 'month': self.publish.strftime('%b'), - 'day': self.publish.day, - }) - + return reverse('news_detail', args=(self.publish.year, self.publish.strftime('%b'), self.publish.day, self.slug, )) + + def get_category_slug(self): + try: + s = self.categories.all()[0].slug + except IndexError: + return 'none' + return s + def get_previous_post(self): + # get_previous_by_FOO(**kwargs) is a django model function return self.get_previous_by_publish(status__gte=2) def get_next_post(self): - return self.get_next_by_publish(status__gte=2) + # get_next_by_FOO(**kwargs) is a django model function + return self.get_next_by_publish(status__gte=2, publish__lte=datetime.datetime.now()) === modified file 'news/templatetags/news_extras.py' --- news/templatetags/news_extras.py 2016-05-12 19:34:41 +0000 +++ news/templatetags/news_extras.py 2016-11-20 12:13:26 +0000 @@ -46,88 +46,3 @@ raise template.TemplateSyntaxError, "%s tag had invalid arguments" % tag_name format_string, var_name = m.groups() return LatestPosts(format_string, var_name) - -class NewsYears(template.Node): - def __init__(self, var_name): - self.var_name = var_name - - def render(self, context): - years = Post.objects.all().dates('publish', 'year') - context[self.var_name] = years - return '' - -@register.tag -def get_news_years(parser, token): - """ - Gets any number of latest posts and stores them in a varable. - - Syntax:: - - {% get_latest_posts [limit] as [var_name] %} - - Example usage:: - - {% get_latest_posts 10 as latest_post_list %} - """ - try: - tag_name, arg = token.contents.split(None, 1) - except ValueError: - raise template.TemplateSyntaxError, "%s tag requires arguments" % token.contents.split()[0] - m = re.search(r'as (\w+)', arg) - if not m: - raise template.TemplateSyntaxError, "%s tag had invalid arguments" % tag_name - (var_name, ) = m.groups() - return NewsYears(var_name) - -class NewsCategories(template.Node): - def __init__(self, var_name): - self.var_name = var_name - - def render(self, context): - categories = Category.objects.all() - context[self.var_name] = categories - return '' - -@register.tag -def get_news_categories(parser, token): - """ - Gets all news categories. - - Syntax:: - - {% get_news_categories as [var_name] %} - - Example usage:: - - {% get_news_categories as category_list %} - """ - try: - tag_name, arg = token.contents.split(None, 1) - except ValueError: - raise template.TemplateSyntaxError, "%s tag requires arguments" % token.contents.split()[0] - m = re.search(r'as (\w+)', arg) - if not m: - raise template.TemplateSyntaxError, "%s tag had invalid arguments" % tag_name - var_name = m.groups()[0] - return NewsCategories(var_name) - - -@register.filter -def get_links(value): - """ - Extracts links from a ``Post`` body and returns a list. - - Template Syntax:: - - {{ post.body|markdown:"safe"|get_links }} - - """ - try: - from BeautifulSoup import BeautifulSoup - soup = BeautifulSoup(value) - return soup.findAll('a') - except ImportError: - if settings.DEBUG: - raise template.TemplateSyntaxError, "Error in 'get_links' filter: BeautifulSoup isn't installed." - return value - === modified file 'news/urls.py' --- news/urls.py 2016-06-04 14:17:40 +0000 +++ news/urls.py 2016-11-20 12:13:26 +0000 @@ -1,42 +1,25 @@ from django.conf.urls import * -from news.models import Post -from django.views.generic.dates import DateDetailView, YearArchiveView, MonthArchiveView from django.views.generic import ListView +from news.views import NewsList, YearNews, MonthNews, NewsDetail, CategoryView urlpatterns = [ url(r'^(?P<year>[0-9]{4})/(?P<month>[-\w]+)/(?P<day>[0-9]+)/(?P<slug>[-\w]+)/$', - DateDetailView.as_view(model=Post, date_field="publish", template_name="news/post_detail.html"), + NewsDetail.as_view(), name='news_detail'), - # url(r'^(?P<year>\d{4})/(?P<month>\d{1,2})/(?P<day>\d{1,2})/$', - # view=news_views.post_archive_day, - # name='news_archive_day'), - # - # url(r'^(?P<year>\d{4})/(?P<month>\d{1,2})/$', - # view=news_views.post_archive_month, - # name='news_archive_month'), - # - url(r'^(?P<year>\d{4})/(?P<month>[-\w]+)/$', - MonthArchiveView.as_view(model=Post, date_field="publish"), + url(r'^(?P<year>\d{4})/(?P<month>[-\w]+)/$', + MonthNews.as_view(), name='news_archive_month'), - url(r'^(?P<year>\d{4})/$', - YearArchiveView.as_view(model=Post, make_object_list=True, date_field="publish", template_name="post_archive_year.html"), + url(r'^(?P<year>\d{4})/$', + YearNews.as_view(), name='news_archive_year'), - # - # # url(r'^categories/(?P<slug>[-\w]+)/$', - # # view=news_views.category_detail, - # # name='news_category_detail'), - # # - # # url (r'^categories/$', - # # view=news_views.category_list, - # # name='news_category_list'), - # - # url(r'^page/(?P<page>\w)/$', - # ListView.as_view(model=Post, template_name="news/post_list.html"), - # name='news_index_paginated'), + + url(r'^category/(?P<slug>[-\w]+)/', + CategoryView.as_view(), + name='category_posts'), url(r'^$', - ListView.as_view(model=Post, template_name="news/post_list.html"), + NewsList.as_view(template_name = 'news/post_list.html'), name='news_index'), ] === added file 'news/views.py' --- news/views.py 1970-01-01 00:00:00 +0000 +++ news/views.py 2016-11-20 12:13:26 +0000 @@ -0,0 +1,72 @@ +from django.shortcuts import get_object_or_404 +from news.models import Post, Category +from django.views.generic import \ + ListView, \ + ArchiveIndexView, \ + YearArchiveView, \ + MonthArchiveView, \ + DetailView +import datetime + + +class NewsList(ArchiveIndexView): + + template_name = 'news/category_posts.html' + queryset = Post.objects.published() + date_field = 'publish' + + def get_context_data(self, **kwargs): + # Call the base implementation first to get a context + context = super(NewsList, self).get_context_data(**kwargs) + + context['categories'] = Category.objects.all() + return context + + +class YearNews(YearArchiveView): + + queryset = Post.objects.published() + template_name = 'news/post_archive_year.html' + date_field = 'publish' + make_object_list = True + + +class MonthNews(MonthArchiveView): + + queryset = Post.objects.published() + template_name = 'news/post_archive_month.html' + date_field = 'publish' + + +class NewsDetail(DetailView): + + queryset = Post.objects.published() + template_name = 'news/post_detail.html' + + +class CategoryView(ListView): + + template_name = 'news/category_posts.html' + + def get_context_data(self, **kwargs): + # Call the base implementation first to get a context + context = super(CategoryView, self).get_context_data(**kwargs) + if self.kwargs['slug'] == 'none': + # Exemption for posts with no category + context['cur_category'] = 'None' + else: + context['cur_category'] = get_object_or_404( + Category, slug=self.kwargs['slug']) + + context['categories'] = Category.objects.all() + return context + + def get_queryset(self): + # Gather posts filtered by category + if self.kwargs['slug'] == 'none': + # Posts mustn't have a category + qs = Post.objects.published().filter(categories=None) + else: + qs = Post.objects.published().filter( + categories__slug=self.kwargs['slug']) + return qs === removed file 'news/views.py.delete' --- news/views.py.delete 2016-03-02 21:02:38 +0000 +++ news/views.py.delete 1970-01-01 00:00:00 +0000 @@ -1,164 +0,0 @@ -from django.shortcuts import render_to_response, get_object_or_404 -from django.template import RequestContext -from django.http import Http404 -#from django.views.generic import date_based, list_detail -from django.db.models import Q -from news.models import * -from django.views import generic -from django.views.generic.dates import DateDetailView - -import datetime -import re - - - -def post_list(request, page=0, **kwargs): - return list_detail.object_list( - request, - queryset = Post.objects.published(), - page = page, - **kwargs - ) -#post_list.__doc__ = list_detail.object_list.__doc__ - -def post_archive_year(request, year, **kwargs): - return date_based.archive_year( - request, - year = year, - date_field = 'publish', - queryset = Post.objects.published(), - make_object_list = True, - **kwargs - ) -#post_archive_year.__doc__ = date_based.archive_year.__doc__ - - -def post_archive_month(request, year, month, **kwargs): - return date_based.archive_month( - request, - year = year, - month = month, - month_format = "%m", - date_field = 'publish', - queryset = Post.objects.published(), - **kwargs - ) -#post_archive_month.__doc__ = date_based.archive_month.__doc__ - - -def post_archive_day(request, year, month, day, **kwargs): - return date_based.archive_day( - request, - year = year, - month = month, - month_format = "%m", - day = day, - date_field = 'publish', - queryset = Post.objects.published(), - **kwargs - ) -#post_archive_day.__doc__ = date_based.archive_day.__doc__ - - -def post_detail(request, slug, year, month, day, **kwargs): - return date_based.object_detail( - request, - year = year, - month = month, - month_format = "%m", - day = day, - date_field = 'publish', - slug = slug, - queryset = Post.objects.published(), - **kwargs - ) -#post_detail.__doc__ = date_based.object_detail.__doc__ - - -def category_list(request, template_name = 'news/category_list.html', **kwargs): - """ - Category list - - Template: ``news/category_list.html`` - Context: - object_list - List of categories. - """ - return list_detail.object_list( - request, - queryset = Category.objects.all(), - template_name = template_name, - **kwargs - ) - -def category_detail(request, slug, template_name = 'news/category_detail.html', **kwargs): - """ - Category detail - - Template: ``news/category_detail.html`` - Context: - object_list - List of posts specific to the given category. - category - Given category. - """ - category = get_object_or_404(Category, slug__iexact=slug) - - return list_detail.object_list( - request, - queryset = category.post_set.published(), - extra_context = {'category': category}, - template_name = template_name, - **kwargs - ) - - -# Stop Words courtesy of http://www.dcs.gla.ac.uk/idom/ir_resources/linguistic_utils/stop_words -STOP_WORDS = r"""\b(a|about|above|across|after|afterwards|again|against|all|almost|alone|along|already|also| -although|always|am|among|amongst|amoungst|amount|an|and|another|any|anyhow|anyone|anything|anyway|anywhere|are| -around|as|at|back|be|became|because|become|becomes|becoming|been|before|beforehand|behind|being|below|beside| -besides|between|beyond|bill|both|bottom|but|by|call|can|cannot|cant|co|computer|con|could|couldnt|cry|de|describe| -detail|do|done|down|due|during|each|eg|eight|either|eleven|else|elsewhere|empty|enough|etc|even|ever|every|everyone| -everything|everywhere|except|few|fifteen|fify|fill|find|fire|first|five|for|former|formerly|forty|found|four|from| -front|full|further|get|give|go|had|has|hasnt|have|he|hence|her|here|hereafter|hereby|herein|hereupon|hers|herself| -him|himself|his|how|however|hundred|i|ie|if|in|inc|indeed|interest|into|is|it|its|itself|keep|last|latter|latterly| -least|less|ltd|made|many|may|me|meanwhile|might|mill|mine|more|moreover|most|mostly|move|much|must|my|myself|name| -namely|neither|never|nevertheless|next|nine|no|nobody|none|noone|nor|not|nothing|now|nowhere|of|off|often|on|once| -one|only|onto|or|other|others|otherwise|our|ours|ourselves|out|over|own|part|per|perhaps|please|put|rather|re|same| -see|seem|seemed|seeming|seems|serious|several|she|should|show|side|since|sincere|six|sixty|so|some|somehow|someone| -something|sometime|sometimes|somewhere|still|such|system|take|ten|than|that|the|their|them|themselves|then|thence| -there|thereafter|thereby|therefore|therein|thereupon|these|they|thick|thin|third|this|those|though|three|through| -throughout|thru|thus|to|together|too|top|toward|towards|twelve|twenty|two|un|under|until|up|upon|us|very|via|was| -we|well|were|what|whatever|when|whence|whenever|where|whereafter|whereas|whereby|wherein|whereupon|wherever|whether| -which|while|whither|who|whoever|whole|whom|whose|why|will|with|within|without|would|yet|you|your|yours|yourself| -yourselves)\b""" - - -def search(request, template_name='news/post_search.html'): - """ - Search for news posts. - - This template will allow you to setup a simple search form that will try to return results based on - given search strings. The queries will be put through a stop words filter to remove words like - 'the', 'a', or 'have' to help imporve the result set. - - Template: ``news/post_search.html`` - Context: - object_list - List of news posts that match given search term(s). - search_term - Given search term. - """ - context = {} - if request.GET: - stop_word_list = re.compile(STOP_WORDS, re.IGNORECASE) - search_term = '%s' % request.GET['q'] - cleaned_search_term = stop_word_list.sub('', search_term) - cleaned_search_term = cleaned_search_term.strip() - if len(cleaned_search_term) != 0: - post_list = Post.objects.published().filter(Q(body__icontains=cleaned_search_term) | Q(tags__icontains=cleaned_search_term) | Q(categories__title__icontains=cleaned_search_term)) - context = {'object_list': post_list, 'search_term':search_term} - else: - message = 'Search term was too vague. Please try again.' - context = {'message':message} - return render_to_response(template_name, context, context_instance=RequestContext(request)) === modified file 'templates/news/base_news.html' --- templates/news/base_news.html 2012-04-02 09:41:12 +0000 +++ templates/news/base_news.html 2016-11-20 12:13:26 +0000 @@ -1,7 +1,8 @@ {% extends "base.html" %} -{% block title %}News Archive - {{block.super}}{% endblock %} +{% block title %}News Archive {% endblock %} {% block extra_head %} <link rel="alternate" type="application/rss+xml" title="Widelands News" href="/feeds/news/" /> +<link rel="stylesheet" type="text/css" media="all" href="{{ MEDIA_URL }}css/news.css" /> {{ block.super}}{% endblock %} === removed file 'templates/news/category_list.html' --- templates/news/category_list.html 2009-02-21 18:24:02 +0000 +++ templates/news/category_list.html 1970-01-01 00:00:00 +0000 @@ -1,20 +0,0 @@ -{% extends "news/base_news.html" %} - - -{% block title %}Post categories{% endblock %} -{% block body_class %}{{ block.super }} category_list{% endblock %} - - -{% block content_title %} - <h2>Post categories</h2> -{% endblock %} - - -{% block content %} - {% load markup %} - <ul class="link_list"> - {% for category in object_list %} - <li><a href="{{ category.get_absolute_url }}">{{ category }}</a></li> - {% endfor %} - </ul> -{% endblock %} === renamed file 'templates/news/category_detail.html' => 'templates/news/category_posts.html' --- templates/news/category_detail.html 2009-03-16 17:28:02 +0000 +++ templates/news/category_posts.html 2016-11-20 12:13:26 +0000 @@ -1,26 +1,40 @@ {% extends "news/base_news.html" %} - - -{% block title %}Posts for {{ category.title }}{% endblock %} -{% block body_class %}{{ block.super }} category_detail{% endblock %} -{% block body_id %}category_{{ category.id }}{% endblock %} +{% load pagination_tags %} +{% load threadedcommentstags %} {% load custom_date %} - -{% block content_title %} - <h2>Posts for {{ category.title }}</h2> -{% endblock %} - - {% block content %} - {% load markup %} - <div class="post_list"> - {% for post in object_list %} - <div> - <h3 class="title"><a href="{{ post.get_absolute_url }}">{{ post.title }}</a></h3> - <p class="date">{{ post.publish|custom_date:user }}</p> - <p class="tease">{{ post.tease }}</p> - </div> +<h1>Posts for Category: {{ cur_category }}</h1> +<div> + <div class="linksBox"> + <a href="{% url 'news_index' %}">News Archive</a> + </div> + <br /> + <div class="linksBox">Other Categories: + {% for category in categories %} + <a href="{% url 'category_posts' slug=category.slug %}">{{ category }} </a> | + {% endfor %} + {# Speciallink to provide posts which have no category #} + <a href="{% url 'category_posts' slug='none' %}"> None </a> + </div> +</div> +<div class="blogEntry"> + <div class="center"> + {% autopaginate post_list 20 %} + {% paginate %} + </div> + <table width="100%"> + <th align="left">Title</th> + <th>Posted at</th> + <th>Comments</th> + {% for post in post_list %} + {% get_comment_count for post as ccount %} + <tr> + <td><a href="{{ post.get_absolute_url }}">{{ post.title }}</a></td> + <td align="center">{{ post.publish|custom_date:user }}</td> + <td align="center"> {{ ccount }}</td> + </tr> {% endfor %} - </div> + </table> +</div> {% endblock %} === modified file 'templates/news/inlines/post_detail.html' --- templates/news/inlines/post_detail.html 2016-06-15 19:20:24 +0000 +++ templates/news/inlines/post_detail.html 2016-11-20 12:13:26 +0000 @@ -5,20 +5,25 @@ {% endcomment %} {% load threadedcommentstags %} -{% load news_extras wl_markdown tagging_tags wlprofile_extras custom_date %} +{% load wl_markdown wlprofile_extras custom_date %} <div class="blogEntry"> {% if object.has_image %} - <a href="{{ object.get_absolute_url }}"><img class="title posLeft" src='{{MEDIA_URL}}{{ object.image|urlencode }}' alt='{{ object.image_alt }}' /></a> + <a href="{% url 'category_posts' slug=object.get_category_slug %}"> + <img class="title posLeft" src="{{MEDIA_URL}}{{ object.image|urlencode }}" alt="{{ object.image_alt }}"> + </a> {% endif %} {% if perms.news %} - <div class="small posRight invertedColor"> + <div class="small posRight invertedColor"> {% if perms.news.add_post %}<a href="/admin/news/post/add/">Add New News</a>{% endif %} {% if perms.news.change_post %}| <a href="/admin/news/post/{{object.id}}/">Edit</a>{% endif %} - </div> + </div> {% endif %} - <h2><a href="{{ object.get_absolute_url }}" class="invertedColor">{{ object.title }}</a></h2> + + <h2>{{ object.title }}</h2> + {{ object.body|wl_markdown }} + <hr /> {% get_comment_count for object as ccount %} <span class="small posLeft"><a href="{{ object.get_absolute_url }}">{{ ccount }} comments</a></span> === added file 'templates/news/inlines/posts_table.html' --- templates/news/inlines/posts_table.html 1970-01-01 00:00:00 +0000 +++ templates/news/inlines/posts_table.html 2016-11-20 12:13:26 +0000 @@ -0,0 +1,41 @@ +{% comment %} +List all news in a table +{% endcomment %} + +{% load threadedcommentstags %} +{% load custom_date %} +{% load pagination_tags %} + +<div class="blogEntry"> + <div class="center"> + {% autopaginate object_list 20 %} + {% paginate %} + </div> + <table width="100%"> + <caption></caption> + <thead> + <tr> + <th align="left">Title</th> + <th>Published</th> + <th>Comments</th> + <th align="right">Category</th> + </tr> + </thead> + <tbody> + {% for object in object_list %} + {% get_comment_count for object as ccount %} + <tr> + <td><a href="{{object.get_absolute_url}}">{{ object.title }}</a></td> + <td align="center">{{ object.publish|custom_date:user }}</td> + <td align="center">{{ ccount }}</td> + <td align="right"><a href=" {% url 'category_posts' slug=object.get_category_slug %}"> {{ object.get_category_slug|title }}</a></td> + </tr> + {% endfor %} + </tbody> + </table> + {% if page_obj.has_other_pages %} + <div class="center"> + {% paginate %} + </div> + {% endif %} +</div> === removed file 'templates/news/post_archive_day.html' --- templates/news/post_archive_day.html 2016-06-06 18:26:47 +0000 +++ templates/news/post_archive_day.html 1970-01-01 00:00:00 +0000 @@ -1,29 +0,0 @@ -{% extends "news/base_news.html" %} -{% load custom_date %} -{% load pagination_tags %} -{% block title %}Post archive for {{ day|date:"d F Y" }}{% endblock %} -{% block body_class %}{{ block.super }} post_archive_day{% endblock %} - -{% block content %} -{% include "django_messages/inlines/navigation.html" %} -<br /> -<br /> -<div class="muttis_liebling"> - <div class="box_item_model even show_center"> - <a href="{% url 'news_index' %}{{ day|date:"Y" }}/{{ day|date:"m" }}">Archiv {{ day|date:"F" }}</a> - {% autopaginate object_list 10 %} - {% paginate %} - </div> - <br /> - {% for object in object_list %} - {% include "news/inlines/post_detail.html" %} - <br /> - {% endfor %} - <br /> - {% if page_obj.has_other_pages %} - <div class="box_item_model even show_center"> - {% paginate %} - </div> - {% endif %} -</div> -{% endblock %} === modified file 'templates/news/post_archive_month.html' --- templates/news/post_archive_month.html 2016-03-04 19:44:10 +0000 +++ templates/news/post_archive_month.html 2016-11-20 12:13:26 +0000 @@ -1,35 +1,16 @@ {% extends "news/base_news.html" %} -{% load custom_date %} -{% load news_extras %} -{% load pagination_tags %} -{#{% load markup %}#} -{% block title %}{{ month|date:"F - Y" }} - {{block.super}}}{% endblock %} +{% block title %}{{ month|date:"F - Y" }} - {{block.super}} {% endblock %} {% block content %} -<h1>News Archive</h1> -<a href="{% url 'news_index' %}" class="invertedColor">News Archiv</a> » -<a href="{% url 'news_index' %}{{ month|date:"Y" }}/" class="invertedColor">{{ month|date:"Y" }}</a> » -<a href="{% url 'news_index' %}{{ month|date:"Y" }}/{{ month|date:"b" }}/" class="invertedColor">{{ month|date:"F" }}</a> -{% for day in object_list %} -{% endfor %} -<br /> - -<div class="center"> -{% autopaginate object_list 10 %} -{% paginate %} -</div> -<br /> - -{% for object in object_list %} - {% include "news/inlines/post_detail.html" %} -{% endfor %} -{% if page_obj.has_other_pages %} - -<div class="box_item_model even show_center"> -{% paginate %} -</div> -{% endif %} +<h1>News Archive: {{ month|date:"F" }} {{ month|date:"Y" }}</h1> +<div class="linksBox"> +<a href="{% url 'news_index' %}">News Archiv</a> » +<a href="{% url 'news_index' %}{{ month|date:"Y" }}/">{{ month|date:"Y" }}</a> » +<a href="{% url 'news_index' %}{{ month|date:"Y" }}/{{ month|date:"b" }}/">{{ month|date:"F" }}</a> +</div> + +{% include "news/inlines/posts_table.html" %} {% endblock %} === modified file 'templates/news/post_archive_year.html' --- templates/news/post_archive_year.html 2016-03-04 19:44:10 +0000 +++ templates/news/post_archive_year.html 2016-11-20 12:13:26 +0000 @@ -1,35 +1,20 @@ {% extends "news/base_news.html" %} -{% load custom_date %} -{% load news_extras %} -{% load pagination_tags %} -{#{% load markup %}#} {% block title %}{{ year }} - {{ block.super }}{% endblock %} {% block content %} -<h1>News Archive</h1> -<a href="{% url 'news_index' %}" class="invertedColor">News Archiv</a> » -<a href="{% url 'news_index' %}{{ year|date:"Y" }}" class="invertedColor">{{ year|date:"Y" }}</a>: +<h1>News Archive: {{ year|date:"Y" }}</h1> +<div class="linksBox"> +<a href="{% url 'news_index' %}">News Archiv </a>» +<a href="{% url 'news_index' %}{{ year|date:"Y" }}">{{ year|date:"Y" }}</a> : + {% for month in date_list %} - <a href="{% url 'news_index' %}{{ year|date:"Y" }}/{{ month|date:"b" }}/" class="invertedColor">{{ month|date:"F" }}</a> + <a href="{% url 'news_index' %}{{ year|date:"Y" }}/{{ month|date:"b" }}/">{{ month|date:"F" }}</a> {% if not forloop.last %} | {% endif %} {% endfor %} -<br /> - -<div class="center"> -{% autopaginate object_list 10 %} -{% paginate %} -</div> -<br /> -{% for object in object_list %} - {% include "news/inlines/post_detail.html" %} -{% endfor %} -{% if page_obj.has_other_pages %} - -<div class="center"> -{% paginate %} -</div> -{% endif %} +</div> + +{% include "news/inlines/posts_table.html" %} {% endblock %} === modified file 'templates/news/post_detail.html' --- templates/news/post_detail.html 2016-06-07 18:24:20 +0000 +++ templates/news/post_detail.html 2016-11-20 12:13:26 +0000 @@ -1,34 +1,36 @@ {% extends "news/base_news.html" %} -{% load wlprofile_extras %} +{% comment %} +Base view to show a news post in the archive +{% endcomment %} + + {% load threadedcommentstags %} -{% load news_extras %} {% block title %}{{ object.title }} - {{ block.super }}{% endblock %} {% block extra_head %} {{ block.super }} -<link rel="stylesheet" type="text/css" media="all" href="{{ MEDIA_URL }}css/news.css" /> -<link rel="stylesheet" type="text/css" media="all" href="{{ MEDIA_URL }}css/comments.css" /> + <link rel="stylesheet" type="text/css" media="all" href="{{ MEDIA_URL }}css/news.css" /> + <link rel="stylesheet" type="text/css" media="all" href="{{ MEDIA_URL }}css/comments.css" /> {% endblock %} {% block content %} -<h1>News: {{ object.title }}</h1> -<a class="invertedColor" href="{% url 'news_index' %}">News Archive: </a> -{% if object.get_previous_by_publish %} -<a class="invertedColor" href="{{ object.get_previous_post.get_absolute_url }}">« {{ object.get_previous_post }}</a> -{% endif %} -| -{% if object.get_next_by_publish %} -<a class="invertedColor" href="{{ object.get_next_post.get_absolute_url }}">{{ object.get_next_post }} »</a> -{% endif %} -<br /><br /> - -{% include "news/inlines/post_detail.html" %} - -<div class="blogEntry"> - - <h3>Comments on this Post:</h3> - {% include "threadedcomments/inlines/comments.html" %} -</div> + <h1>News: {{ object.title }}</h1> + <div class="linksBox"> + <a href="{% url 'news_index' %}">News Archive: </a> + {% if object.get_previous_by_publish %} + <a href="{{ object.get_previous_post.get_absolute_url }}">« {{ object.get_previous_post }}</a> + {% endif %} + {% if object.get_next_post %} + | <a href="{{ object.get_next_post.get_absolute_url }}">{{ object.get_next_post }} »</a> + {% endif %} + </div> + + {% include "news/inlines/post_detail.html" %} + + <div class="blogEntry"> + <h3>Comments on this Post:</h3> + {% include "threadedcomments/inlines/comments.html" %} + </div> {% endblock %} === modified file 'templates/news/post_list.html' --- templates/news/post_list.html 2016-06-07 18:24:20 +0000 +++ templates/news/post_list.html 2016-11-20 12:13:26 +0000 @@ -1,44 +1,21 @@ {% extends "news/base_news.html" %} -{% load news_extras %} -{% load threadedcommentstags custom_date %} -{% load pagination_tags %} - {% block content %} <h1>News Archive</h1> -<div> -{% get_news_years as news_years %} -<a href="{% url 'news_index' %}" class="invertedColor">News Archiv</a>: -{% for muh in news_years %} - <a href="{% url 'news_index' %}{{ muh.year }}" class="invertedColor">{{ muh.year }}</a> - {% if not forloop.last %} | {% endif %} -{% endfor %} +<div class="linksBox"> + <a href="{% url 'news_index' %}">News Archiv: </a> + {% for dateobj in date_list reversed %} + <a href="{% url 'news_index' %}{{ dateobj|date:'Y' }}">{{ dateobj|date:'Y' }}</a> + {% if not forloop.last %} | {% endif %} + {% endfor%} </div> {% if perms.news %} - <div class="small posRight invertedColor"> - {% if perms.news.add_post %}<a href="/admin/news/post/add/" class="invertedColor">Add New News</a>{% endif %} - {% if perms.news.change_post %}| <a href="/admin/news/post/{{object.id}}/" class="invertedColor">Edit</a>{% endif %} + <div class="small posRight linksBox"> + {% if perms.news.add_post %}<a href="/admin/news/post/add/">Add New News</a>{% endif %} </div> {% endif %} -<br /> -<div class="blogEntry"> - <div class="center"> - {% autopaginate object_list 20 %} - {% paginate %} - </div> - <ul> - {% for object in object_list %} - {% get_comment_count for object as ccount %} - <li><a href="{{object.get_absolute_url}}">{{ object.title }}</a> - <span class="small">posted at {{ object.publish|custom_date:user }}, {{ ccount }} comments</span></li> - {% endfor %} - </ul> -{% if page_obj.has_other_pages %} -<div class="center"> -{% paginate %} -</div> -{% endif %} -</div> +{% include "news/inlines/posts_table.html" %} {% endblock %}
_______________________________________________ Mailing list: https://launchpad.net/~widelands-dev Post to : widelands-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~widelands-dev More help : https://help.launchpad.net/ListHelp