##// END OF EJS Templates
Changed the url to the post page. Added one more TODO.
neko259 -
r6:5fb6f373 default
parent child Browse files
Show More
@@ -1,14 +1,14 b''
1 from django.conf.urls import patterns, url
1 from django.conf.urls import patterns, url
2 from boards import views
2 from boards import views
3
3
4 urlpatterns = patterns('',
4 urlpatterns = patterns('',
5 # /boards/
5 # /boards/
6 url(r'^$', views.index, name = 'index'),
6 url(r'^$', views.index, name = 'index'),
7 # /boards/tag/
7 # /boards/tag/
8 url(r'^(?P<tag>\w+)/$', views.tag, name = 'tag'),
8 url(r'^(?P<tag>\w+)/$', views.tag, name = 'tag'),
9 # /boards/post_id/
9 # /boards/post_id/
10 url(r'^(?P<post>\w+)/$', views.thread, name = 'thread'),
10 url(r'^(?P<post>\w+)/$', views.thread, name = 'thread'),
11 # /boards/tag/post/
11 # /boards/tag/post/
12 url(r'^(?P<tag>\w+)/post.html$', views.new_post,
12 url(r'^post.html$', views.new_post,
13 name='post'),
13 name='post'),
14 )
14 )
@@ -1,38 +1,40 b''
1 from django.http import HttpResponse
1 from django.http import HttpResponse
2
2
3 from boards.models import Post
3 from boards.models import Post
4
4
5 def index(request):
5 def index(request):
6 # TODO Show a real index page with all threads list
6 # TODO Show a real index page with all threads list
7 threads = Post.objects.get_threads()
7 threads = Post.objects.get_threads()
8
8
9 return HttpResponse('Imageboard, motherfucker! Do you post to it?!')
9 return HttpResponse('Imageboard, motherfucker! Do you post to it?!')
10
10
11 def new_post(request):
11 def new_post(request):
12 """Add a new post (in thread or as a reply)."""
12 """Add a new post (in thread or as a reply)."""
13
13
14 title = request.POST['title']
14 title = request.POST['title']
15 text = request.POST['text']
15 text = request.POST['text']
16
16
17 image = request.POST['image']
17 image = request.POST['image']
18
18
19 # TODO Get tags list, download image (if link is given)
20
19 post = Post.objects.create_post(title = title, text = text, image = image)
21 post = Post.objects.create_post(title = title, text = text, image = image)
20
22
21 # TODO Show the thread with a newly created post
23 # TODO Show the thread with a newly created post
22
24
23 def tag(request):
25 def tag(request):
24 """Get all tag threads (posts without a parent)."""
26 """Get all tag threads (posts without a parent)."""
25
27
26 tag_name = request.GET['tag']
28 tag_name = request.GET['tag']
27
29
28 posts = Post.objects.get_threads(tag = tag)
30 posts = Post.objects.get_threads(tag = tag)
29
31
30 # TODO Send a response with the post list
32 # TODO Send a response with the post list
31
33
32 def thread(request):
34 def thread(request):
33 """Get all thread posts"""
35 """Get all thread posts"""
34
36
35 opening_post_id = request.GET['id']
37 opening_post_id = request.GET['id']
36 posts = Post.objects.get_thread(opening_post_id)
38 posts = Post.objects.get_thread(opening_post_id)
37
39
38 # TODO Show all posts for the current thread No newline at end of file
40 # TODO Show all posts for the current thread
General Comments 0
You need to be logged in to leave comments. Login now