Use the forums as the source of news

This commit is contained in:
Trever Fischer
2012-04-18 11:10:05 -04:00
parent df4fc07cbc
commit 0826e01bd2
4 changed files with 12 additions and 8 deletions

View File

@@ -13,8 +13,8 @@ from django.core.exceptions import ObjectDoesNotExist
import forms
import models
from forums.models import Forum
from news.models import Post
from minecraft.forms import ProfileForm
from django.conf import settings
@login_required
def profile(request):
@@ -116,6 +116,10 @@ def list(request):
return render_to_response('local/list.html', {'profiles': profiles}, context_instance = RequestContext(request))
def index(request):
latestNews = Post.objects.all()[0]
newsForum = Forum.objects.get(id=settings.CAMINUS_NEWS_FORUM_ID)
try:
latestNews = newsForum.topic_set.order_by('-created')[0]
except IndexError, e:
latestNews = None
forums = Forum.objects.filter(parent=None)
return render_to_response('local/index.html', {'news': latestNews, 'forums': forums}, context_instance = RequestContext(request))

View File

@@ -126,7 +126,6 @@ INSTALLED_APPS = (
'api',
'django.contrib.markup',
'south',
'news',
'django.contrib.flatpages',
'minecraft',
'petition',

View File

@@ -5,17 +5,19 @@
{%block title %}Caminus{% endblock %}
{% block content %}
{% if news %}
<div class='item news-item'>
<h2><a href="{{news.get_absolute_url}}">{{news.title}}</a></h2>
<div class="byline">By <span itemprop="author">{{news.author}}</span> <div class="avatar">{% avatar news.author %}</div></div>
<div class="byline">By <span itemprop="author">{{news.rootPost.user}}</span> <div class="avatar">{% avatar news.rootPost.user %}</div></div>
<div class="dateline">Posted {{news.created|timesince}} ago</div>
<div class="content" itemprop="articleBody">
{{news.body|truncatewords:"100"|markdown}}
{{news.rootPost.body|truncatewords:"100"|markdown}}
</div>
<div class="commentcount"><a href="{{news.get_absolute_url}}"><span itemprop="interactionCount">{{news.comments.all|length}} comment{{news.comments.all|length|pluralize}}</span> &raquo;</a></div>
<div class="commentcount"><a href="{{news.get_absolute_url}}"><span itemprop="interactionCount">{{news.rootPost.get_descendant_count}} comment{{news.rootPost.get_descendant_count|pluralize}}</span> &raquo;</a></div>
<br style="clear:both"/>
<a href="{% url news.views.index %}">News Archive &raquo;</a>
<a href="{{ news.forum.get_absolute_url }}">News Forum &raquo;</a>
</div>
{% endif %}
<div class="item">
<h2>Forums</h2>
{%include "forums/_forum_table.html" with forums=forums%}

View File

@@ -8,7 +8,6 @@ urlpatterns = patterns('',
url(r'^$', 'local.views.index', name='home'),
url(r'^petitions/', include('petition.urls')),
url(r'^comments/', include('django.contrib.comments.urls')),
url(r'^news/', include('news.urls')),
url(r'^minecraft/', include('minecraft.urls')),
url(r'^mail/', include('messages.urls')),
url(r'^profiles/', include('local.urls')),