Implement a basic forum

This commit is contained in:
Trever Fischer
2012-02-18 15:31:13 -05:00
parent d5a4b83a74
commit db6d0c29d8
20 changed files with 334 additions and 0 deletions

View File

@@ -32,7 +32,15 @@
</div>
</div>
<div class="clear"></div>
<div id="nav" class="grid_12">
<ul>
<li><a href="/">Home</a></li>
<li><a href="{%url forums.views.index%}">Forums</a></li>
</ul>
</div>
<div id="content" class="grid_12">
<h1>{%block sectiontitle %}Caminus{%endblock%}</h1>
{% block breadcrumb %}{% endblock %}
{% block content %}
{% endblock %}
</div>

View File

@@ -0,0 +1,2 @@
{% extends "base.html" %}
{% block sectiontitle %}Forums{% endblock %}

View File

@@ -0,0 +1 @@
{%block breadcrumb %}

View File

@@ -0,0 +1,15 @@
{% load mptt_tags %}
<table>
<tr class="header">
<th>Name</th>
<th>Topics</th>
<th>Last Post</th>
</tr>
{% for f in forums %}
<tr class="{% cycle 'even' 'odd' %}">
<td><a href="{{ f.get_absolute_url }}">{{ f.name }}</a></td>
<td>{{ f.topicCount }}</td>
<td>Today</td>
</tr>
{% endfor %}
</table>

View File

@@ -0,0 +1,11 @@
{% load mptt_tags %}
<div class="forum-post">
{% include "forums/_post_children.html" with post=post %}
{% recursetree post.children %}
<div class="forum-post">
{% include "forums/_post_children.html" with post=node %}
{{children}}
</div>
{%endrecursetree%}
</div>

View File

@@ -0,0 +1,13 @@
{% load markup %}
{% load avatar_tags %}
<a name="reply-{{post.id}}"></a>
<div class="forum-post-user">
{%avatar post.user%}
{{post.user}}
</div>
<div class="forum-post-content">
{{post.body|markdown:"safe"}}
<br style="clear:both"/>
</div>
<a href="{%url forums.views.reply post.id%}">Reply</a>

View File

@@ -0,0 +1,29 @@
{% extends "forum_base.html" %}
{% block breadcrumb %}
<a href="{% url forums.views.index%}">Forums</a>
{%for f in forum.get_ancestors %}
&gt; <a href="{{f.get_relative_url}}">{{f}}</a>
{%endfor%}
{% endblock %}
{% block content %}
<h2>{{ forum.name }}</h2>
{%include "forums/_forum_table.html" with forums=forums.children%}
<table>
<tr class="header">
<th>Title</th>
<th>Posted</th>
<th>Latest Activity</th>
</tr>
{% for topic in topics %}
<tr class="{%cycle 'even' 'odd' %}">
<td><a href="{{topic.get_absolute_url}}">{{ topic.title }}</a></td>
<td>{{ topic.created }} </td>
<td>{{topic.lastPost.created}} by {{ topic.lastPost.user }} </td>
</tr>
{% endfor %}
</table>
<a href="{%url forums.views.newTopic forumID=forum.id %}">New Topic</a>
{% endblock %}

View File

@@ -0,0 +1,7 @@
{% extends "base.html" %}
{% block content %}
{% block breadcrumb %}
{% endblock breadcrumb %}
{% endblock content%}

View File

@@ -0,0 +1,7 @@
{% extends "forum_base.html" %}
{%block title %}Forums{% endblock %}
{% block content %}
{%include "forums/_forum_table.html" with forums=forums%}
{%endblock%}

View File

@@ -0,0 +1,17 @@
{% extends "forum_base.html" %}
{% block breadcrumb %}
<a href="{% url forums.views.index%}">Forums</a>
{%for f in forum.get_ancestors %}
&gt; <a href="{{f.get_relative_url}}">{{f}}</a>
{%endfor%}
{% endblock %}
{% block content %}
<form method="POST" action="{%url forums.views.newTopic forumID=forum.id %}">
{% csrf_token %}
{{topicForm.as_p}}
{{replyForm.as_p}}
<input type="submit" value="Submit"/>
</form>
{% endblock %}

View File

@@ -0,0 +1,8 @@
{% extends "forum_base.html" %}
{%block content%}
<form method="POST" action="{%url forums.views.reply post.id %}">
{% csrf_token %}
{{form.as_p}}
<input type="submit" value="Submit"/>
</form>
{%endblock%}

View File

@@ -0,0 +1,17 @@
{% extends "forum_base.html" %}
{% load mptt_tags %}
{%block title %}{{topic.title}}{%endblock%}
{%block breadcrumb %}
<a href="{% url forums.views.index%}">Forums</a>
&gt; <a href="{{topic.forum.get_absolute_url}}">{{topic.forum}}</a>
{%for f in topic.forum.get_ancestors %}
&gt; <a href="{{f.get_relative_url}}">{{f}}</a>
{%endfor%}
{%endblock%}
{%block content %}
<h2>{{topic.title}}</h2>
{% include "forums/_post.html" with post=topic.rootPost %}
{%endblock%}