Show More
1 | NO CONTENT: new file 100644, binary diff hidden |
|
NO CONTENT: new file 100644, binary diff hidden |
1 | NO CONTENT: modified file, binary diff hidden |
|
NO CONTENT: modified file, binary diff hidden |
@@ -1,182 +1,189 b'' | |||||
1 | # SOME DESCRIPTIVE TITLE. |
|
1 | # SOME DESCRIPTIVE TITLE. | |
2 | # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER |
|
2 | # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER | |
3 | # This file is distributed under the same license as the PACKAGE package. |
|
3 | # This file is distributed under the same license as the PACKAGE package. | |
4 | # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR. |
|
4 | # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR. | |
5 | # |
|
5 | # | |
6 | msgid "" |
|
6 | msgid "" | |
7 | msgstr "" |
|
7 | msgstr "" | |
8 | "Project-Id-Version: PACKAGE VERSION\n" |
|
8 | "Project-Id-Version: PACKAGE VERSION\n" | |
9 | "Report-Msgid-Bugs-To: \n" |
|
9 | "Report-Msgid-Bugs-To: \n" | |
10 |
"POT-Creation-Date: 2013-08- |
|
10 | "POT-Creation-Date: 2013-08-30 18:54+0300\n" | |
11 | "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" |
|
11 | "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" | |
12 | "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" |
|
12 | "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" | |
13 | "Language-Team: LANGUAGE <LL@li.org>\n" |
|
13 | "Language-Team: LANGUAGE <LL@li.org>\n" | |
14 | "Language: ru\n" |
|
14 | "Language: ru\n" | |
15 | "MIME-Version: 1.0\n" |
|
15 | "MIME-Version: 1.0\n" | |
16 | "Content-Type: text/plain; charset=UTF-8\n" |
|
16 | "Content-Type: text/plain; charset=UTF-8\n" | |
17 | "Content-Transfer-Encoding: 8bit\n" |
|
17 | "Content-Transfer-Encoding: 8bit\n" | |
18 | "Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n" |
|
18 | "Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n" | |
19 | "%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);\n" |
|
19 | "%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);\n" | |
20 |
|
20 | |||
|
21 | #: templates/boards/404.html:6 | |||
|
22 | msgid "Not found" | |||
|
23 | msgstr "Не найдено" | |||
|
24 | ||||
|
25 | #: templates/boards/404.html:12 | |||
|
26 | msgid "This page does not exist" | |||
|
27 | msgstr "Этой страницы не существует" | |||
|
28 | ||||
21 | #: templates/boards/authors.html:6 |
|
29 | #: templates/boards/authors.html:6 | |
22 | msgid "Authors" |
|
30 | msgid "Authors" | |
23 | msgstr "Авторы" |
|
31 | msgstr "Авторы" | |
24 |
|
32 | |||
25 | #: templates/boards/authors.html:24 |
|
33 | #: templates/boards/authors.html:24 | |
26 | msgid "Distributed under the" |
|
34 | msgid "Distributed under the" | |
27 | msgstr "Распространяется под" |
|
35 | msgstr "Распространяется под" | |
28 |
|
36 | |||
29 | #: templates/boards/authors.html:26 |
|
37 | #: templates/boards/authors.html:26 | |
30 | msgid "license" |
|
38 | msgid "license" | |
31 | msgstr "лицензией" |
|
39 | msgstr "лицензией" | |
32 |
|
40 | |||
33 | #: templates/boards/authors.html:28 |
|
41 | #: templates/boards/authors.html:28 | |
34 | msgid "Repository" |
|
42 | msgid "Repository" | |
35 | msgstr "Репозиторий" |
|
43 | msgstr "Репозиторий" | |
36 |
|
44 | |||
37 | #: templates/boards/banned.html:6 |
|
45 | #: templates/boards/banned.html:6 | |
38 | msgid "Banned" |
|
46 | msgid "Banned" | |
39 | msgstr "" |
|
47 | msgstr "Заблокирован" | |
40 |
|
48 | |||
41 | #: templates/boards/banned.html:11 |
|
49 | #: templates/boards/banned.html:11 | |
42 | msgid "Your IP address has been banned. Contact the administrator" |
|
50 | msgid "Your IP address has been banned. Contact the administrator" | |
43 | msgstr "" |
|
51 | msgstr "Ваш IP адрес был заблокирован. Свяжитесь с администратором" | |
44 |
|
52 | |||
45 | #: templates/boards/base.html:12 |
|
53 | #: templates/boards/base.html:12 | |
46 | msgid "Feed" |
|
54 | msgid "Feed" | |
47 | msgstr "Лента" |
|
55 | msgstr "Лента" | |
48 |
|
56 | |||
49 |
#: templates/boards/base.html:3 |
|
57 | #: templates/boards/base.html:36 | |
50 | msgid "All threads" |
|
58 | msgid "All threads" | |
51 | msgstr "Все темы" |
|
59 | msgstr "Все темы" | |
52 |
|
60 | |||
53 |
#: templates/boards/base.html:4 |
|
61 | #: templates/boards/base.html:42 | |
54 | msgid "Settings" |
|
62 | msgid "Settings" | |
55 | msgstr "Настройки" |
|
63 | msgstr "Настройки" | |
56 |
|
64 | |||
57 |
#: templates/boards/base.html: |
|
65 | #: templates/boards/base.html:50 | |
58 | msgid "Up" |
|
66 | msgid "Up" | |
59 | msgstr "Вверх" |
|
67 | msgstr "Вверх" | |
60 |
|
68 | |||
61 | #: templates/boards/posting_general.html:18 |
|
69 | #: templates/boards/posting_general.html:18 | |
62 | msgid "Tag: " |
|
70 | msgid "Tag: " | |
63 | msgstr "Тег: " |
|
71 | msgstr "Тег: " | |
64 |
|
72 | |||
65 | #: templates/boards/posting_general.html:35 |
|
73 | #: templates/boards/posting_general.html:35 | |
66 |
#: templates/boards/posting_general.html: |
|
74 | #: templates/boards/posting_general.html:81 templates/boards/thread.html:27 | |
67 | #: templates/boards/rss/post.html:5 |
|
75 | #: templates/boards/rss/post.html:5 | |
68 | msgid "Post image" |
|
76 | msgid "Post image" | |
69 | msgstr "Изображение сообщения" |
|
77 | msgstr "Изображение сообщения" | |
70 |
|
78 | |||
71 |
#: templates/boards/posting_general.html:4 |
|
79 | #: templates/boards/posting_general.html:48 | |
72 | msgid "Reply" |
|
80 | msgid "Reply" | |
73 | msgstr "Ответ" |
|
81 | msgstr "Ответ" | |
74 |
|
82 | |||
75 |
#: templates/boards/posting_general.html:5 |
|
83 | #: templates/boards/posting_general.html:55 templates/boards/thread.html:108 | |
76 | msgid "replies" |
|
84 | msgid "replies" | |
77 | msgstr "ответов" |
|
85 | msgstr "ответов" | |
78 |
|
86 | |||
79 |
#: templates/boards/posting_general.html:5 |
|
87 | #: templates/boards/posting_general.html:56 templates/boards/thread.html:109 | |
80 | msgid "images" |
|
88 | msgid "images" | |
81 | msgstr "изображений" |
|
89 | msgstr "изображений" | |
82 |
|
90 | |||
83 |
#: templates/boards/posting_general.html:5 |
|
91 | #: templates/boards/posting_general.html:58 | |
84 |
#: templates/boards/posting_general.html:1 |
|
92 | #: templates/boards/posting_general.html:131 templates/boards/thread.html:48 | |
85 | #: templates/boards/rss/post.html:10 |
|
93 | #: templates/boards/rss/post.html:10 | |
86 | msgid "Tags" |
|
94 | msgid "Tags" | |
87 | msgstr "Теги" |
|
95 | msgstr "Теги" | |
88 |
|
96 | |||
89 |
#: templates/boards/posting_general.html:1 |
|
97 | #: templates/boards/posting_general.html:113 | |
90 | msgid "Create new thread" |
|
98 | msgid "Create new thread" | |
91 | msgstr "Создать новую тему" |
|
99 | msgstr "Создать новую тему" | |
92 |
|
100 | |||
93 |
#: templates/boards/posting_general.html:11 |
|
101 | #: templates/boards/posting_general.html:116 templates/boards/thread.html:70 | |
94 | msgid "Title" |
|
102 | msgid "Title" | |
95 | msgstr "Заголовок" |
|
103 | msgstr "Заголовок" | |
96 |
|
104 | |||
97 |
#: templates/boards/posting_general.html:11 |
|
105 | #: templates/boards/posting_general.html:121 templates/boards/thread.html:75 | |
98 | msgid "Text" |
|
106 | msgid "Text" | |
99 | msgstr "Текст" |
|
107 | msgstr "Текст" | |
100 |
|
108 | |||
101 |
#: templates/boards/posting_general.html:12 |
|
109 | #: templates/boards/posting_general.html:126 templates/boards/thread.html:80 | |
102 | msgid "Image" |
|
110 | msgid "Image" | |
103 | msgstr "Изображение" |
|
111 | msgstr "Изображение" | |
104 |
|
112 | |||
105 |
#: templates/boards/posting_general.html:1 |
|
113 | #: templates/boards/posting_general.html:141 templates/boards/thread.html:91 | |
106 | msgid "Post" |
|
114 | msgid "Post" | |
107 | msgstr "Отправить" |
|
115 | msgstr "Отправить" | |
108 |
|
116 | |||
109 |
#: templates/boards/posting_general.html:13 |
|
117 | #: templates/boards/posting_general.html:143 | |
110 | msgid "Tags must be delimited by spaces. Text or image is required." |
|
118 | msgid "Tags must be delimited by spaces. Text or image is required." | |
111 | msgstr "" |
|
119 | msgstr "" | |
112 | "Теги должны быть разделены пробелами. Текст или изображение обязательны." |
|
120 | "Теги должны быть разделены пробелами. Текст или изображение обязательны." | |
113 |
|
121 | |||
114 |
#: templates/boards/posting_general.html:14 |
|
122 | #: templates/boards/posting_general.html:146 templates/boards/thread.html:93 | |
115 | msgid "Basic markdown syntax." |
|
123 | msgid "Basic markdown syntax." | |
116 | msgstr "Базовый синтаксис markdown." |
|
124 | msgstr "Базовый синтаксис markdown." | |
117 |
|
125 | |||
118 |
#: templates/boards/posting_general.html:15 |
|
126 | #: templates/boards/posting_general.html:156 | |
119 | msgid "Pages:" |
|
127 | msgid "Pages:" | |
120 | msgstr "Страницы: " |
|
128 | msgstr "Страницы: " | |
121 |
|
129 | |||
122 | #: templates/boards/settings.html:13 |
|
130 | #: templates/boards/settings.html:13 | |
123 | msgid "Theme" |
|
131 | msgid "Theme" | |
124 | msgstr "Тема" |
|
132 | msgstr "Тема" | |
125 |
|
133 | |||
126 | #: templates/boards/settings.html:29 |
|
134 | #: templates/boards/settings.html:29 | |
127 | msgid "Save" |
|
135 | msgid "Save" | |
128 | msgstr "Сохранить" |
|
136 | msgstr "Сохранить" | |
129 |
|
137 | |||
130 | #: templates/boards/tags.html:7 |
|
138 | #: templates/boards/tags.html:7 | |
131 | msgid "tags" |
|
139 | msgid "tags" | |
132 | msgstr "тегов" |
|
140 | msgstr "тегов" | |
133 |
|
141 | |||
134 |
#: templates/boards/thread.html: |
|
142 | #: templates/boards/thread.html:67 | |
135 | msgid "Get!" |
|
|||
136 | msgstr "Гет!" |
|
|||
137 |
|
||||
138 | #: templates/boards/thread.html:70 |
|
|||
139 | msgid "Reply to thread" |
|
143 | msgid "Reply to thread" | |
140 | msgstr "Ответить в тему" |
|
144 | msgstr "Ответить в тему" | |
141 |
|
145 | |||
142 |
#: templates/boards/thread.html:9 |
|
146 | #: templates/boards/thread.html:94 | |
143 | msgid "Example: " |
|
147 | msgid "Example: " | |
144 | msgstr "Пример: " |
|
148 | msgstr "Пример: " | |
145 |
|
149 | |||
146 |
#: templates/boards/thread.html:9 |
|
150 | #: templates/boards/thread.html:94 | |
147 | msgid "italic" |
|
151 | msgid "italic" | |
148 | msgstr "курсив" |
|
152 | msgstr "курсив" | |
149 |
|
153 | |||
150 |
#: templates/boards/thread.html:9 |
|
154 | #: templates/boards/thread.html:95 | |
151 | msgid "bold" |
|
155 | msgid "bold" | |
152 | msgstr "полужирный" |
|
156 | msgstr "полужирный" | |
153 |
|
157 | |||
154 |
#: templates/boards/thread.html:9 |
|
158 | #: templates/boards/thread.html:96 | |
155 | msgid "Quotes can be inserted with" |
|
159 | msgid "Quotes can be inserted with" | |
156 | msgstr "Цитаты могут быть вставлены при помощи" |
|
160 | msgstr "Цитаты могут быть вставлены при помощи" | |
157 |
|
161 | |||
158 |
#: templates/boards/thread.html: |
|
162 | #: templates/boards/thread.html:97 | |
159 | msgid "Links to answers can be inserted with" |
|
163 | msgid "Links to answers can be inserted with" | |
160 | msgstr "Ссылки на ответы могут быть вставлены с помощью" |
|
164 | msgstr "Ссылки на ответы могут быть вставлены с помощью" | |
161 |
|
165 | |||
162 |
#: templates/boards/thread.html:11 |
|
166 | #: templates/boards/thread.html:110 | |
163 | msgid "Last update: " |
|
167 | msgid "Last update: " | |
164 | msgstr "Последнее обновление: " |
|
168 | msgstr "Последнее обновление: " | |
165 |
|
169 | |||
|
170 | #~ msgid "Get!" | |||
|
171 | #~ msgstr "Гет!" | |||
|
172 | ||||
166 | #~ msgid "View" |
|
173 | #~ msgid "View" | |
167 | #~ msgstr "Просмотр" |
|
174 | #~ msgstr "Просмотр" | |
168 |
|
175 | |||
169 | #~ msgid "gets" |
|
176 | #~ msgid "gets" | |
170 | #~ msgstr "гетов" |
|
177 | #~ msgstr "гетов" | |
171 |
|
178 | |||
172 | #~ msgid "author" |
|
179 | #~ msgid "author" | |
173 | #~ msgstr "автор" |
|
180 | #~ msgstr "автор" | |
174 |
|
181 | |||
175 | #~ msgid "developer" |
|
182 | #~ msgid "developer" | |
176 | #~ msgstr "разработчик" |
|
183 | #~ msgstr "разработчик" | |
177 |
|
184 | |||
178 | #~ msgid "javascript developer" |
|
185 | #~ msgid "javascript developer" | |
179 | #~ msgstr "разработчик javascript" |
|
186 | #~ msgstr "разработчик javascript" | |
180 |
|
187 | |||
181 | #~ msgid "designer" |
|
188 | #~ msgid "designer" | |
182 | #~ msgstr "дизайнер" |
|
189 | #~ msgstr "дизайнер" |
@@ -1,30 +1,14 b'' | |||||
1 | {% extends "boards/base.html" %} |
|
1 | {% extends "boards/base.html" %} | |
2 |
|
2 | |||
3 | {% load i18n %} |
|
3 | {% load i18n %} | |
4 |
|
4 | |||
5 | {% block head %} |
|
5 | {% block head %} | |
6 |
<title>{% trans " |
|
6 | <title>{% trans "Not found" %}</title> | |
7 | {% endblock %} |
|
7 | {% endblock %} | |
8 |
|
8 | |||
9 | {% block content %} |
|
9 | {% block content %} | |
10 | <div class="post"> |
|
10 | <div class="post"> | |
11 | <h2>Authors</h2> |
|
11 | <p><img src="{{ STATIC_URL }}images/404.png" width="200" /></p> | |
12 | {% for nick, values in authors.items %} |
|
12 | <p>{% trans 'This page does not exist' %}</p> | |
13 | <p> |
|
|||
14 | <b>{{ nick }}</b> ({{ values.name }}): |
|
|||
15 | {% for value in values.contacts %} |
|
|||
16 | <a href="mailto:{{ value }}">{{ value }}</a> |
|
|||
17 | {% endfor %} - |
|
|||
18 | {% for role in values.roles %} |
|
|||
19 | {% trans role %} |
|
|||
20 | {% endfor %} |
|
|||
21 | </p> |
|
|||
22 | {% endfor %} |
|
|||
23 | <br /> |
|
|||
24 | <p>{% trans "Distributed under the" %} |
|
|||
25 | <a href="http://www.gnu.org/licenses/gpl.html" >GNU GPLv3</a> |
|
|||
26 | {% trans "license" %}</p> |
|
|||
27 | <p><a href="https://bitbucket.org/neko259/neboard"> |
|
|||
28 | {% trans "Repository" %}</a></p> |
|
|||
29 | </div> |
|
13 | </div> | |
30 | {% endblock %} No newline at end of file |
|
14 | {% endblock %} |
@@ -1,256 +1,261 b'' | |||||
1 | from django.core.urlresolvers import reverse |
|
1 | from django.core.urlresolvers import reverse | |
2 | from django.template import RequestContext |
|
2 | from django.template import RequestContext | |
3 | from django.shortcuts import render, redirect, get_object_or_404 |
|
3 | from django.shortcuts import render, redirect, get_object_or_404 | |
4 | from django.http import HttpResponseRedirect |
|
4 | from django.http import HttpResponseRedirect | |
5 |
|
5 | |||
6 | from boards import forms |
|
6 | from boards import forms | |
7 | import boards |
|
7 | import boards | |
8 | from boards import utils |
|
8 | from boards import utils | |
9 | from boards.forms import ThreadForm, PostForm, SettingsForm, PlainErrorList, \ |
|
9 | from boards.forms import ThreadForm, PostForm, SettingsForm, PlainErrorList, \ | |
10 | ThreadCaptchaForm, PostCaptchaForm |
|
10 | ThreadCaptchaForm, PostCaptchaForm | |
11 |
|
11 | |||
12 | from boards.models import Post, Admin, Tag, Ban |
|
12 | from boards.models import Post, Admin, Tag, Ban | |
13 | from boards import authors |
|
13 | from boards import authors | |
14 | import neboard |
|
14 | import neboard | |
15 |
|
15 | |||
16 |
|
16 | |||
17 | def index(request, page=0): |
|
17 | def index(request, page=0): | |
18 | context = _init_default_context(request) |
|
18 | context = _init_default_context(request) | |
19 |
|
19 | |||
20 | if utils.need_include_captcha(request): |
|
20 | if utils.need_include_captcha(request): | |
21 | threadFormClass = ThreadCaptchaForm |
|
21 | threadFormClass = ThreadCaptchaForm | |
22 | kwargs = {'request': request} |
|
22 | kwargs = {'request': request} | |
23 | else: |
|
23 | else: | |
24 | threadFormClass = ThreadForm |
|
24 | threadFormClass = ThreadForm | |
25 | kwargs = {} |
|
25 | kwargs = {} | |
26 |
|
26 | |||
27 | if request.method == 'POST': |
|
27 | if request.method == 'POST': | |
28 | form = threadFormClass(request.POST, request.FILES, |
|
28 | form = threadFormClass(request.POST, request.FILES, | |
29 | error_class=PlainErrorList, **kwargs) |
|
29 | error_class=PlainErrorList, **kwargs) | |
30 |
|
30 | |||
31 | if form.is_valid(): |
|
31 | if form.is_valid(): | |
32 | return _new_post(request, form) |
|
32 | return _new_post(request, form) | |
33 | else: |
|
33 | else: | |
34 | form = threadFormClass(error_class=PlainErrorList, **kwargs) |
|
34 | form = threadFormClass(error_class=PlainErrorList, **kwargs) | |
35 |
|
35 | |||
36 | threads = Post.objects.get_threads(page=int(page)) |
|
36 | threads = Post.objects.get_threads(page=int(page)) | |
37 |
|
37 | |||
38 | context['threads'] = None if len(threads) == 0 else threads |
|
38 | context['threads'] = None if len(threads) == 0 else threads | |
39 | context['form'] = form |
|
39 | context['form'] = form | |
40 | context['pages'] = range(Post.objects.get_thread_page_count()) |
|
40 | context['pages'] = range(Post.objects.get_thread_page_count()) | |
41 |
|
41 | |||
42 | return render(request, 'boards/posting_general.html', |
|
42 | return render(request, 'boards/posting_general.html', | |
43 | context) |
|
43 | context) | |
44 |
|
44 | |||
45 |
|
45 | |||
46 | def _new_post(request, form, thread_id=boards.models.NO_PARENT): |
|
46 | def _new_post(request, form, thread_id=boards.models.NO_PARENT): | |
47 | """Add a new post (in thread or as a reply).""" |
|
47 | """Add a new post (in thread or as a reply).""" | |
48 |
|
48 | |||
49 | ip = _get_client_ip(request) |
|
49 | ip = _get_client_ip(request) | |
50 | is_banned = Ban.objects.filter(ip=ip).count() > 0 |
|
50 | is_banned = Ban.objects.filter(ip=ip).count() > 0 | |
51 |
|
51 | |||
52 | if is_banned: |
|
52 | if is_banned: | |
53 | return redirect(you_are_banned) |
|
53 | return redirect(you_are_banned) | |
54 |
|
54 | |||
55 | data = form.cleaned_data |
|
55 | data = form.cleaned_data | |
56 |
|
56 | |||
57 | title = data['title'] |
|
57 | title = data['title'] | |
58 | text = data['text'] |
|
58 | text = data['text'] | |
59 |
|
59 | |||
60 | if 'image' in data.keys(): |
|
60 | if 'image' in data.keys(): | |
61 | image = data['image'] |
|
61 | image = data['image'] | |
62 | else: |
|
62 | else: | |
63 | image = None |
|
63 | image = None | |
64 |
|
64 | |||
65 | tags = [] |
|
65 | tags = [] | |
66 |
|
66 | |||
67 | new_thread = thread_id == boards.models.NO_PARENT |
|
67 | new_thread = thread_id == boards.models.NO_PARENT | |
68 | if new_thread: |
|
68 | if new_thread: | |
69 | tag_strings = data['tags'] |
|
69 | tag_strings = data['tags'] | |
70 |
|
70 | |||
71 | if tag_strings: |
|
71 | if tag_strings: | |
72 | tag_strings = tag_strings.split(' ') |
|
72 | tag_strings = tag_strings.split(' ') | |
73 | for tag_name in tag_strings: |
|
73 | for tag_name in tag_strings: | |
74 | tag_name = tag_name.strip() |
|
74 | tag_name = tag_name.strip() | |
75 | if len(tag_name) > 0: |
|
75 | if len(tag_name) > 0: | |
76 | tag, created = Tag.objects.get_or_create(name=tag_name) |
|
76 | tag, created = Tag.objects.get_or_create(name=tag_name) | |
77 | tags.append(tag) |
|
77 | tags.append(tag) | |
78 |
|
78 | |||
79 | # TODO Add a possibility to define a link image instead of an image file. |
|
79 | # TODO Add a possibility to define a link image instead of an image file. | |
80 | # If a link is given, download the image automatically. |
|
80 | # If a link is given, download the image automatically. | |
81 |
|
81 | |||
82 | post = Post.objects.create_post(title=title, text=text, ip=ip, |
|
82 | post = Post.objects.create_post(title=title, text=text, ip=ip, | |
83 | parent_id=thread_id, image=image, |
|
83 | parent_id=thread_id, image=image, | |
84 | tags=tags) |
|
84 | tags=tags) | |
85 |
|
85 | |||
86 | thread_to_show = (post.id if new_thread else thread_id) |
|
86 | thread_to_show = (post.id if new_thread else thread_id) | |
87 |
|
87 | |||
88 | if new_thread: |
|
88 | if new_thread: | |
89 | return redirect(thread, post_id=thread_to_show) |
|
89 | return redirect(thread, post_id=thread_to_show) | |
90 | else: |
|
90 | else: | |
91 | return redirect(reverse(thread, |
|
91 | return redirect(reverse(thread, | |
92 | kwargs={'post_id': thread_to_show}) + '#' |
|
92 | kwargs={'post_id': thread_to_show}) + '#' | |
93 | + str(post.id)) |
|
93 | + str(post.id)) | |
94 |
|
94 | |||
95 |
|
95 | |||
96 | def tag(request, tag_name, page=0): |
|
96 | def tag(request, tag_name, page=0): | |
97 | """Get all tag threads (posts without a parent).""" |
|
97 | """Get all tag threads (posts without a parent).""" | |
98 |
|
98 | |||
99 | tag = get_object_or_404(Tag, name=tag_name) |
|
99 | tag = get_object_or_404(Tag, name=tag_name) | |
100 | threads = Post.objects.get_threads(tag=tag, page=int(page)) |
|
100 | threads = Post.objects.get_threads(tag=tag, page=int(page)) | |
101 |
|
101 | |||
102 | if request.method == 'POST': |
|
102 | if request.method == 'POST': | |
103 | form = ThreadForm(request.POST, request.FILES, |
|
103 | form = ThreadForm(request.POST, request.FILES, | |
104 | error_class=PlainErrorList) |
|
104 | error_class=PlainErrorList) | |
105 | if form.is_valid(): |
|
105 | if form.is_valid(): | |
106 | return _new_post(request, form) |
|
106 | return _new_post(request, form) | |
107 | else: |
|
107 | else: | |
108 | form = forms.ThreadForm(initial={'tags': tag_name}, |
|
108 | form = forms.ThreadForm(initial={'tags': tag_name}, | |
109 | error_class=PlainErrorList) |
|
109 | error_class=PlainErrorList) | |
110 |
|
110 | |||
111 | context = _init_default_context(request) |
|
111 | context = _init_default_context(request) | |
112 | context['threads'] = None if len(threads) == 0 else threads |
|
112 | context['threads'] = None if len(threads) == 0 else threads | |
113 | context['tag'] = tag_name |
|
113 | context['tag'] = tag_name | |
114 | context['pages'] = range(Post.objects.get_thread_page_count(tag=tag)) |
|
114 | context['pages'] = range(Post.objects.get_thread_page_count(tag=tag)) | |
115 |
|
115 | |||
116 | context['form'] = form |
|
116 | context['form'] = form | |
117 |
|
117 | |||
118 | return render(request, 'boards/posting_general.html', |
|
118 | return render(request, 'boards/posting_general.html', | |
119 | context) |
|
119 | context) | |
120 |
|
120 | |||
121 |
|
121 | |||
122 | def thread(request, post_id): |
|
122 | def thread(request, post_id): | |
123 | """Get all thread posts""" |
|
123 | """Get all thread posts""" | |
124 |
|
124 | |||
125 | if utils.need_include_captcha(request): |
|
125 | if utils.need_include_captcha(request): | |
126 | postFormClass = PostCaptchaForm |
|
126 | postFormClass = PostCaptchaForm | |
127 | kwargs = {'request': request} |
|
127 | kwargs = {'request': request} | |
128 | else: |
|
128 | else: | |
129 | postFormClass = PostForm |
|
129 | postFormClass = PostForm | |
130 | kwargs = {} |
|
130 | kwargs = {} | |
131 |
|
131 | |||
132 | if request.method == 'POST': |
|
132 | if request.method == 'POST': | |
133 | form = postFormClass(request.POST, request.FILES, |
|
133 | form = postFormClass(request.POST, request.FILES, | |
134 | error_class=PlainErrorList, **kwargs) |
|
134 | error_class=PlainErrorList, **kwargs) | |
135 | if form.is_valid(): |
|
135 | if form.is_valid(): | |
136 | return _new_post(request, form, post_id) |
|
136 | return _new_post(request, form, post_id) | |
137 | else: |
|
137 | else: | |
138 | form = postFormClass(error_class=PlainErrorList, **kwargs) |
|
138 | form = postFormClass(error_class=PlainErrorList, **kwargs) | |
139 |
|
139 | |||
140 | posts = Post.objects.get_thread(post_id) |
|
140 | posts = Post.objects.get_thread(post_id) | |
141 |
|
141 | |||
142 | context = _init_default_context(request) |
|
142 | context = _init_default_context(request) | |
143 |
|
143 | |||
144 | context['posts'] = posts |
|
144 | context['posts'] = posts | |
145 | context['form'] = form |
|
145 | context['form'] = form | |
146 |
|
146 | |||
147 | return render(request, 'boards/thread.html', context) |
|
147 | return render(request, 'boards/thread.html', context) | |
148 |
|
148 | |||
149 |
|
149 | |||
150 | def login(request): |
|
150 | def login(request): | |
151 | """Log in as admin""" |
|
151 | """Log in as admin""" | |
152 |
|
152 | |||
153 | if 'name' in request.POST and 'password' in request.POST: |
|
153 | if 'name' in request.POST and 'password' in request.POST: | |
154 | request.session['admin'] = False |
|
154 | request.session['admin'] = False | |
155 |
|
155 | |||
156 | isAdmin = len(Admin.objects.filter(name=request.POST['name'], |
|
156 | isAdmin = len(Admin.objects.filter(name=request.POST['name'], | |
157 | password=request.POST[ |
|
157 | password=request.POST[ | |
158 | 'password'])) > 0 |
|
158 | 'password'])) > 0 | |
159 |
|
159 | |||
160 | if isAdmin: |
|
160 | if isAdmin: | |
161 | request.session['admin'] = True |
|
161 | request.session['admin'] = True | |
162 |
|
162 | |||
163 | response = HttpResponseRedirect('/') |
|
163 | response = HttpResponseRedirect('/') | |
164 |
|
164 | |||
165 | else: |
|
165 | else: | |
166 | response = render(request, 'boards/login.html', {'error': 'Login error'}) |
|
166 | response = render(request, 'boards/login.html', {'error': 'Login error'}) | |
167 | else: |
|
167 | else: | |
168 | response = render(request, 'boards/login.html', {}) |
|
168 | response = render(request, 'boards/login.html', {}) | |
169 |
|
169 | |||
170 | return response |
|
170 | return response | |
171 |
|
171 | |||
172 |
|
172 | |||
173 | def logout(request): |
|
173 | def logout(request): | |
174 | request.session['admin'] = False |
|
174 | request.session['admin'] = False | |
175 | return HttpResponseRedirect('/') |
|
175 | return HttpResponseRedirect('/') | |
176 |
|
176 | |||
177 |
|
177 | |||
178 | def settings(request): |
|
178 | def settings(request): | |
179 | """User's settings""" |
|
179 | """User's settings""" | |
180 |
|
180 | |||
181 | context = RequestContext(request) |
|
181 | context = RequestContext(request) | |
182 |
|
182 | |||
183 | if request.method == 'POST': |
|
183 | if request.method == 'POST': | |
184 | form = SettingsForm(request.POST) |
|
184 | form = SettingsForm(request.POST) | |
185 | if form.is_valid(): |
|
185 | if form.is_valid(): | |
186 | selected_theme = form.cleaned_data['theme'] |
|
186 | selected_theme = form.cleaned_data['theme'] | |
187 | request.session['theme'] = selected_theme |
|
187 | request.session['theme'] = selected_theme | |
188 |
|
188 | |||
189 | return redirect(settings) |
|
189 | return redirect(settings) | |
190 | else: |
|
190 | else: | |
191 | selected_theme = _get_theme(request) |
|
191 | selected_theme = _get_theme(request) | |
192 | form = SettingsForm(initial={'theme': selected_theme}) |
|
192 | form = SettingsForm(initial={'theme': selected_theme}) | |
193 | context['form'] = form |
|
193 | context['form'] = form | |
194 | context['tags'] = Tag.objects.get_popular_tags() |
|
194 | context['tags'] = Tag.objects.get_popular_tags() | |
195 | context['theme'] = _get_theme(request) |
|
195 | context['theme'] = _get_theme(request) | |
196 |
|
196 | |||
197 | return render(request, 'boards/settings.html', context) |
|
197 | return render(request, 'boards/settings.html', context) | |
198 |
|
198 | |||
199 |
|
199 | |||
200 | def all_tags(request): |
|
200 | def all_tags(request): | |
201 | """All tags list""" |
|
201 | """All tags list""" | |
202 |
|
202 | |||
203 | context = _init_default_context(request) |
|
203 | context = _init_default_context(request) | |
204 | context['all_tags'] = Tag.objects.get_not_empty_tags() |
|
204 | context['all_tags'] = Tag.objects.get_not_empty_tags() | |
205 |
|
205 | |||
206 | return render(request, 'boards/tags.html', context) |
|
206 | return render(request, 'boards/tags.html', context) | |
207 |
|
207 | |||
208 |
|
208 | |||
209 | def jump_to_post(request, post_id): |
|
209 | def jump_to_post(request, post_id): | |
210 | """Determine thread in which the requested post is and open it's page""" |
|
210 | """Determine thread in which the requested post is and open it's page""" | |
211 |
|
211 | |||
212 | post = get_object_or_404(Post, id=post_id) |
|
212 | post = get_object_or_404(Post, id=post_id) | |
213 |
|
213 | |||
214 | if boards.models.NO_PARENT == post.parent: |
|
214 | if boards.models.NO_PARENT == post.parent: | |
215 | return redirect(thread, post_id=post.id) |
|
215 | return redirect(thread, post_id=post.id) | |
216 | else: |
|
216 | else: | |
217 | parent_thread = get_object_or_404(Post, id=post.parent) |
|
217 | parent_thread = get_object_or_404(Post, id=post.parent) | |
218 | return redirect(reverse(thread, kwargs={'post_id': parent_thread.id}) |
|
218 | return redirect(reverse(thread, kwargs={'post_id': parent_thread.id}) | |
219 | + '#' + str(post.id)) |
|
219 | + '#' + str(post.id)) | |
220 |
|
220 | |||
221 |
|
221 | |||
222 | def authors(request): |
|
222 | def authors(request): | |
223 | context = _init_default_context(request) |
|
223 | context = _init_default_context(request) | |
224 | context['authors'] = boards.authors.authors |
|
224 | context['authors'] = boards.authors.authors | |
225 |
|
225 | |||
226 | return render(request, 'boards/authors.html', context) |
|
226 | return render(request, 'boards/authors.html', context) | |
227 |
|
227 | |||
228 |
|
228 | |||
229 | def you_are_banned(request): |
|
229 | def you_are_banned(request): | |
230 | context = _init_default_context(request) |
|
230 | context = _init_default_context(request) | |
231 | return render(request, 'boards/banned.html', context) |
|
231 | return render(request, 'boards/banned.html', context) | |
232 |
|
232 | |||
233 |
|
233 | |||
|
234 | def page_404(request): | |||
|
235 | context = _init_default_context(request) | |||
|
236 | return render(request, 'boards/404.html', context) | |||
|
237 | ||||
|
238 | ||||
234 | def _get_theme(request): |
|
239 | def _get_theme(request): | |
235 | """Get user's CSS theme""" |
|
240 | """Get user's CSS theme""" | |
236 |
|
241 | |||
237 | return request.session.get('theme', neboard.settings.DEFAULT_THEME) |
|
242 | return request.session.get('theme', neboard.settings.DEFAULT_THEME) | |
238 |
|
243 | |||
239 |
|
244 | |||
240 | def _get_client_ip(request): |
|
245 | def _get_client_ip(request): | |
241 | x_forwarded_for = request.META.get('HTTP_X_FORWARDED_FOR') |
|
246 | x_forwarded_for = request.META.get('HTTP_X_FORWARDED_FOR') | |
242 | if x_forwarded_for: |
|
247 | if x_forwarded_for: | |
243 | ip = x_forwarded_for.split(',')[-1].strip() |
|
248 | ip = x_forwarded_for.split(',')[-1].strip() | |
244 | else: |
|
249 | else: | |
245 | ip = request.META.get('REMOTE_ADDR') |
|
250 | ip = request.META.get('REMOTE_ADDR') | |
246 | return ip |
|
251 | return ip | |
247 |
|
252 | |||
248 |
|
253 | |||
249 | def _init_default_context(request): |
|
254 | def _init_default_context(request): | |
250 | """Create context with default values that are used in most views""" |
|
255 | """Create context with default values that are used in most views""" | |
251 |
|
256 | |||
252 | context = RequestContext(request) |
|
257 | context = RequestContext(request) | |
253 | context['tags'] = Tag.objects.get_popular_tags() |
|
258 | context['tags'] = Tag.objects.get_popular_tags() | |
254 | context['theme'] = _get_theme(request) |
|
259 | context['theme'] = _get_theme(request) | |
255 |
|
260 | |||
256 | return context |
|
261 | return context |
@@ -1,23 +1,23 b'' | |||||
1 | from django.conf.urls import patterns, include, url |
|
1 | from django.conf.urls import patterns, include, url | |
2 |
|
2 | |||
3 | # Uncomment the next two lines to enable the admin: |
|
3 | # Uncomment the next two lines to enable the admin: | |
4 | from django.conf.urls.static import static |
|
4 | from django.conf.urls.static import static | |
5 | from django.contrib import admin |
|
5 | from django.contrib import admin | |
6 | from neboard import settings |
|
6 | from neboard import settings | |
7 |
|
7 | |||
8 | admin.autodiscover() |
|
8 | admin.autodiscover() | |
9 |
|
9 | |||
10 | urlpatterns = patterns('', |
|
10 | urlpatterns = patterns('', | |
11 | # Examples: |
|
11 | # Examples: | |
12 | # url(r'^$', 'neboard.views.home', name='home'), |
|
12 | # url(r'^$', 'neboard.views.home', name='home'), | |
13 | # url(r'^neboard/', include('neboard.foo.urls')), |
|
13 | # url(r'^neboard/', include('neboard.foo.urls')), | |
14 |
|
14 | |||
15 | # Uncomment the admin/doc line below to enable admin documentation: |
|
15 | # Uncomment the admin/doc line below to enable admin documentation: | |
16 | # url(r'^admin/doc/', include('django.contrib.admindocs.urls')), |
|
16 | # url(r'^admin/doc/', include('django.contrib.admindocs.urls')), | |
17 |
|
17 | |||
18 | # Uncomment the next line to enable the admin: |
|
18 | # Uncomment the next line to enable the admin: | |
19 | url(r'^admin/', include(admin.site.urls)), |
|
19 | url(r'^admin/', include(admin.site.urls)), | |
20 | url(r'^', include('boards.urls')), |
|
20 | url(r'^', include('boards.urls')), | |
21 | ) + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) |
|
21 | ) + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) | |
22 |
|
22 | |||
23 |
|
23 | handler404 = 'boards.views.page_404' |
General Comments 0
You need to be logged in to leave comments.
Login now