##// END OF EJS Templates
Added missing profiler script. Removed user's last access time, now getting it from the user's last post time. Added more info to the settings (user's registration and last access time).
neko259 -
r197:4ac7d8f0 default
parent child Browse files
Show More
@@ -0,0 +1,23 b''
1 import sys
2 import cProfile
3 from cStringIO import StringIO
4 from django.conf import settings
5 import line_profiler
6
7 class ProfilerMiddleware(object):
8 def process_view(self, request, callback, callback_args, callback_kwargs):
9 if settings.DEBUG and 'prof' in request.GET:
10 self.profiler = line_profiler.LineProfiler()
11 self.profiler.add_function(callback)
12 self.profiler.enable()
13 args = (request,) + callback_args
14 return callback(*args, **callback_kwargs)
15
16 def process_response(self, request, response):
17 if settings.DEBUG and 'prof' in request.GET:
18 out = StringIO()
19 old_stdout, sys.stdout = sys.stdout, out
20 self.profiler.print_stats()
21 sys.stdout = old_stdout
22 response.content = '<pre>%s</pre>' % out.getvalue()
23 return response
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: 2013-09-14 18:46+0300\n"
10 "POT-Creation-Date: 2013-09-16 20:18+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"
@@ -75,76 +75,76 b' msgstr "ID \xd0\xbf\xd0\xbe\xd0\xbb\xd1\x8c\xd0\xb7\xd0\xbe\xd0\xb2\xd0\xb0\xd1\x82\xd0\xb5\xd0\xbb\xd1\x8f"'
75 msgid "Insert your user id above"
75 msgid "Insert your user id above"
76 msgstr "Вставьте свой ID пользователя выше"
76 msgstr "Вставьте свой ID пользователя выше"
77
77
78 #: templates/boards/posting_general.html:18
78 #: templates/boards/posting_general.html:19
79 msgid "Tag: "
79 msgid "Tag: "
80 msgstr "Тег: "
80 msgstr "Тег: "
81
81
82 #: templates/boards/posting_general.html:43
82 #: templates/boards/posting_general.html:44
83 #: templates/boards/posting_general.html:99 templates/boards/thread.html:27
83 #: templates/boards/posting_general.html:100 templates/boards/thread.html:29
84 #: templates/boards/rss/post.html:5
84 #: templates/boards/rss/post.html:5
85 msgid "Post image"
85 msgid "Post image"
86 msgstr "Изображение сообщения"
86 msgstr "Изображение сообщения"
87
87
88 #: templates/boards/posting_general.html:56
88 #: templates/boards/posting_general.html:57
89 msgid "Reply"
89 msgid "Reply"
90 msgstr "Ответ"
90 msgstr "Ответ"
91
91
92 #: templates/boards/posting_general.html:61 templates/boards/thread.html:45
92 #: templates/boards/posting_general.html:62 templates/boards/thread.html:47
93 msgid "Delete"
93 msgid "Delete"
94 msgstr "Удалить"
94 msgstr "Удалить"
95
95
96 #: templates/boards/posting_general.html:64 templates/boards/thread.html:48
96 #: templates/boards/posting_general.html:65 templates/boards/thread.html:50
97 msgid "Ban IP"
97 msgid "Ban IP"
98 msgstr "Заблокировать IP"
98 msgstr "Заблокировать IP"
99
99
100 #: templates/boards/posting_general.html:73 templates/boards/thread.html:112
100 #: templates/boards/posting_general.html:74 templates/boards/thread.html:116
101 msgid "replies"
101 msgid "replies"
102 msgstr "ответов"
102 msgstr "ответов"
103
103
104 #: templates/boards/posting_general.html:74 templates/boards/thread.html:113
104 #: templates/boards/posting_general.html:75 templates/boards/thread.html:117
105 msgid "images"
105 msgid "images"
106 msgstr "изображений"
106 msgstr "изображений"
107
107
108 #: templates/boards/posting_general.html:76
108 #: templates/boards/posting_general.html:77
109 #: templates/boards/posting_general.html:149 templates/boards/tags.html:7
109 #: templates/boards/posting_general.html:150 templates/boards/tags.html:7
110 #: templates/boards/thread.html:58 templates/boards/rss/post.html:10
110 #: templates/boards/thread.html:60 templates/boards/rss/post.html:10
111 msgid "Tags"
111 msgid "Tags"
112 msgstr "Теги"
112 msgstr "Теги"
113
113
114 #: templates/boards/posting_general.html:125
114 #: templates/boards/posting_general.html:126
115 msgid "No threads exist. Create the first one!"
115 msgid "No threads exist. Create the first one!"
116 msgstr "Нет тем. Создайте первую!"
116 msgstr "Нет тем. Создайте первую!"
117
117
118 #: templates/boards/posting_general.html:131
118 #: templates/boards/posting_general.html:132
119 msgid "Create new thread"
119 msgid "Create new thread"
120 msgstr "Создать новую тему"
120 msgstr "Создать новую тему"
121
121
122 #: templates/boards/posting_general.html:134 templates/boards/thread.html:77
122 #: templates/boards/posting_general.html:135 templates/boards/thread.html:80
123 msgid "Title"
123 msgid "Title"
124 msgstr "Заголовок"
124 msgstr "Заголовок"
125
125
126 #: templates/boards/posting_general.html:139 templates/boards/thread.html:82
126 #: templates/boards/posting_general.html:140 templates/boards/thread.html:85
127 msgid "Text"
127 msgid "Text"
128 msgstr "Текст"
128 msgstr "Текст"
129
129
130 #: templates/boards/posting_general.html:144 templates/boards/thread.html:87
130 #: templates/boards/posting_general.html:145 templates/boards/thread.html:90
131 msgid "Image"
131 msgid "Image"
132 msgstr "Изображение"
132 msgstr "Изображение"
133
133
134 #: templates/boards/posting_general.html:162 templates/boards/thread.html:101
134 #: templates/boards/posting_general.html:163 templates/boards/thread.html:104
135 msgid "Post"
135 msgid "Post"
136 msgstr "Отправить"
136 msgstr "Отправить"
137
137
138 #: templates/boards/posting_general.html:164
138 #: templates/boards/posting_general.html:165
139 msgid "Tags must be delimited by spaces. Text or image is required."
139 msgid "Tags must be delimited by spaces. Text or image is required."
140 msgstr ""
140 msgstr ""
141 "Теги должны быть разделены пробелами. Текст или изображение обязательны."
141 "Теги должны быть разделены пробелами. Текст или изображение обязательны."
142
142
143 #: templates/boards/posting_general.html:167 templates/boards/thread.html:103
143 #: templates/boards/posting_general.html:168 templates/boards/thread.html:106
144 msgid "Text syntax"
144 msgid "Text syntax"
145 msgstr "Синтаксис текста"
145 msgstr "Синтаксис текста"
146
146
147 #: templates/boards/posting_general.html:177
147 #: templates/boards/posting_general.html:178
148 msgid "Pages:"
148 msgid "Pages:"
149 msgstr "Страницы: "
149 msgstr "Страницы: "
150
150
@@ -160,11 +160,19 b' msgstr "\xd0\x92\xd1\x8b \xd0\xbc\xd0\xbe\xd0\xb4\xd0\xb5\xd1\x80\xd0\xb0\xd1\x82\xd0\xbe\xd1\x80."'
160 msgid "Posts:"
160 msgid "Posts:"
161 msgstr "Сообщений:"
161 msgstr "Сообщений:"
162
162
163 #: templates/boards/settings.html:23
163 #: templates/boards/settings.html:19
164 msgid "First access:"
165 msgstr "Первый доступ:"
166
167 #: templates/boards/settings.html:21
168 msgid "Last access:"
169 msgstr "Последний доступ: "
170
171 #: templates/boards/settings.html:27
164 msgid "Theme"
172 msgid "Theme"
165 msgstr "Тема"
173 msgstr "Тема"
166
174
167 #: templates/boards/settings.html:39
175 #: templates/boards/settings.html:43
168 msgid "Save"
176 msgid "Save"
169 msgstr "Сохранить"
177 msgstr "Сохранить"
170
178
@@ -176,11 +184,11 b' msgstr "\xd1\x82\xd0\xb5\xd0\xbc"'
176 msgid "No tags found."
184 msgid "No tags found."
177 msgstr "Теги не найдены."
185 msgstr "Теги не найдены."
178
186
179 #: templates/boards/thread.html:74
187 #: templates/boards/thread.html:77
180 msgid "Reply to thread"
188 msgid "Reply to thread"
181 msgstr "Ответить в тему"
189 msgstr "Ответить в тему"
182
190
183 #: templates/boards/thread.html:114
191 #: templates/boards/thread.html:118
184 msgid "Last update: "
192 msgid "Last update: "
185 msgstr "Последнее обновление: "
193 msgstr "Последнее обновление: "
186
194
@@ -279,7 +279,6 b' class User(models.Model):'
279 rank = models.IntegerField()
279 rank = models.IntegerField()
280
280
281 registration_time = models.DateTimeField()
281 registration_time = models.DateTimeField()
282 last_access_time = models.DateTimeField()
283
282
284 fav_tags = models.ManyToManyField(Tag, null=True, blank=True)
283 fav_tags = models.ManyToManyField(Tag, null=True, blank=True)
285 fav_threads = models.ManyToManyField(Post, related_name='+', null=True,
284 fav_threads = models.ManyToManyField(Post, related_name='+', null=True,
@@ -316,6 +315,11 b' class User(models.Model):'
316 def __unicode__(self):
315 def __unicode__(self):
317 return self.user_id + '(' + str(self.rank) + ')'
316 return self.user_id + '(' + str(self.rank) + ')'
318
317
318 def get_last_access_time(self):
319 posts = Post.objects.filter(user=self)
320 if posts.count() > 0:
321 return posts.latest('pub_time').pub_time
322
319
323
320 class Setting(models.Model):
324 class Setting(models.Model):
321
325
@@ -16,6 +16,10 b''
16 {% endif %}
16 {% endif %}
17 </p>
17 </p>
18 <p>{% trans 'Posts:' %} {{ user.get_post_count }}</p>
18 <p>{% trans 'Posts:' %} {{ user.get_post_count }}</p>
19 <p>{% trans 'First access:' %} {{ user.registration_time }}</p>
20 {% if user.get_last_access_time %}
21 <p>{% trans 'Last access:' %} {{ user.get_last_access_time }}</p>
22 {% endif %}
19 </div>
23 </div>
20
24
21 <div class="post-form-w">
25 <div class="post-form-w">
@@ -343,10 +343,6 b' def _get_user(request):'
343 else:
343 else:
344 user = User.objects.get(id=session['user_id'])
344 user = User.objects.get(id=session['user_id'])
345
345
346 # TODO We need to determine if we need this and increas the performance
347 #user.last_access_time = timezone.now()
348 #user.save()
349
350 return user
346 return user
351
347
352
348
General Comments 0
You need to be logged in to leave comments. Login now