refactoring: replace forum_settings filter by forum.context_processors.forum_settings
This commit is contained in:
parent
1728d70cb4
commit
34f8b62eba
11 changed files with 43 additions and 43 deletions
|
@ -60,7 +60,7 @@ class LastPostsOnTopic(ForumFeed):
|
|||
return _('Latest posts on %s topic' % obj.name)
|
||||
|
||||
def items(self, obj):
|
||||
return Post.objects.filter(topic__id__exact=obj.id).order_by('-created')[:15]
|
||||
return Post.objects.filter(topic__id__exact=obj.id).order_by('-created')[:15]
|
||||
|
||||
|
||||
class LastPostsOnForum(ForumFeed):
|
||||
|
@ -84,7 +84,7 @@ class LastPostsOnForum(ForumFeed):
|
|||
return _('Latest posts on %s forum' % obj.name)
|
||||
|
||||
def items(self, obj):
|
||||
return Post.objects.filter(topic__forum__id__exact=obj.id).order_by('-created')[:15]
|
||||
return Post.objects.filter(topic__forum__id__exact=obj.id).order_by('-created')[:15]
|
||||
|
||||
|
||||
class LastPostsOnCategory(ForumFeed):
|
||||
|
@ -103,4 +103,4 @@ class LastPostsOnCategory(ForumFeed):
|
|||
return _('Latest posts on %s category' % obj.name)
|
||||
|
||||
def items(self, obj):
|
||||
return Post.objects.filter(topic__forum__category__id__exact=obj.id).order_by('-created')[:15]
|
||||
return Post.objects.filter(topic__forum__category__id__exact=obj.id).order_by('-created')[:15]
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
</div>
|
||||
</fieldset>
|
||||
</div>
|
||||
{% if "ATTACHMENT_SUPPORT"|forum_setting %}
|
||||
{% if forum_settings.ATTACHMENT_SUPPORT %}
|
||||
<div class="inform">
|
||||
<fieldset>
|
||||
<legend>{% trans "Attachment" %}</legend>
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
{% load forum_extras %}
|
||||
{% load i18n %}
|
||||
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
<title>{{ "FORUM_BASE_TITLE"|forum_setting }} {% block title %}{% endblock %}</title>
|
||||
<meta name="description" content="{{ "FORUM_META_DESCRIPTION"|forum_setting }} " />
|
||||
<meta name="keywords" content="{{ "FORUM_META_KEYWORDS"|forum_setting }}" />
|
||||
<title>{{ forum_settings.FORUM_BASE_TITLE }} {% block title %}{% endblock %}</title>
|
||||
<meta name="description" content="{{ forum_settings.FORUM_META_DESCRIPTION }} " />
|
||||
<meta name="keywords" content="{{ forum_settings.FORUM_META_KEYWORDS }}" />
|
||||
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
|
||||
{% if request.user.is_authenticated %}
|
||||
<link rel="stylesheet" type="text/css" href="{{ MEDIA_URL }}forum/themes/{{ request.user.forum_profile.theme }}/style.css" />
|
||||
|
|
|
@ -72,7 +72,7 @@
|
|||
<div class="clearer"></div>
|
||||
</div>
|
||||
</div>
|
||||
{% if "LOFI_SUPPORT"|forum_setting %}
|
||||
{% if forum_setting.LOFI_SUPPORT %}
|
||||
<div id="brdfooter" class="block">
|
||||
<div class="box">
|
||||
<div class="inbox" align="center">
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
<div id="brdheader" class="block">
|
||||
<div class="box">
|
||||
<div id="brdtitle" class="inbox">
|
||||
<h1><span><a href="{% url djangobb:index %}">{{ "HEADER"|forum_setting }}</a></span></h1>
|
||||
<p><span>{{ "TAGLINE"|forum_setting|safe }}</span></p>
|
||||
<h1><span><a href="{% url djangobb:index %}">{{ forum_setting.HEADER|safe }}</a></span></h1>
|
||||
<p><span>{{ forum_settings.TAGLINE|safe }}</span></p>
|
||||
{% if not user.is_authenticated %}
|
||||
{% endif %}
|
||||
</div>
|
||||
|
@ -21,7 +21,7 @@
|
|||
{% endif %}
|
||||
{% if user.is_authenticated %}
|
||||
<li id="navprofile"><a href="{% url djangobb:forum_profile request.user %}">{% trans "Profile" %}</a></li>
|
||||
{% if "PM_SUPPORT"|forum_setting %}
|
||||
{% if forum_settings.PM_SUPPORT %}
|
||||
<li id="navpm"><a href="{% url djangobb:forum_pm_inbox %}">{% trans "PM" %}</a></li>
|
||||
{% endif %}
|
||||
<li id="navlogout"><a href="{% url user_signout %}?next={{ request.path }}">{% trans "Log out" %}</a></li>
|
||||
|
@ -57,12 +57,12 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
{% if "NOTICE"|forum_setting %}
|
||||
{% if forum_settings.NOTICE %}
|
||||
<div id="announce" class="block">
|
||||
<h2><span>{% trans "Notice" %}</span></h2>
|
||||
<div class="box">
|
||||
<div class="inbox">
|
||||
<div>{{ "NOTICE"|forum_setting }}</div>
|
||||
<div>{{ forum_settings.NOTICE }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -59,7 +59,7 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
{% if "LOFI_SUPPORT"|forum_setting %}
|
||||
{% if forum_settings.LOFI_SUPPORT %}
|
||||
<div id="brdfooter" class="block">
|
||||
<div class="box">
|
||||
<div class="inbox" align="center">
|
||||
|
|
|
@ -14,33 +14,33 @@
|
|||
<dt><strong>{{ post_user|profile_link }}</strong></dt>
|
||||
<dd>
|
||||
{% if post_user.forum_profile.status %}
|
||||
<strong>{{ post_user.forum_profile.status }}</strong>
|
||||
<strong>{{ post_user.forum_profile.status }}</strong>
|
||||
{% else %}
|
||||
<strong>{{ post_user.forum_profile.group }}</strong>
|
||||
<strong>{{ post_user.forum_profile.group }}</strong>
|
||||
{% endif %}
|
||||
</dd>
|
||||
{% if "AUTHORITY_SUPPORT"|forum_setting %}
|
||||
<dd class="usertitle">
|
||||
{{ post_user|forum_authority }}
|
||||
</dd>
|
||||
{% if forum_settings.AUTHORITY_SUPPORT" %}
|
||||
<dd class="usertitle">
|
||||
{{ post_user|forum_authority }}
|
||||
</dd>
|
||||
{% endif %}
|
||||
{% if post_user.forum_profile.avatar %}
|
||||
<dd class="postavatar"><img src="{{ post_user.forum_profile.avatar.url }}" /></dd>
|
||||
<dd class="postavatar"><img src="{{ post_user.forum_profile.avatar.url }}" /></dd>
|
||||
{% endif %}
|
||||
<dd>{% trans "Registered:" %} {{ post_user.date_joined|date:"Y-m-d" }}</dd>
|
||||
<dd>{% trans "Posts:" %} {{ post_user.posts.count }}</dd>
|
||||
{% if moderator %}
|
||||
<dd>{% trans "IP:" %} {{ post_user_ip }}</dd>
|
||||
{% endif %}
|
||||
{% if "REPUTATION_SUPPORT"|forum_setting %}
|
||||
<dd><a href="{% url djangobb:reputation post_user %}">{% trans "Reputation" %}</a> : <b>{{ post_user.forum_profile.reply_total }}</b></dd>
|
||||
<dd>{% trans "IP:" %} {{ post_user_ip }}</dd>
|
||||
{% endif %}
|
||||
{% if forum_settings.REPUTATION_SUPPORT %}
|
||||
<dd><a href="{% url djangobb:reputation post_user %}">{% trans "Reputation" %}</a> : <b>{{ post_user.forum_profile.reply_total }}</b></dd>
|
||||
{% endif %}
|
||||
<dd class="usercontacts"><a href="{% url djangobb:forum_profile post_user %}">{% trans "Profile" %}</a>
|
||||
{% ifequal post_user.forum_profile.privacy_permission 0 %}
|
||||
<a href="mailto:{{ post_user.email }}">{% trans "E-mail" %}</a>
|
||||
<a href="mailto:{{ post_user.email }}">{% trans "E-mail" %}</a>
|
||||
{% endifequal %}
|
||||
{% if user_is_authenticated %}
|
||||
<a href="{% url djangobb:forum_create_pm %}?recipient={{ post_user.username }}">{% trans "PM" %}</a> </dd>
|
||||
<a href="{% url djangobb:forum_create_pm %}?recipient={{ post_user.username }}">{% trans "PM" %}</a> </dd>
|
||||
{% endif %}
|
||||
</dl>
|
||||
</div>
|
||||
|
@ -84,7 +84,5 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% endwith %}
|
||||
{% endblock %}
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
<strong>{{ post.user.forum_profile.group }}</strong>
|
||||
{% endif %}
|
||||
</dd>
|
||||
{% if "AUTHORITY_SUPPORT"|forum_setting %}
|
||||
{% if forum_settings.AUTHORITY_SUPPORT %}
|
||||
<dd class="usertitle">
|
||||
{{ post.user|forum_authority }}
|
||||
</dd>
|
||||
|
@ -53,7 +53,7 @@
|
|||
{% if moderator %}
|
||||
<dd>{% trans "IP:" %} {{ post.user_ip }}</dd>
|
||||
{% endif %}
|
||||
{% if "REPUTATION_SUPPORT"|forum_setting %}
|
||||
{% if forum_settings.REPUTATION_SUPPORT %}
|
||||
{% ifnotequal request.user post.user.username %}
|
||||
<dd><a href="{% url djangobb:reputation post.user %}">{% trans "Reputation" %}</a> : <a href="{% url djangobb:reputation post.user %}?action=plus&topic_id={{ post.topic.id }}"><img src="{{ MEDIA_URL }}forum/img/reputation/warn_add.gif" alt="+" border="0"></a> <strong>{{ post.user.forum_profile.reply_total }} </strong><a href="{% url djangobb:reputation post.user %}?action=minus&topic_id={{ post.topic.id }}"><img src="{{ MEDIA_URL }}forum/img/reputation/warn_minus.gif" alt="-" border="0"></a></dd>
|
||||
{% endifnotequal %}
|
||||
|
@ -66,7 +66,7 @@
|
|||
<a href="{% url djangobb:misc %}?mail_to={{ post.user }}">{% trans "Send e-mail" %}</a>
|
||||
{% endifequal %}
|
||||
{% endifequal %}
|
||||
{% if "PM_SUPPORT"|forum_setting %}
|
||||
{% if forum_settings.PM_SUPPORT %}
|
||||
{% if user.is_authenticated %}
|
||||
<a href="{% url djangobb:forum_create_pm %}?recipient={{ post.user.username }}">{% trans "PM" %}</a> </dd>
|
||||
{% endif %}
|
||||
|
@ -152,7 +152,7 @@
|
|||
</div>
|
||||
</fieldset>
|
||||
</div>
|
||||
{% if "ATTACHMENT_SUPPORT"|forum_setting %}
|
||||
{% if forum_settings.ATTACHMENT_SUPPORT %}
|
||||
<div class="inform">
|
||||
<fieldset>
|
||||
<legend>{% trans "Attachment" %}</legend>
|
||||
|
@ -170,7 +170,7 @@
|
|||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if "LOFI_SUPPORT"|forum_setting %}
|
||||
{% if forum_settings.LOFI_SUPPORT %}
|
||||
<div id="brdfooter" class="block">
|
||||
<div class="box">
|
||||
<div class="inbox" align="center">
|
||||
|
|
|
@ -38,6 +38,7 @@ def forum_time(parser, token):
|
|||
else:
|
||||
return ForumTimeNode(time)
|
||||
|
||||
|
||||
class ForumTimeNode(template.Node):
|
||||
def __init__(self, time):
|
||||
self.time = template.Variable(time)
|
||||
|
@ -55,6 +56,7 @@ class ForumTimeNode(template.Node):
|
|||
else:
|
||||
return time.strftime('%Y-%m-%d %H:%M:%S')
|
||||
|
||||
|
||||
# TODO: this old code requires refactoring
|
||||
@register.inclusion_tag('forum/pagination.html',takes_context=True)
|
||||
def pagination(context, adjacent_pages=1):
|
||||
|
@ -160,11 +162,6 @@ def has_unreads(topic, user):
|
|||
return True
|
||||
|
||||
|
||||
@register.filter
|
||||
def forum_setting(name):
|
||||
return getattr(forum_settings, name, 'NOT DEFINED')
|
||||
|
||||
|
||||
@register.filter
|
||||
def forum_moderated_by(topic, user):
|
||||
"""
|
||||
|
@ -233,14 +230,17 @@ def forum_authority(user):
|
|||
else:
|
||||
return mark_safe('<img src="%sforum/img/authority/vote0.gif" alt="" >' % (settings.MEDIA_URL))
|
||||
|
||||
|
||||
@register.filter
|
||||
def online(user):
|
||||
return cache.get(str(user.id))
|
||||
|
||||
|
||||
@register.filter
|
||||
def pm_unreads(user):
|
||||
return PrivateMessage.objects.filter(dst_user=user, read=False).count()
|
||||
|
||||
|
||||
@register.filter
|
||||
def attachment_link(attach):
|
||||
from django.template.defaultfilters import filesizeformat
|
||||
|
@ -257,10 +257,12 @@ def attachment_link(attach):
|
|||
attachment = '%s <a href="%s">%s</a> (%s)' % (img, attach.get_absolute_url(), attach.name, filesizeformat(attach.size))
|
||||
return mark_safe(attachment)
|
||||
|
||||
|
||||
@register.simple_tag
|
||||
def new_reports():
|
||||
return Report.objects.filter(zapped=False).count()
|
||||
|
||||
|
||||
@register.simple_tag
|
||||
def gravatar(email):
|
||||
if forum_settings.GRAVATAR_SUPPORT:
|
||||
|
|
|
@ -127,7 +127,8 @@ TEMPLATE_CONTEXT_PROCESSORS = (
|
|||
'django.core.context_processors.i18n',
|
||||
'django.core.context_processors.media',
|
||||
'django.core.context_processors.request',
|
||||
'django_authopenid.context_processors.authopenid'
|
||||
'django_authopenid.context_processors.authopenid',
|
||||
'forum.context_processors.forum_settings'
|
||||
)
|
||||
|
||||
# Djapian settings
|
||||
|
@ -142,6 +143,6 @@ LOGIN_URL = '/forum/account/signin/'
|
|||
CACHE_MIDDLEWARE_ANONYMOUS_ONLY = True
|
||||
|
||||
try:
|
||||
from local_settings import *
|
||||
from local_settings import *
|
||||
except ImportError:
|
||||
pass
|
|
@ -8,7 +8,7 @@ class SitemapForum(Sitemap):
|
|||
|
||||
def items(self):
|
||||
return Forum.objects.all()
|
||||
|
||||
|
||||
class SitemapTopic(Sitemap):
|
||||
priority = 0.5
|
||||
|
||||
|
|
Reference in a new issue