##// END OF EJS Templates
Added ability to reset tripcode
neko259 -
r1296:34238f79 default
parent child Browse files
Show More
@@ -0,0 +1,27 b''
1 class Tripcode:
2 def __init__(self, code_str):
3 self.tripcode = code_str
4
5 def get_color(self):
6 return self.tripcode[:6]
7
8 def get_background(self):
9 code = self.get_color()
10 result = ''
11
12 for i in range(0, len(code), 2):
13 p = code[i:i+2]
14 background = hex(255 - int(p, 16))[2:]
15 if len(background) < 2:
16 background = '0' + background
17 result += background
18
19 return result
20
21 def get_short_text(self):
22 return self.tripcode[:8]
23
24 def get_view(self):
25 return '<span style="color: #{}; background: #{}">{}</span>'\
26 .format(self.get_color(), self.get_background(),
27 self.get_short_text()) No newline at end of file
@@ -1,3 +1,4 b''
1 import uuid
1 from django.shortcuts import get_object_or_404
2 from django.shortcuts import get_object_or_404
2 from boards.models import Tag
3 from boards.models import Tag
3
4
@@ -15,6 +16,7 b" SETTING_PERMISSIONS = 'permissions'"
15 SETTING_USERNAME = 'username'
16 SETTING_USERNAME = 'username'
16 SETTING_LAST_NOTIFICATION_ID = 'last_notification'
17 SETTING_LAST_NOTIFICATION_ID = 'last_notification'
17 SETTING_IMAGE_VIEWER = 'image_viewer'
18 SETTING_IMAGE_VIEWER = 'image_viewer'
19 SETTING_TRIPCODE = 'tripcode'
18
20
19 DEFAULT_THEME = 'md'
21 DEFAULT_THEME = 'md'
20
22
@@ -116,6 +118,12 b' class SettingsManager:'
116 tags.remove(tag.name)
118 tags.remove(tag.name)
117 self.set_setting(SETTING_HIDDEN_TAGS, tags)
119 self.set_setting(SETTING_HIDDEN_TAGS, tags)
118
120
121 def get_tripcode(self):
122 return self.get_setting(SETTING_TRIPCODE, str(uuid.uuid4()))
123
124 def reset_tripcode(self):
125 self.set_setting(SETTING_TRIPCODE, str(uuid.uuid4()))
126
119
127
120 class SessionSettingsManager(SettingsManager):
128 class SessionSettingsManager(SettingsManager):
121 """
129 """
@@ -130,6 +138,7 b' class SessionSettingsManager(SettingsMan'
130 if setting in self.session:
138 if setting in self.session:
131 return self.session[setting]
139 return self.session[setting]
132 else:
140 else:
141 self.set_setting(setting, default)
133 return default
142 return default
134
143
135 def set_setting(self, setting, value):
144 def set_setting(self, setting, value):
@@ -1,8 +1,7 b''
1 import hashlib
2 import re
1 import re
3 import time
2 import time
3
4 import pytz
4 import pytz
5
6 from django import forms
5 from django import forms
7 from django.core.files.uploadedfile import SimpleUploadedFile
6 from django.core.files.uploadedfile import SimpleUploadedFile
8 from django.core.exceptions import ObjectDoesNotExist
7 from django.core.exceptions import ObjectDoesNotExist
@@ -10,6 +9,7 b' from django.forms.util import ErrorList'
10 from django.utils.translation import ugettext_lazy as _
9 from django.utils.translation import ugettext_lazy as _
11 import requests
10 import requests
12
11
12 from boards.abstracts.settingsmanager import SessionSettingsManager
13 from boards.mdx_neboard import formatters
13 from boards.mdx_neboard import formatters
14 from boards.models.post import TITLE_MAX_LENGTH
14 from boards.models.post import TITLE_MAX_LENGTH
15 from boards.models import Tag, Post
15 from boards.models import Tag, Post
@@ -241,7 +241,7 b' class PostForm(NeboardForm):'
241
241
242 def get_tripcode(self):
242 def get_tripcode(self):
243 if self.cleaned_data['tripcode']:
243 if self.cleaned_data['tripcode']:
244 return hashlib.sha1(self.session.session_key.encode()).hexdigest()
244 return SessionSettingsManager(self.session).get_tripcode()
245
245
246 def _clean_text_file(self):
246 def _clean_text_file(self):
247 text = self.cleaned_data.get('text')
247 text = self.cleaned_data.get('text')
@@ -366,7 +366,7 b' class ThreadForm(PostForm):'
366 class SettingsForm(NeboardForm):
366 class SettingsForm(NeboardForm):
367
367
368 theme = forms.ChoiceField(choices=settings.THEMES, label=_('Theme'))
368 theme = forms.ChoiceField(choices=settings.THEMES, label=_('Theme'))
369 image_viewer = forms.ChoiceField(choices=settings.IMAGE_VIEWERS, label=_('image view mode'))
369 image_viewer = forms.ChoiceField(choices=settings.IMAGE_VIEWERS, label=_('Image view mode'))
370 username = forms.CharField(label=_('User name'), required=False)
370 username = forms.CharField(label=_('User name'), required=False)
371 timezone = forms.ChoiceField(choices=get_timezones(), label=_('Time zone'))
371 timezone = forms.ChoiceField(choices=get_timezones(), label=_('Time zone'))
372
372
1 NO CONTENT: modified file, binary diff hidden
NO CONTENT: modified file, binary diff hidden
@@ -7,7 +7,7 b' 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: 2015-08-21 11:01+0300\n"
10 "POT-Creation-Date: 2015-08-22 15:07+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"
@@ -38,111 +38,114 b' msgstr "\xd1\x80\xd0\xb0\xd0\xb7\xd1\x80\xd0\xb0\xd0\xb1\xd0\xbe\xd1\x82\xd1\x87\xd0\xb8\xd0\xba javascript"'
38 msgid "designer"
38 msgid "designer"
39 msgstr "Π΄ΠΈΠ·Π°ΠΉΠ½Π΅Ρ€"
39 msgstr "Π΄ΠΈΠ·Π°ΠΉΠ½Π΅Ρ€"
40
40
41 #: forms.py:30
41 #: forms.py:31
42 msgid "Type message here. Use formatting panel for more advanced usage."
42 msgid "Type message here. Use formatting panel for more advanced usage."
43 msgstr ""
43 msgstr ""
44 "Π’Π²ΠΎΠ΄ΠΈΡ‚Π΅ сообщСниС сюда. Π˜ΡΠΏΠΎΠ»ΡŒΠ·ΡƒΠΉΡ‚Π΅ панСль для Π±ΠΎΠ»Π΅Π΅ слоТного форматирования."
44 "Π’Π²ΠΎΠ΄ΠΈΡ‚Π΅ сообщСниС сюда. Π˜ΡΠΏΠΎΠ»ΡŒΠ·ΡƒΠΉΡ‚Π΅ панСль для Π±ΠΎΠ»Π΅Π΅ слоТного форматирования."
45
45
46 #: forms.py:31
46 #: forms.py:32
47 msgid "music images i_dont_like_tags"
47 msgid "music images i_dont_like_tags"
48 msgstr "ΠΌΡƒΠ·Ρ‹ΠΊΠ° ΠΊΠ°Ρ€Ρ‚ΠΈΠ½ΠΊΠΈ Ρ‚Π΅Π³ΠΈ_Π½Π΅_Π½ΡƒΠΆΠ½Ρ‹"
48 msgstr "ΠΌΡƒΠ·Ρ‹ΠΊΠ° ΠΊΠ°Ρ€Ρ‚ΠΈΠ½ΠΊΠΈ Ρ‚Π΅Π³ΠΈ_Π½Π΅_Π½ΡƒΠΆΠ½Ρ‹"
49
49
50 #: forms.py:33
50 #: forms.py:34
51 msgid "Title"
51 msgid "Title"
52 msgstr "Π—Π°Π³ΠΎΠ»ΠΎΠ²ΠΎΠΊ"
52 msgstr "Π—Π°Π³ΠΎΠ»ΠΎΠ²ΠΎΠΊ"
53
53
54 #: forms.py:34
54 #: forms.py:35
55 msgid "Text"
55 msgid "Text"
56 msgstr "ВСкст"
56 msgstr "ВСкст"
57
57
58 #: forms.py:35
58 #: forms.py:36
59 msgid "Tag"
59 msgid "Tag"
60 msgstr "ΠœΠ΅Ρ‚ΠΊΠ°"
60 msgstr "ΠœΠ΅Ρ‚ΠΊΠ°"
61
61
62 #: forms.py:36 templates/boards/base.html:40 templates/search/search.html:7
62 #: forms.py:37 templates/boards/base.html:40 templates/search/search.html:7
63 msgid "Search"
63 msgid "Search"
64 msgstr "Поиск"
64 msgstr "Поиск"
65
65
66 #: forms.py:38
66 #: forms.py:39
67 #, python-format
67 #, python-format
68 msgid "Please wait %s seconds before sending message"
68 msgid "Please wait %s seconds before sending message"
69 msgstr "ΠŸΠΎΠΆΠ°Π»ΡƒΠΉΡΡ‚Π° ΠΏΠΎΠ΄ΠΎΠΆΠ΄ΠΈΡ‚Π΅ %s сСкунд ΠΏΠ΅Ρ€Π΅Π΄ ΠΎΡ‚ΠΏΡ€Π°Π²ΠΊΠΎΠΉ сообщСния"
69 msgstr "ΠŸΠΎΠΆΠ°Π»ΡƒΠΉΡΡ‚Π° ΠΏΠΎΠ΄ΠΎΠΆΠ΄ΠΈΡ‚Π΅ %s сСкунд ΠΏΠ΅Ρ€Π΅Π΄ ΠΎΡ‚ΠΏΡ€Π°Π²ΠΊΠΎΠΉ сообщСния"
70
70
71 #: forms.py:139
71 #: forms.py:140
72 msgid "File"
72 msgid "File"
73 msgstr "Π€Π°ΠΉΠ»"
73 msgstr "Π€Π°ΠΉΠ»"
74
74
75 #: forms.py:142
75 #: forms.py:143
76 msgid "File URL"
76 msgid "File URL"
77 msgstr "URL Ρ„Π°ΠΉΠ»Π°"
77 msgstr "URL Ρ„Π°ΠΉΠ»Π°"
78
78
79 #: forms.py:148
79 #: forms.py:149
80 msgid "e-mail"
80 msgid "e-mail"
81 msgstr ""
81 msgstr ""
82
82
83 #: forms.py:151
83 #: forms.py:152
84 msgid "Additional threads"
84 msgid "Additional threads"
85 msgstr "Π”ΠΎΠΏΠΎΠ»Π½ΠΈΡ‚Π΅Π»ΡŒΠ½Ρ‹Π΅ Ρ‚Π΅ΠΌΡ‹"
85 msgstr "Π”ΠΎΠΏΠΎΠ»Π½ΠΈΡ‚Π΅Π»ΡŒΠ½Ρ‹Π΅ Ρ‚Π΅ΠΌΡ‹"
86
86
87 #: forms.py:162
87 #: forms.py:155
88 msgid "Tripcode"
89 msgstr "Π’Ρ€ΠΈΠΏΠΊΠΎΠ΄"
90
91 #: forms.py:164
88 #, python-format
92 #, python-format
89 msgid "Title must have less than %s characters"
93 msgid "Title must have less than %s characters"
90 msgstr "Π—Π°Π³ΠΎΠ»ΠΎΠ²ΠΎΠΊ Π΄ΠΎΠ»ΠΆΠ΅Π½ ΠΈΠΌΠ΅Ρ‚ΡŒ мСньшС %s символов"
94 msgstr "Π—Π°Π³ΠΎΠ»ΠΎΠ²ΠΎΠΊ Π΄ΠΎΠ»ΠΆΠ΅Π½ ΠΈΠΌΠ΅Ρ‚ΡŒ мСньшС %s символов"
91
95
92 #: forms.py:172
96 #: forms.py:174
93 #, python-format
97 #, python-format
94 msgid "Text must have less than %s characters"
98 msgid "Text must have less than %s characters"
95 msgstr "ВСкст Π΄ΠΎΠ»ΠΆΠ΅Π½ Π±Ρ‹Ρ‚ΡŒ ΠΊΠΎΡ€ΠΎΡ‡Π΅ %s символов"
99 msgstr "ВСкст Π΄ΠΎΠ»ΠΆΠ΅Π½ Π±Ρ‹Ρ‚ΡŒ ΠΊΠΎΡ€ΠΎΡ‡Π΅ %s символов"
96
100
97 #: forms.py:192
101 #: forms.py:194
98 msgid "Invalid URL"
102 msgid "Invalid URL"
99 msgstr "НСвСрный URL"
103 msgstr "НСвСрный URL"
100
104
101 #: forms.py:213
105 #: forms.py:215
102 msgid "Invalid additional thread list"
106 msgid "Invalid additional thread list"
103 msgstr "НСвСрный список Π΄ΠΎΠΏΠΎΠ»Π½ΠΈΡ‚Π΅Π»ΡŒΠ½Ρ‹Ρ… Ρ‚Π΅ΠΌ"
107 msgstr "НСвСрный список Π΄ΠΎΠΏΠΎΠ»Π½ΠΈΡ‚Π΅Π»ΡŒΠ½Ρ‹Ρ… Ρ‚Π΅ΠΌ"
104
108
105 #: forms.py:245
109 #: forms.py:251
106 msgid "Either text or file must be entered."
110 msgid "Either text or file must be entered."
107 msgstr "ВСкст ΠΈΠ»ΠΈ Ρ„Π°ΠΉΠ» Π΄ΠΎΠ»ΠΆΠ½Ρ‹ Π±Ρ‹Ρ‚ΡŒ Π²Π²Π΅Π΄Π΅Π½Ρ‹."
111 msgstr "ВСкст ΠΈΠ»ΠΈ Ρ„Π°ΠΉΠ» Π΄ΠΎΠ»ΠΆΠ½Ρ‹ Π±Ρ‹Ρ‚ΡŒ Π²Π²Π΅Π΄Π΅Π½Ρ‹."
108
112
109 #: forms.py:283
113 #: forms.py:289
110 #, python-format
114 #, python-format
111 msgid "File must be less than %s bytes"
115 msgid "File must be less than %s bytes"
112 msgstr "Π€Π°ΠΉΠ» Π΄ΠΎΠ»ΠΆΠ΅Π½ Π±Ρ‹Ρ‚ΡŒ ΠΌΠ΅Π½Π΅Π΅ %s Π±Π°ΠΉΡ‚"
116 msgstr "Π€Π°ΠΉΠ» Π΄ΠΎΠ»ΠΆΠ΅Π½ Π±Ρ‹Ρ‚ΡŒ ΠΌΠ΅Π½Π΅Π΅ %s Π±Π°ΠΉΡ‚"
113
117
114 #: forms.py:329 templates/boards/all_threads.html:154
118 #: forms.py:335 templates/boards/all_threads.html:154
115 #: templates/boards/rss/post.html:10 templates/boards/tags.html:6
119 #: templates/boards/rss/post.html:10 templates/boards/tags.html:6
116 msgid "Tags"
120 msgid "Tags"
117 msgstr "ΠœΠ΅Ρ‚ΠΊΠΈ"
121 msgstr "ΠœΠ΅Ρ‚ΠΊΠΈ"
118
122
119 #: forms.py:336
123 #: forms.py:342
120 msgid "Inappropriate characters in tags."
124 msgid "Inappropriate characters in tags."
121 msgstr "НСдопустимыС символы Π² ΠΌΠ΅Ρ‚ΠΊΠ°Ρ…."
125 msgstr "НСдопустимыС символы Π² ΠΌΠ΅Ρ‚ΠΊΠ°Ρ…."
122
126
123 #: forms.py:350
127 #: forms.py:356
124 msgid "Need at least one section."
128 msgid "Need at least one section."
125 msgstr "НуТСн хотя Π±Ρ‹ ΠΎΠ΄ΠΈΠ½ Ρ€Π°Π·Π΄Π΅Π»."
129 msgstr "НуТСн хотя Π±Ρ‹ ΠΎΠ΄ΠΈΠ½ Ρ€Π°Π·Π΄Π΅Π»."
126
130
127 #: forms.py:362
131 #: forms.py:368
128 msgid "Theme"
132 msgid "Theme"
129 msgstr "Π’Π΅ΠΌΠ°"
133 msgstr "Π’Π΅ΠΌΠ°"
130
134
131 #: forms.py:363
135 #: forms.py:369
132 #, fuzzy
133 #| msgid "Image view mode"
136 #| msgid "Image view mode"
134 msgid "image view mode"
137 msgid "Image view mode"
135 msgstr "Π Π΅ΠΆΠΈΠΌ просмотра ΠΈΠ·ΠΎΠ±Ρ€Π°ΠΆΠ΅Π½ΠΈΠΉ"
138 msgstr "Π Π΅ΠΆΠΈΠΌ просмотра ΠΈΠ·ΠΎΠ±Ρ€Π°ΠΆΠ΅Π½ΠΈΠΉ"
136
139
137 #: forms.py:364
140 #: forms.py:370
138 msgid "User name"
141 msgid "User name"
139 msgstr "Имя ΠΏΠΎΠ»ΡŒΠ·ΠΎΠ²Π°Ρ‚Π΅Π»Ρ"
142 msgstr "Имя ΠΏΠΎΠ»ΡŒΠ·ΠΎΠ²Π°Ρ‚Π΅Π»Ρ"
140
143
141 #: forms.py:365
144 #: forms.py:371
142 msgid "Time zone"
145 msgid "Time zone"
143 msgstr "Часовой пояс"
146 msgstr "Часовой пояс"
144
147
145 #: forms.py:371
148 #: forms.py:377
146 msgid "Inappropriate characters."
149 msgid "Inappropriate characters."
147 msgstr "НСдопустимыС символы."
150 msgstr "НСдопустимыС символы."
148
151
@@ -300,35 +303,35 b' msgstr "\xd0\x92\xd0\xb2\xd0\xb5\xd1\x80\xd1\x85"'
300 msgid "No posts exist. Create the first one!"
303 msgid "No posts exist. Create the first one!"
301 msgstr "НСт сообщСний. Π‘ΠΎΠ·Π΄Π°ΠΉΡ‚Π΅ ΠΏΠ΅Ρ€Π²ΠΎΠ΅!"
304 msgstr "НСт сообщСний. Π‘ΠΎΠ·Π΄Π°ΠΉΡ‚Π΅ ΠΏΠ΅Ρ€Π²ΠΎΠ΅!"
302
305
303 #: templates/boards/post.html:25
306 #: templates/boards/post.html:30
304 msgid "Open"
307 msgid "Open"
305 msgstr "ΠžΡ‚ΠΊΡ€Ρ‹Ρ‚ΡŒ"
308 msgstr "ΠžΡ‚ΠΊΡ€Ρ‹Ρ‚ΡŒ"
306
309
307 #: templates/boards/post.html:27 templates/boards/post.html.py:38
310 #: templates/boards/post.html:32 templates/boards/post.html.py:43
308 msgid "Reply"
311 msgid "Reply"
309 msgstr "ΠžΡ‚Π²Π΅Ρ‚ΠΈΡ‚ΡŒ"
312 msgstr "ΠžΡ‚Π²Π΅Ρ‚ΠΈΡ‚ΡŒ"
310
313
311 #: templates/boards/post.html:33
314 #: templates/boards/post.html:38
312 msgid " in "
315 msgid " in "
313 msgstr " Π² "
316 msgstr " Π² "
314
317
315 #: templates/boards/post.html:43
318 #: templates/boards/post.html:48
316 msgid "Edit"
319 msgid "Edit"
317 msgstr "Π˜Π·ΠΌΠ΅Π½ΠΈΡ‚ΡŒ"
320 msgstr "Π˜Π·ΠΌΠ΅Π½ΠΈΡ‚ΡŒ"
318
321
319 #: templates/boards/post.html:45
322 #: templates/boards/post.html:50
320 msgid "Edit thread"
323 msgid "Edit thread"
321 msgstr "Π˜Π·ΠΌΠ΅Π½ΠΈΡ‚ΡŒ Ρ‚Π΅ΠΌΡƒ"
324 msgstr "Π˜Π·ΠΌΠ΅Π½ΠΈΡ‚ΡŒ Ρ‚Π΅ΠΌΡƒ"
322
325
323 #: templates/boards/post.html:92
326 #: templates/boards/post.html:97
324 msgid "Replies"
327 msgid "Replies"
325 msgstr "ΠžΡ‚Π²Π΅Ρ‚Ρ‹"
328 msgstr "ΠžΡ‚Π²Π΅Ρ‚Ρ‹"
326
329
327 #: templates/boards/post.html:104 templates/boards/thread.html:34
330 #: templates/boards/post.html:109 templates/boards/thread.html:34
328 msgid "messages"
331 msgid "messages"
329 msgstr "сообщСний"
332 msgstr "сообщСний"
330
333
331 #: templates/boards/post.html:105 templates/boards/thread.html:35
334 #: templates/boards/post.html:110 templates/boards/thread.html:35
332 msgid "images"
335 msgid "images"
333 msgstr "ΠΈΠ·ΠΎΠ±Ρ€Π°ΠΆΠ΅Π½ΠΈΠΉ"
336 msgstr "ΠΈΠ·ΠΎΠ±Ρ€Π°ΠΆΠ΅Π½ΠΈΠΉ"
334
337
@@ -336,18 +339,26 b' msgstr "\xd0\xb8\xd0\xb7\xd0\xbe\xd0\xb1\xd1\x80\xd0\xb0\xd0\xb6\xd0\xb5\xd0\xbd\xd0\xb8\xd0\xb9"'
336 msgid "Post image"
339 msgid "Post image"
337 msgstr "Π˜Π·ΠΎΠ±Ρ€Π°ΠΆΠ΅Π½ΠΈΠ΅ сообщСния"
340 msgstr "Π˜Π·ΠΎΠ±Ρ€Π°ΠΆΠ΅Π½ΠΈΠ΅ сообщСния"
338
341
339 #: templates/boards/settings.html:16
342 #: templates/boards/settings.html:15
340 msgid "You are moderator."
343 msgid "You are moderator."
341 msgstr "Π’Ρ‹ ΠΌΠΎΠ΄Π΅Ρ€Π°Ρ‚ΠΎΡ€."
344 msgstr "Π’Ρ‹ ΠΌΠΎΠ΄Π΅Ρ€Π°Ρ‚ΠΎΡ€."
342
345
343 #: templates/boards/settings.html:20
346 #: templates/boards/settings.html:19
344 msgid "Hidden tags:"
347 msgid "Hidden tags:"
345 msgstr "Π‘ΠΊΡ€Ρ‹Ρ‚Ρ‹Π΅ ΠΌΠ΅Ρ‚ΠΊΠΈ:"
348 msgstr "Π‘ΠΊΡ€Ρ‹Ρ‚Ρ‹Π΅ ΠΌΠ΅Ρ‚ΠΊΠΈ:"
346
349
347 #: templates/boards/settings.html:28
350 #: templates/boards/settings.html:27
348 msgid "No hidden tags."
351 msgid "No hidden tags."
349 msgstr "НСт скрытых ΠΌΠ΅Ρ‚ΠΎΠΊ."
352 msgstr "НСт скрытых ΠΌΠ΅Ρ‚ΠΎΠΊ."
350
353
354 #: templates/boards/settings.html:29
355 msgid "Tripcode:"
356 msgstr "Π’Ρ€ΠΈΠΏΠΊΠΎΠ΄:"
357
358 #: templates/boards/settings.html:29
359 msgid "reset"
360 msgstr "ΡΠ±Ρ€ΠΎΡΠΈΡ‚ΡŒ"
361
351 #: templates/boards/settings.html:37
362 #: templates/boards/settings.html:37
352 msgid "Save"
363 msgid "Save"
353 msgstr "Π‘ΠΎΡ…Ρ€Π°Π½ΠΈΡ‚ΡŒ"
364 msgstr "Π‘ΠΎΡ…Ρ€Π°Π½ΠΈΡ‚ΡŒ"
@@ -439,7 +450,6 b' msgid "Reply to thread"'
439 msgstr "ΠžΡ‚Π²Π΅Ρ‚ΠΈΡ‚ΡŒ Π² Ρ‚Π΅ΠΌΡƒ"
450 msgstr "ΠžΡ‚Π²Π΅Ρ‚ΠΈΡ‚ΡŒ Π² Ρ‚Π΅ΠΌΡƒ"
440
451
441 #: templates/boards/thread_normal.html:31
452 #: templates/boards/thread_normal.html:31
442 #| msgid "messages"
443 msgid "to message "
453 msgid "to message "
444 msgstr "Π½Π° сообщСниС"
454 msgstr "Π½Π° сообщСниС"
445
455
@@ -12,6 +12,7 b' from django.template.loader import rende'
12 from django.utils import timezone
12 from django.utils import timezone
13
13
14 from boards import settings
14 from boards import settings
15 from boards.abstracts.tripcode import Tripcode
15 from boards.mdx_neboard import Parser
16 from boards.mdx_neboard import Parser
16 from boards.models import PostImage, Attachment
17 from boards.models import PostImage, Attachment
17 from boards.models.base import Viewable
18 from boards.models.base import Viewable
@@ -440,21 +441,6 b' class Post(models.Model, Viewable):'
440 thread.save(update_fields=['last_edit_time', 'bumpable'])
441 thread.save(update_fields=['last_edit_time', 'bumpable'])
441 self.threads.add(opening_post.get_thread())
442 self.threads.add(opening_post.get_thread())
442
443
443 def get_tripcode_color(self):
444 def get_tripcode(self):
444 return self.tripcode[:6]
445 if self.tripcode:
445
446 return Tripcode(self.tripcode)
446 def get_tripcode_background(self):
447 code = self.get_tripcode_color()
448 result = ''
449
450 for i in range(0, len(code), 2):
451 p = code[i:i+2]
452 background = hex(255 - int(p, 16))[2:]
453 if len(background) < 2:
454 background = '0' + background
455 result += background
456
457 return result
458
459 def get_short_tripcode(self):
460 return self.tripcode[:10]
@@ -9,7 +9,9 b''
9 <span class="title">{{ post.title }}</span>
9 <span class="title">{{ post.title }}</span>
10 <span class="pub_time"><time datetime="{{ post.pub_time|date:'c' }}">{{ post.pub_time }}</time></span>
10 <span class="pub_time"><time datetime="{{ post.pub_time|date:'c' }}">{{ post.pub_time }}</time></span>
11 {% if post.tripcode %}
11 {% if post.tripcode %}
12 <span style="color: #{{ post.get_tripcode_color }}; background: #{{ post.get_tripcode_background }}">{{ post.get_short_tripcode }}</span>
12 {% autoescape off %}
13 {{ post.get_tripcode.get_view }}
14 {% endautoescape %}
13 {% endif %}
15 {% endif %}
14 {% comment %}
16 {% comment %}
15 Thread death time needs to be shown only if the thread is alredy archived
17 Thread death time needs to be shown only if the thread is alredy archived
@@ -9,7 +9,6 b''
9 {% endblock %}
9 {% endblock %}
10
10
11 {% block content %}
11 {% block content %}
12
13 <div class="post">
12 <div class="post">
14 <p>
13 <p>
15 {% if moderator %}
14 {% if moderator %}
@@ -27,6 +26,7 b''
27 {% else %}
26 {% else %}
28 <p>{% trans 'No hidden tags.' %}</p>
27 <p>{% trans 'No hidden tags.' %}</p>
29 {% endif %}
28 {% endif %}
29 <p>{% trans "Tripcode:" %} {% autoescape off %}{{ tripcode.get_view }}{% endautoescape %} (<a href="?reset_tripcode">{% trans "reset" %}</a>)</p>
30 </div>
30 </div>
31
31
32 <div class="post-form-w">
32 <div class="post-form-w">
@@ -4,11 +4,13 b' from django.utils import timezone'
4
4
5 from boards.abstracts.settingsmanager import get_settings_manager, \
5 from boards.abstracts.settingsmanager import get_settings_manager, \
6 SETTING_USERNAME, SETTING_LAST_NOTIFICATION_ID, SETTING_IMAGE_VIEWER
6 SETTING_USERNAME, SETTING_LAST_NOTIFICATION_ID, SETTING_IMAGE_VIEWER
7 from boards.abstracts.tripcode import Tripcode
7 from boards.middlewares import SESSION_TIMEZONE
8 from boards.middlewares import SESSION_TIMEZONE
8 from boards.views.base import BaseBoardView, CONTEXT_FORM
9 from boards.views.base import BaseBoardView, CONTEXT_FORM
9 from boards.forms import SettingsForm, PlainErrorList
10 from boards.forms import SettingsForm, PlainErrorList
10 from boards import settings
11 from boards import settings
11
12
13 PARAM_RESET_TRIPCODE = 'reset_tripcode'
12
14
13 FORM_THEME = 'theme'
15 FORM_THEME = 'theme'
14 FORM_USERNAME = 'username'
16 FORM_USERNAME = 'username'
@@ -16,6 +18,7 b" FORM_TIMEZONE = 'timezone'"
16 FORM_IMAGE_VIEWER = 'image_viewer'
18 FORM_IMAGE_VIEWER = 'image_viewer'
17
19
18 CONTEXT_HIDDEN_TAGS = 'hidden_tags'
20 CONTEXT_HIDDEN_TAGS = 'hidden_tags'
21 CONTEXT_TRIPCODE = 'tripcode'
19
22
20 TEMPLATE = 'boards/settings.html'
23 TEMPLATE = 'boards/settings.html'
21
24
@@ -26,6 +29,9 b' class SettingsView(BaseBoardView):'
26 params = dict()
29 params = dict()
27 settings_manager = get_settings_manager(request)
30 settings_manager = get_settings_manager(request)
28
31
32 if PARAM_RESET_TRIPCODE in request.GET:
33 settings_manager.reset_tripcode()
34
29 selected_theme = settings_manager.get_theme()
35 selected_theme = settings_manager.get_theme()
30
36
31 form = SettingsForm(
37 form = SettingsForm(
@@ -42,6 +48,7 b' class SettingsView(BaseBoardView):'
42
48
43 params[CONTEXT_FORM] = form
49 params[CONTEXT_FORM] = form
44 params[CONTEXT_HIDDEN_TAGS] = settings_manager.get_hidden_tags()
50 params[CONTEXT_HIDDEN_TAGS] = settings_manager.get_hidden_tags()
51 params[CONTEXT_TRIPCODE] = Tripcode(settings_manager.get_tripcode())
45
52
46 return render(request, TEMPLATE, params)
53 return render(request, TEMPLATE, params)
47
54
General Comments 0
You need to be logged in to leave comments. Login now