##// 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
@@ -7,7 +7,7 b' msgid ""'
7 7 msgstr ""
8 8 "Project-Id-Version: PACKAGE VERSION\n"
9 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 11 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
12 12 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
13 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 75 msgid "Insert your user id above"
76 76 msgstr "Вставьте свой ID пользователя выше"
77 77
78 #: templates/boards/posting_general.html:18
78 #: templates/boards/posting_general.html:19
79 79 msgid "Tag: "
80 80 msgstr "Тег: "
81 81
82 #: templates/boards/posting_general.html:43
83 #: templates/boards/posting_general.html:99 templates/boards/thread.html:27
82 #: templates/boards/posting_general.html:44
83 #: templates/boards/posting_general.html:100 templates/boards/thread.html:29
84 84 #: templates/boards/rss/post.html:5
85 85 msgid "Post image"
86 86 msgstr "Изображение сообщения"
87 87
88 #: templates/boards/posting_general.html:56
88 #: templates/boards/posting_general.html:57
89 89 msgid "Reply"
90 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 93 msgid "Delete"
94 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 97 msgid "Ban IP"
98 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 101 msgid "replies"
102 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 105 msgid "images"
106 106 msgstr "изображений"
107 107
108 #: templates/boards/posting_general.html:76
109 #: templates/boards/posting_general.html:149 templates/boards/tags.html:7
110 #: templates/boards/thread.html:58 templates/boards/rss/post.html:10
108 #: templates/boards/posting_general.html:77
109 #: templates/boards/posting_general.html:150 templates/boards/tags.html:7
110 #: templates/boards/thread.html:60 templates/boards/rss/post.html:10
111 111 msgid "Tags"
112 112 msgstr "Теги"
113 113
114 #: templates/boards/posting_general.html:125
114 #: templates/boards/posting_general.html:126
115 115 msgid "No threads exist. Create the first one!"
116 116 msgstr "Нет тем. Создайте первую!"
117 117
118 #: templates/boards/posting_general.html:131
118 #: templates/boards/posting_general.html:132
119 119 msgid "Create new thread"
120 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 123 msgid "Title"
124 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 127 msgid "Text"
128 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 131 msgid "Image"
132 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 135 msgid "Post"
136 136 msgstr "Отправить"
137 137
138 #: templates/boards/posting_general.html:164
138 #: templates/boards/posting_general.html:165
139 139 msgid "Tags must be delimited by spaces. Text or image is required."
140 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 144 msgid "Text syntax"
145 145 msgstr "Синтаксис текста"
146 146
147 #: templates/boards/posting_general.html:177
147 #: templates/boards/posting_general.html:178
148 148 msgid "Pages:"
149 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 160 msgid "Posts:"
161 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 172 msgid "Theme"
165 173 msgstr "Тема"
166 174
167 #: templates/boards/settings.html:39
175 #: templates/boards/settings.html:43
168 176 msgid "Save"
169 177 msgstr "Сохранить"
170 178
@@ -176,11 +184,11 b' msgstr "\xd1\x82\xd0\xb5\xd0\xbc"'
176 184 msgid "No tags found."
177 185 msgstr "Теги не найдены."
178 186
179 #: templates/boards/thread.html:74
187 #: templates/boards/thread.html:77
180 188 msgid "Reply to thread"
181 189 msgstr "Ответить в тему"
182 190
183 #: templates/boards/thread.html:114
191 #: templates/boards/thread.html:118
184 192 msgid "Last update: "
185 193 msgstr "Последнее обновление: "
186 194
@@ -279,7 +279,6 b' class User(models.Model):'
279 279 rank = models.IntegerField()
280 280
281 281 registration_time = models.DateTimeField()
282 last_access_time = models.DateTimeField()
283 282
284 283 fav_tags = models.ManyToManyField(Tag, null=True, blank=True)
285 284 fav_threads = models.ManyToManyField(Post, related_name='+', null=True,
@@ -316,6 +315,11 b' class User(models.Model):'
316 315 def __unicode__(self):
317 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 324 class Setting(models.Model):
321 325
@@ -16,6 +16,10 b''
16 16 {% endif %}
17 17 </p>
18 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 23 </div>
20 24
21 25 <div class="post-form-w">
@@ -343,10 +343,6 b' def _get_user(request):'
343 343 else:
344 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 346 return user
351 347
352 348
General Comments 0
You need to be logged in to leave comments. Login now