Show More
@@ -46,12 +46,12 b' class PostManager(models.Manager):' | |||||
46 | return [opening_post, replies] |
|
46 | return [opening_post, replies] | |
47 |
|
47 | |||
48 | def exists(self, post_id): |
|
48 | def exists(self, post_id): | |
49 |
posts = |
|
49 | posts = self.filter(id = post_id) | |
50 |
|
50 | |||
51 | return len(posts) > 0 |
|
51 | return len(posts) > 0 | |
52 |
|
52 | |||
53 | def is_admin(self, user, passw): |
|
53 | def is_admin(self, user, passw): | |
54 |
return |
|
54 | return self.filter(name = user, password = passw) is not None | |
55 |
|
55 | |||
56 |
|
56 | |||
57 | class Tag(models.Model): |
|
57 | class Tag(models.Model): | |
@@ -88,8 +88,8 b' class Admin(models.Model):' | |||||
88 |
|
88 | |||
89 | objects = PostManager() |
|
89 | objects = PostManager() | |
90 |
|
90 | |||
91 | name = models.CharField(max_length=100) |
|
91 | name = models.CharField(max_length = 100) | |
92 | password = models.CharField(max_length=100) |
|
92 | password = models.CharField(max_length = 100) | |
93 |
|
93 | |||
94 | def __unicode__(self): |
|
94 | def __unicode__(self): | |
95 | return self.name + '/' + '*' * len(self.password) |
|
95 | return self.name + '/' + '*' * len(self.password) |
@@ -4,7 +4,6 b' from django.shortcuts import render' | |||||
4 | from django.http import HttpResponseRedirect |
|
4 | from django.http import HttpResponseRedirect | |
5 |
|
5 | |||
6 | def index(request): |
|
6 | def index(request): | |
7 | # TODO Show a real index page with all threads list |
|
|||
8 | threads = Post.objects.get_threads() |
|
7 | threads = Post.objects.get_threads() | |
9 |
|
8 | |||
10 | context = RequestContext(request) |
|
9 | context = RequestContext(request) | |
@@ -30,19 +29,31 b' def new_post(request):' | |||||
30 | def tag(request): |
|
29 | def tag(request): | |
31 | """Get all tag threads (posts without a parent).""" |
|
30 | """Get all tag threads (posts without a parent).""" | |
32 |
|
31 | |||
|
32 | # TODO Show 404 if no such tag | |||
|
33 | ||||
33 | tag_name = request.GET['tag'] |
|
34 | tag_name = request.GET['tag'] | |
34 |
|
35 | |||
35 |
|
|
36 | threads = Post.objects.get_threads(tag = tag_name) | |
36 |
|
37 | |||
37 | # TODO Send a response with the post list |
|
38 | context = RequestContext(request) | |
|
39 | context['threads'] = None if len(threads) == 0 else threads | |||
|
40 | context['tag'] = tag_name | |||
|
41 | ||||
|
42 | return render(request, 'posting_general.html', | |||
|
43 | context) | |||
38 |
|
44 | |||
39 | def thread(request): |
|
45 | def thread(request): | |
40 | """Get all thread posts""" |
|
46 | """Get all thread posts""" | |
41 |
|
47 | |||
|
48 | # TODO Show 404 if there is no such thread | |||
|
49 | ||||
42 | opening_post_id = request.GET['id'] |
|
50 | opening_post_id = request.GET['id'] | |
43 | posts = Post.objects.get_thread(opening_post_id) |
|
51 | posts = Post.objects.get_thread(opening_post_id) | |
44 |
|
52 | |||
45 | # TODO Show all posts for the current thread |
|
53 | context = RequestContext(request) | |
|
54 | context['posts'] = posts | |||
|
55 | ||||
|
56 | return render(request), 'thread.html' | |||
46 |
|
57 | |||
47 | def login(request): |
|
58 | def login(request): | |
48 | """Log in as admin""" |
|
59 | """Log in as admin""" |
General Comments 0
You need to be logged in to leave comments.
Login now