# HG changeset patch # User neko259 # Date 2014-01-19 19:50:21 # Node ID 8b7899f54e5c6edeb9b21fea589aa25aaf76aef5 # Parent 90d66ad5514f704f911bd5bb8b470a3a354240bc Rewriting views to class-based diff --git a/boards/middlewares.py b/boards/middlewares.py --- a/boards/middlewares.py +++ b/boards/middlewares.py @@ -17,14 +17,14 @@ class BanMiddleware: def process_view(self, request, view_func, view_args, view_kwargs): - if view_func != views.you_are_banned: + if view_func != views.banned.BannedView.as_view: ip = utils.get_client_ip(request) bans = Ban.objects.filter(ip=ip) if bans.exists(): ban = bans[0] if not ban.can_read: - return redirect(views.you_are_banned) + return redirect('banned') class MinifyHTMLMiddleware(object): diff --git a/boards/models/post.py b/boards/models/post.py --- a/boards/models/post.py +++ b/boards/models/post.py @@ -356,6 +356,10 @@ class Thread(models.Model): return last_replies + def get_skipped_replies_count(self): + last_replies = self.get_last_replies() + return self.get_reply_count() - len(last_replies) - 1 + def get_replies(self): """ Get sorted thread posts diff --git a/boards/templates/boards/archive.html b/boards/templates/boards/archive.html deleted file mode 100644 --- a/boards/templates/boards/archive.html +++ /dev/null @@ -1,144 +0,0 @@ -{% extends "boards/base.html" %} - -{% load i18n %} -{% load cache %} -{% load board %} -{% load static %} - -{% block head %} -Neboard - {% trans 'Archive' %} - - {% if current_page.has_previous %} - - {% endif %} - {% if current_page.has_next %} - - {% endif %} - -{% endblock %} - -{% block content %} - - {% get_current_language as LANGUAGE_CODE %} - - {% if threads %} - {% if current_page.has_previous %} - - {% endif %} - - {% for thread in threads %} - {% cache 600 thread_short thread.thread.id thread.thread.last_edit_time moderator LANGUAGE_CODE %} -
-
- {% if thread.op.image %} -
- {{ thread.op.id }} - -
- {% endif %} -
- - {% autoescape off %} - {{ thread.op.text.rendered|truncatewords_html:50 }} - {% endautoescape %} - {% if thread.op.is_referenced %} -
- {% trans "Replies" %}: - {% for ref_post in thread.op.get_sorted_referenced_posts %} - >>{{ ref_post.id }}{% if not forloop.last %},{% endif %} - {% endfor %} -
- {% endif %} -
- -
-
- {% endcache %} - {% endfor %} - - {% if current_page.has_next %} - - {% endif %} - {% else %} -
- {% trans 'No threads exist. Create the first one!' %}
- {% endif %} - -{% endblock %} - -{% block metapanel %} - - - Neboard 1.6 Amon - {% trans "Pages:" %}[ - {% for page in paginator.page_range %} - {{ page }} - {% if not forloop.last %},{% endif %} - {% endfor %} - ] - - -{% endblock %} diff --git a/boards/templates/boards/login.html b/boards/templates/boards/login.html --- a/boards/templates/boards/login.html +++ b/boards/templates/boards/login.html @@ -3,7 +3,7 @@ {% load i18n %} {% block head %} - {% trans 'Login' %} + {% trans 'Login' %} - {{ site_name }} {% endblock %} {% block content %} diff --git a/boards/templates/boards/post.html b/boards/templates/boards/post.html --- a/boards/templates/boards/post.html +++ b/boards/templates/boards/post.html @@ -2,82 +2,90 @@ {% load board %} {% spaceless %} -{% if post.thread_new.archived %} -
-{% elif post.thread_new.can_bump %} -
-{% else %} -
-{% endif %} - -{% if post.image %} -
- {{ post.id }} - -
-{% endif %} -
-