diff --git a/boards/static/css/base_page.css b/boards/static/css/base_page.css
--- a/boards/static/css/base_page.css
+++ b/boards/static/css/base_page.css
@@ -1,5 +1,5 @@
html {
- background: #555555;
+ background: #333;
}
#admin_panel {
@@ -22,9 +22,13 @@ html {
}
.link {
- color: #33bb33
+ color: #33bb33;
}
.link:hover {
color: #00ff00;
+}
+
+.post_id {
+ color: #ffffff;
}
\ No newline at end of file
diff --git a/boards/views.py b/boards/views.py
--- a/boards/views.py
+++ b/boards/views.py
@@ -1,37 +1,41 @@
from django.template import RequestContext
from boards import forms
+import boards
from boards.models import Post, Admin
-from django.shortcuts import render, get_list_or_404
+from django.shortcuts import render, get_list_or_404, redirect
from django.http import HttpResponseRedirect, Http404
def index(request):
context = RequestContext(request)
if request.method == 'POST':
- Post.objects.create_post(request.POST['title'],
- request.POST['text'], ip = request.META['REMOTE_ADDR'])
-
- threads = Post.objects.get_threads()
+ return new_post(request)
+ else:
+ threads = Post.objects.get_threads()
- context['threads'] = None if len(threads) == 0 else threads
- context['form'] = forms.NewThreadForm()
+ context['threads'] = None if len(threads) == 0 else threads
+ context['form'] = forms.NewThreadForm()
- return render(request, 'posting_general.html',
- context)
+ return render(request, 'posting_general.html',
+ context)
-def new_post(request):
+def new_post(request, thread_id = boards.models.NO_PARENT):
"""Add a new post (in thread or as a reply)."""
title = request.POST['title']
text = request.POST['text']
-
- image = request.POST['image']
+ ip = request.META['REMOTE_ADDR']
# TODO Get tags list, download image (if link is given)
- post = Post.objects.create_post(title = title, text = text, image = image)
+ post = Post.objects.create_post(title = title, text = text, ip = ip,
+ parent_id = thread_id)
- # TODO Show the thread with a newly created post
+ if thread_id != boards.models.NO_PARENT:
+ request.method = 'GET'
+ return thread(request, thread_id)
+ else:
+ return redirect(thread, id = post.id)
def tag(request):
"""Get all tag threads (posts without a parent)."""
@@ -50,14 +54,18 @@ def tag(request):
def thread(request, id):
"""Get all thread posts"""
- # TODO Show 404 if there is no such thread
-
- posts = Post.objects.get_thread(id)
+ if request.method == 'POST':
+ return new_post(request, id)
+ else:
+ # TODO Show 404 if there is no such thread
+ posts = Post.objects.get_thread(id)
- context = RequestContext(request)
- context['posts'] = posts
+ context = RequestContext(request)
+ context['posts'] = posts
- return render(request, 'thread.html', context)
+ context['form'] = forms.NewThreadForm()
+
+ return render(request, 'thread.html', context)
def login(request):
"""Log in as admin"""
diff --git a/templates/posting_general.html b/templates/posting_general.html
--- a/templates/posting_general.html
+++ b/templates/posting_general.html
@@ -4,10 +4,10 @@
{% if threads %}
{% for thread in threads %}
- {{ thread.title }}
+ {{ thread.title }}
+
+ [View]
{{ thread.text }}
- View
- thread