##// END OF EJS Templates
Initial commit. One test doesn't work, missing posting form.
Initial commit. One test doesn't work, missing posting form.

File last commit:

r0:8aafc193 default
r0:8aafc193 default
Show More
views.py
49 lines | 1.1 KiB | text/x-python | PythonLexer
from django.http import HttpResponse
from django.shortcuts import render
from boards.models import Board, Thread, Post
def index(request):
return HttpResponse('Imageboard, motherfucker! Do you post to it?!')
def board(request, board_name):
board = []
threads = []
boards = Board.objects.filter(name=board_name)
if len(boards) > 0:
board = boards[0]
if board != []:
threads = Thread.objects.filter(board=board)
context = {
'board': board,
'threads': threads,
}
return render(request, 'boards/board.html', context)
def thread(request, board_name, thread_id):
thread = []
posts = []
threads = Thread.objects.filter(id=thread_id)
if len(threads) > 0:
thread = threads[0]
posts = Post.objects.filter(thread=thread)
context = {
'thread': thread,
'posts': posts,
}
return render(request, 'boards/thread.html', context)
def post(request):
title = request.POST['title']
text = request.POST['text']
image = request.POST['image']
post = Post.objects.create_post(title=title, text=text, image=image)