Show More
@@ -0,0 +1,38 b'' | |||||
|
1 | # SOME DESCRIPTIVE TITLE. | |||
|
2 | # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER | |||
|
3 | # This file is distributed under the same license as the PACKAGE package. | |||
|
4 | # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR. | |||
|
5 | # | |||
|
6 | #, fuzzy | |||
|
7 | msgid "" | |||
|
8 | msgstr "" | |||
|
9 | "Project-Id-Version: PACKAGE VERSION\n" | |||
|
10 | "Report-Msgid-Bugs-To: \n" | |||
|
11 | "POT-Creation-Date: 2013-04-05 20:55+0300\n" | |||
|
12 | "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" | |||
|
13 | "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" | |||
|
14 | "Language-Team: LANGUAGE <LL@li.org>\n" | |||
|
15 | "Language: \n" | |||
|
16 | "MIME-Version: 1.0\n" | |||
|
17 | "Content-Type: text/plain; charset=UTF-8\n" | |||
|
18 | "Content-Transfer-Encoding: 8bit\n" | |||
|
19 | "Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n" | |||
|
20 | "%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);\n" | |||
|
21 | ||||
|
22 | msgid "Title" | |||
|
23 | msgstr "ΠΠ°Π³ΠΎΠ»ΠΎΠ²ΠΎΠΊ" | |||
|
24 | ||||
|
25 | msgid "Text" | |||
|
26 | msgstr "Π’Π΅ΠΊΡΡ" | |||
|
27 | ||||
|
28 | msgid "Image" | |||
|
29 | msgstr "ΠΠ°ΡΡΠΈΠ½ΠΊΠ°" | |||
|
30 | ||||
|
31 | msgid "Post" | |||
|
32 | msgstr "ΠΡΠΏΡΠ°Π²ΠΈΡΡ" | |||
|
33 | ||||
|
34 | msgid "Tags" | |||
|
35 | msgstr "Π’Π΅Π³ΠΈ" | |||
|
36 | ||||
|
37 | msgid "View" | |||
|
38 | msgstr "ΠΡΠΎΡΠΌΠΎΡΡ" No newline at end of file |
@@ -2,7 +2,7 b' from django import forms' | |||||
2 |
|
2 | |||
3 |
|
3 | |||
4 | class NewThreadForm(forms.Form): |
|
4 | class NewThreadForm(forms.Form): | |
5 |
title = forms.CharField(max_length |
|
5 | title = forms.CharField(max_length=100) | |
6 |
text = forms.CharField(widget |
|
6 | text = forms.CharField(widget=forms.Textarea) | |
7 | image = forms.ImageField() |
|
7 | image = forms.ImageField() | |
8 | tags = forms.CharField(max_length=100) |
|
8 | tags = forms.CharField(max_length=100) |
@@ -12,7 +12,7 b" UNKNOWN_UA = ''" | |||||
12 |
|
12 | |||
13 | class PostManager(models.Manager): |
|
13 | class PostManager(models.Manager): | |
14 | def create_post(self, title, text, image=None, parent_id=NO_PARENT, |
|
14 | def create_post(self, title, text, image=None, parent_id=NO_PARENT, | |
15 | ip=NO_IP): |
|
15 | ip=NO_IP, tags=None): | |
16 | post = self.create(title=title, |
|
16 | post = self.create(title=title, | |
17 | text=text, |
|
17 | text=text, | |
18 | pub_time=timezone.now(), |
|
18 | pub_time=timezone.now(), | |
@@ -21,6 +21,10 b' class PostManager(models.Manager):' | |||||
21 | poster_ip=ip, |
|
21 | poster_ip=ip, | |
22 | poster_user_agent=UNKNOWN_UA) |
|
22 | poster_user_agent=UNKNOWN_UA) | |
23 |
|
23 | |||
|
24 | if tags: | |||
|
25 | for tag in tags: | |||
|
26 | post.tags.add(tag) | |||
|
27 | ||||
24 | return post |
|
28 | return post | |
25 |
|
29 | |||
26 | def delete_post(self, post): |
|
30 | def delete_post(self, post): |
@@ -1,5 +1,6 b'' | |||||
1 | html { |
|
1 | html { | |
2 | background: #333; |
|
2 | background: #333; | |
|
3 | color: #ffffff; | |||
3 | } |
|
4 | } | |
4 |
|
5 | |||
5 | #admin_panel { |
|
6 | #admin_panel { | |
@@ -12,13 +13,18 b' html {' | |||||
12 | color: #ffcc00; |
|
13 | color: #ffcc00; | |
13 | } |
|
14 | } | |
14 |
|
15 | |||
15 | .text { |
|
|||
16 | color: #ffffff; |
|
|||
17 | } |
|
|||
18 |
|
||||
19 | .post-form { |
|
16 | .post-form { | |
20 | text-align: left; |
|
17 | text-align: left; | |
21 | color: #ffffff; |
|
18 | color: #ffffff; | |
|
19 | display: table; | |||
|
20 | } | |||
|
21 | ||||
|
22 | .form-row { | |||
|
23 | display: table-row; | |||
|
24 | } | |||
|
25 | ||||
|
26 | .form-input { | |||
|
27 | display: table-cell; | |||
22 | } |
|
28 | } | |
23 |
|
29 | |||
24 | .link { |
|
30 | .link { | |
@@ -36,4 +42,12 b' html {' | |||||
36 | .block { |
|
42 | .block { | |
37 | display: inline-block; |
|
43 | display: inline-block; | |
38 | vertical-align: top; |
|
44 | vertical-align: top; | |
|
45 | } | |||
|
46 | ||||
|
47 | .tag { | |||
|
48 | color: #bb7766; | |||
|
49 | } | |||
|
50 | ||||
|
51 | .tag:hover { | |||
|
52 | color: #dd8888; | |||
39 | } No newline at end of file |
|
53 | } |
@@ -3,7 +3,7 b' from django.test.client import Client' | |||||
3 |
|
3 | |||
4 | import boards |
|
4 | import boards | |
5 |
|
5 | |||
6 | from boards.models import Post, Admin |
|
6 | from boards.models import Post, Admin, Tag | |
7 |
|
7 | |||
8 |
|
8 | |||
9 | class BoardTests(TestCase): |
|
9 | class BoardTests(TestCase): | |
@@ -95,3 +95,8 b' class BoardTests(TestCase):' | |||||
95 | thread = Post.objects.get_thread(op_id) |
|
95 | thread = Post.objects.get_thread(op_id) | |
96 |
|
96 | |||
97 | self.assertEqual(3, len(thread)) |
|
97 | self.assertEqual(3, len(thread)) | |
|
98 | ||||
|
99 | def test_create_post_with_tag(self): | |||
|
100 | tag = Tag.objects.create(name='test_tag') | |||
|
101 | post = Post.objects.create_post(title='title', text='text', tags=[tag]) | |||
|
102 | self.assertIsNotNone(post) No newline at end of file |
@@ -12,9 +12,9 b" urlpatterns = patterns(''," | |||||
12 | url(r'^logout$', views.logout, name='logout'), |
|
12 | url(r'^logout$', views.logout, name='logout'), | |
13 |
|
13 | |||
14 | # /boards/tag/ |
|
14 | # /boards/tag/ | |
15 | url(r'^tag/(?P<tag>\w+)/$', views.tag, name = 'tag'), |
|
15 | url(r'^tag/(?P<tag_name>\w+)/$', views.tag, name = 'tag'), | |
16 | # /boards/post_id/ |
|
16 | # /boards/post_id/ | |
17 | url(r'^thread/(?P<id>\w+)/$', views.thread, name = 'thread'), |
|
17 | url(r'^thread/(?P<post_id>\w+)/$', views.thread, name = 'thread'), | |
18 | # /boards/tag/post/ |
|
18 | # /boards/tag/post/ | |
19 | url(r'^post.html$', views.new_post, |
|
19 | url(r'^post.html$', views.new_post, | |
20 | name='post'), |
|
20 | name='post'), |
@@ -2,7 +2,7 b' from django.template import RequestConte' | |||||
2 | from boards import forms |
|
2 | from boards import forms | |
3 | import boards |
|
3 | import boards | |
4 | from boards.forms import NewThreadForm |
|
4 | from boards.forms import NewThreadForm | |
5 | from boards.models import Post, Admin |
|
5 | from boards.models import Post, Admin, Tag | |
6 | from django.shortcuts import render, get_list_or_404, redirect |
|
6 | from django.shortcuts import render, get_list_or_404, redirect | |
7 | from django.http import HttpResponseRedirect, Http404 |
|
7 | from django.http import HttpResponseRedirect, Http404 | |
8 |
|
8 | |||
@@ -37,39 +37,57 b' def new_post(request, thread_id=boards.m' | |||||
37 |
|
37 | |||
38 | ip = request.META['REMOTE_ADDR'] |
|
38 | ip = request.META['REMOTE_ADDR'] | |
39 |
|
39 | |||
40 | # TODO Get tags list, download image (if link is given) |
|
40 | tags = [] | |
|
41 | if thread_id == boards.models.NO_PARENT: | |||
|
42 | tag_strings = request.POST['tags'] | |||
|
43 | ||||
|
44 | if tag_strings: | |||
|
45 | tag_strings = tag_strings.split(',') | |||
|
46 | for tag_name in tag_strings: | |||
|
47 | tag_name = tag_name.strip() | |||
|
48 | if len(tag_name) > 0: | |||
|
49 | tag, created = Tag.objects.get_or_create(name=tag_name) | |||
|
50 | tags.append(tag) | |||
|
51 | ||||
|
52 | # TODO Add a possibility to define a link image instead of an image file. | |||
|
53 | # If a link is given, download the image automatically. | |||
41 |
|
54 | |||
42 | post = Post.objects.create_post(title=title, text=text, ip=ip, |
|
55 | post = Post.objects.create_post(title=title, text=text, ip=ip, | |
43 |
parent_id=thread_id, image=image |
|
56 | parent_id=thread_id, image=image, | |
|
57 | tags=tags) | |||
44 |
|
58 | |||
45 | thread_to_show = (post.id if thread_id == boards.models.NO_PARENT else |
|
59 | thread_to_show = (post.id if thread_id == boards.models.NO_PARENT else | |
46 | thread_id) |
|
60 | thread_id) | |
47 | return redirect(thread, id=thread_to_show) |
|
61 | return redirect(thread, post_id=thread_to_show) | |
48 |
|
62 | |||
49 |
|
63 | |||
50 | def tag(request): |
|
64 | def tag(request, tag_name): | |
51 | """Get all tag threads (posts without a parent).""" |
|
65 | """Get all tag threads (posts without a parent).""" | |
52 |
|
66 | |||
53 | tag_name = request.GET['tag'] |
|
67 | tag = Tag.objects.get(name=tag_name) | |
54 |
|
68 | threads = get_list_or_404(Post, tags=tag) | ||
55 | threads = get_list_or_404(Post, tag=tag_name) |
|
|||
56 |
|
69 | |||
57 | context = RequestContext(request) |
|
70 | if request.method == 'POST': | |
58 | context['threads'] = None if len(threads) == 0 else threads |
|
71 | return new_post(request) | |
59 | context['tag'] = tag_name |
|
72 | else: | |
|
73 | context = RequestContext(request) | |||
|
74 | context['threads'] = None if len(threads) == 0 else threads | |||
|
75 | context['tag'] = tag_name | |||
60 |
|
76 | |||
61 | return render(request, 'posting_general.html', |
|
77 | context['form'] = forms.NewThreadForm(initial={'tags': tag_name}) | |
62 | context) |
|
78 | ||
|
79 | return render(request, 'posting_general.html', | |||
|
80 | context) | |||
63 |
|
81 | |||
64 |
|
82 | |||
65 | def thread(request, id): |
|
83 | def thread(request, post_id): | |
66 | """Get all thread posts""" |
|
84 | """Get all thread posts""" | |
67 |
|
85 | |||
68 | if request.method == 'POST': |
|
86 | if request.method == 'POST': | |
69 | return new_post(request, id) |
|
87 | return new_post(request, post_id) | |
70 | else: |
|
88 | else: | |
71 | # TODO Show 404 if there is no such thread |
|
89 | # TODO Show 404 if there is no such thread | |
72 | posts = Post.objects.get_thread(id) |
|
90 | posts = Post.objects.get_thread(post_id) | |
73 |
|
91 | |||
74 | context = RequestContext(request) |
|
92 | context = RequestContext(request) | |
75 | context['posts'] = posts |
|
93 | context['posts'] = posts |
@@ -1,5 +1,7 b'' | |||||
1 | {% extends "base.html" %} |
|
1 | {% extends "base.html" %} | |
2 |
|
2 | |||
|
3 | {% load i18n %} | |||
|
4 | ||||
3 | {% block content %} |
|
5 | {% block content %} | |
4 |
|
6 | |||
5 | {% if threads %} |
|
7 | {% if threads %} | |
@@ -14,21 +16,46 b'' | |||||
14 | <div class="block"> |
|
16 | <div class="block"> | |
15 | <span class="title">{{ thread.title }}</span> |
|
17 | <span class="title">{{ thread.title }}</span> | |
16 | <a class="link" href="/thread/{{ thread.id }}/"> |
|
18 | <a class="link" href="/thread/{{ thread.id }}/"> | |
17 | [View]</a><br /> |
|
19 | [{% trans "View" %}]</a><br /> | |
18 |
|
|
20 | {{ thread.text }}<br /> | |
|
21 | {% if thread.tags %} | |||
|
22 | <span class="tags">{% trans 'Tags' %}: | |||
|
23 | {% for tag in thread.tags.all %} | |||
|
24 | <a class="tag" href="/tag/{{ tag.name }}"> | |||
|
25 | {{ tag.name }}</a> | |||
|
26 | {% endfor %} | |||
|
27 | </span> | |||
|
28 | {% endif %} | |||
19 | </div> |
|
29 | </div> | |
20 | <hr /> |
|
30 | <hr /> | |
21 | {% endfor %} |
|
31 | {% endfor %} | |
22 | {% else %} |
|
32 | {% else %} | |
23 | <span class="text">No threads found.</span> |
|
33 | No threads found. | |
24 | <hr /> |
|
34 | <hr /> | |
25 | {% endif %} |
|
35 | {% endif %} | |
26 |
|
36 | |||
27 | <div class="post-form"> |
|
37 | <div class="post-form"> | |
28 | <form enctype="multipart/form-data" method="post">{% csrf_token %} |
|
38 | <div class="post-form"> | |
29 | {{ form.as_p }} |
|
39 | <form enctype="multipart/form-data" method="post">{% csrf_token %} | |
30 | <input type="submit" value="Post!" /> |
|
40 | <div class="form-row"> | |
31 | </form> |
|
41 | <div class="form-input">{% trans 'Title' %}</div> | |
|
42 | <div class="form-input">{{ form.title }}</div> | |||
|
43 | </div> | |||
|
44 | <div class="form-row"> | |||
|
45 | <div class="form-input">{% trans 'Text' %}</div> | |||
|
46 | <div class="form-input">{{ form.text }}</div> | |||
|
47 | </div> | |||
|
48 | <div class="form-row"> | |||
|
49 | <div class="form-input">{% trans 'Image' %}</div> | |||
|
50 | <div class="form-input">{{ form.image }}</div> | |||
|
51 | </div> | |||
|
52 | <div class="form-row"> | |||
|
53 | <div class="form-input">{% trans 'Tags' %}</div> | |||
|
54 | <div class="form-input">{{ form.tags }}</div> | |||
|
55 | </div> | |||
|
56 | <input type="submit" value="{% trans 'Post' %}" /> | |||
|
57 | </form> | |||
|
58 | </div> | |||
32 | </div> |
|
59 | </div> | |
33 |
|
60 | |||
34 | {% endblock %} No newline at end of file |
|
61 | {% endblock %} |
@@ -1,5 +1,7 b'' | |||||
1 | {% extends "base.html" %} |
|
1 | {% extends "base.html" %} | |
2 |
|
2 | |||
|
3 | {% load i18n %} | |||
|
4 | ||||
3 | {% block content %} |
|
5 | {% block content %} | |
4 |
|
6 | |||
5 | {% if posts %} |
|
7 | {% if posts %} | |
@@ -14,7 +16,15 b'' | |||||
14 | <div class="block"> |
|
16 | <div class="block"> | |
15 | <span class="title">{{ post.title }}</span> |
|
17 | <span class="title">{{ post.title }}</span> | |
16 | <span class="post_id">(#{{ post.id }})</span><br /> |
|
18 | <span class="post_id">(#{{ post.id }})</span><br /> | |
17 |
|
|
19 | {{ post.text }}<br /> | |
|
20 | {% if post.tags %} | |||
|
21 | <span class="tags">{% trans 'Tags' %}: | |||
|
22 | {% for tag in post.tags.all %} | |||
|
23 | <a class="tag" href="/tag/{{ tag.name }}"> | |||
|
24 | {{ tag.name }}</a> | |||
|
25 | {% endfor %} | |||
|
26 | </span> | |||
|
27 | {% endif %} | |||
18 | </div> |
|
28 | </div> | |
19 | <hr /> |
|
29 | <hr /> | |
20 | {% endfor %} |
|
30 | {% endfor %} | |
@@ -25,8 +35,19 b'' | |||||
25 |
|
35 | |||
26 | <div class="post-form"> |
|
36 | <div class="post-form"> | |
27 | <form enctype="multipart/form-data" method="post">{% csrf_token %} |
|
37 | <form enctype="multipart/form-data" method="post">{% csrf_token %} | |
28 | {{ form.as_p }} |
|
38 | <div class="form-row"> | |
29 | <input type="submit" value="Post!" /> |
|
39 | <div class="form-input">{% trans 'Title' %}</div> | |
|
40 | <div class="form-input">{{ form.title }}</div> | |||
|
41 | </div> | |||
|
42 | <div class="form-row"> | |||
|
43 | <div class="form-input">{% trans 'Text' %}</div> | |||
|
44 | <div class="form-input">{{ form.text }}</div> | |||
|
45 | </div> | |||
|
46 | <div class="form-row"> | |||
|
47 | <div class="form-input">{% trans 'Image' %}</div> | |||
|
48 | <div class="form-input">{{ form.image }}</div> | |||
|
49 | </div> | |||
|
50 | <input type="submit" value="{% trans 'Post' %}" /> | |||
30 | </form> |
|
51 | </form> | |
31 | </div> |
|
52 | </div> | |
32 |
|
53 |
General Comments 0
You need to be logged in to leave comments.
Login now