# HG changeset patch # User neko259 # Date 2013-09-16 17:21:26 # Node ID 4ac7d8f06002c30d52f4da8cd4672a8b70bb0186 # Parent 005f6ba5a178d8fbea1c33414f894de008f54181 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). diff --git a/boards/locale/ru/LC_MESSAGES/django.mo b/boards/locale/ru/LC_MESSAGES/django.mo index 2173b90d43d3beac081380af7c55970ed18baa07..7274cba57a7880d4a88ca675fd307822e5c235cd GIT binary patch literal 3761 zc$|GzU2Ggz6}~|1#_ONZmXJc5_J)$QA)e0f;0Gd%=kdTU0@mj${pLl`q+;bf} ziN(Y_-~Bn~o^!tQ&CRFx?fQ+t^Avs$;rGWc32_Qo{)*7g#a%+|2fhq!2L2v+5AZ6m z5m-0)39t$HXS073crWnpX8&{GUf>r%{E0+^5Us#HK>UgQczpx-XamRT1hxS4#_lw* z4Olexftim3AEP`QIR1PC$6IUQI3EKOz(1Mw*!cg=;HP-)0shn2ePR6m3)~Id)yVa< zHnRWTMvnVXBl{m|WcxI*1NgL=2aR0Ed1Lo;-~+&4nE5-vF9ZKz&i}xyF9PqQ{DB$Z zUrgNH_psd_gZm6Vg4Z&7_82gS`9F4ZJqMeZzo(kGe-^Di0 z=Z!Y*-}^wcNzi9S`qx_DsH0zHGu950GV%81`z60nX9X>3$A5RGG1AWVB!8OtMNZPiHJ?Zeff^|fX zG?+5@sKNUUQeWsU_^O$cUPZesJFb!=zOr8kQ+(N_06v=sP2|P!(m(Eh-=T zN^~on((U*`DDBZv6$BZPuh=Ce@@}B~P>y>wU)C^`PEpz;-Z|`qcG(%_s6F;JM?I-k zi-@0*qQ`MxkfDcys$Kv~ujII*&y%5DqDqlMQct-)sm>$6q%`RxHF-v7<+_T=C z1IP`b2Ixq7Nk?Z(LoENW=AqI-RV|P6n-VZIVD1G@==tMf$VM4MDhwUB6o{d!=aiK% zhQ{5{J}(M(NmgtZr)oYiMKO2>`Xwth1RYVbsLD>oAu>nCWl*(2K~fgLi9{21Qql>e zuU@P{?q+Klf=z|=y10<+iIifWJPCW!14K=BDvEsO-1o9O+&p@D^3hfp?D0491 z)ZBpYomHcul`mSSl^-~sn~?+AXMd1Am6NA)gG2fLz68ac^=EqX zM}E}bmrIbitb%X5L77s|$nN2u9@&@e&B=~jZ#LiaOt!0QFgG-G0;X=MhQh3ZvMU+c zlkGb-OeuHt^gL5`lAd4MvdKulmgvp*=C&$KCsPTc4BfX1<5ifD)Ssx9ZO1(>N5^bG zP+{kAq1!sPWk-pfQNERPN4+9sm669roG>v^uK9M^>h}CfkdbaxPlL{*$0ZLtA9oL? zQ=Oe@dFYU&Vd_9mnXq@ngmb)-}BrI*+RHmSq#NyDf8@bLt0 zm1rYciYKC_XdzmU7NdC?PsUSNSdZ4C6-+Q#ruF!hcuGb$FkOgeqg5HrM;~ElKAuU6 z=-04YlJOLdxgO7o=$9~>iq_)^n*3Iq*7-zz@&eqZ;yJpVcHWI{i0Ca0>+y7SO)uZj zL3M;R%1}hFWB)q-En#m82TnvQ(W;0p-%6Mwn1rX}S2nYo7STJjjgTv3BBHlpI~i?I zY*Rbp$Cp6M6y}$RAuuDNH#S32Zp4`(V$t|bM;jRty^84T(MS4}Yvh5nmNY};3ZFSj zgoq`=SMj}afOnLFYJ}cP2n~Jw60~EA`TqxchNy$4cmXH7? z$?WK5ohDgchTANb)*uC}&a(ulqL;Tx+<-InS-73l8Ip^j{}} zF4A?0T8P@HE{TGjZZIwQ1yFQNON6pV7bf)y#I>%`)N3S!3r*}uH\n" "Language-Team: LANGUAGE \n" @@ -75,76 +75,76 @@ msgstr "ID пользователя" msgid "Insert your user id above" msgstr "Вставьте свой ID пользователя выше" -#: templates/boards/posting_general.html:18 +#: templates/boards/posting_general.html:19 msgid "Tag: " msgstr "Тег: " -#: templates/boards/posting_general.html:43 -#: templates/boards/posting_general.html:99 templates/boards/thread.html:27 +#: templates/boards/posting_general.html:44 +#: templates/boards/posting_general.html:100 templates/boards/thread.html:29 #: templates/boards/rss/post.html:5 msgid "Post image" msgstr "Изображение сообщения" -#: templates/boards/posting_general.html:56 +#: templates/boards/posting_general.html:57 msgid "Reply" msgstr "Ответ" -#: templates/boards/posting_general.html:61 templates/boards/thread.html:45 +#: templates/boards/posting_general.html:62 templates/boards/thread.html:47 msgid "Delete" msgstr "Удалить" -#: templates/boards/posting_general.html:64 templates/boards/thread.html:48 +#: templates/boards/posting_general.html:65 templates/boards/thread.html:50 msgid "Ban IP" msgstr "Заблокировать IP" -#: templates/boards/posting_general.html:73 templates/boards/thread.html:112 +#: templates/boards/posting_general.html:74 templates/boards/thread.html:116 msgid "replies" msgstr "ответов" -#: templates/boards/posting_general.html:74 templates/boards/thread.html:113 +#: templates/boards/posting_general.html:75 templates/boards/thread.html:117 msgid "images" msgstr "изображений" -#: templates/boards/posting_general.html:76 -#: templates/boards/posting_general.html:149 templates/boards/tags.html:7 -#: templates/boards/thread.html:58 templates/boards/rss/post.html:10 +#: templates/boards/posting_general.html:77 +#: templates/boards/posting_general.html:150 templates/boards/tags.html:7 +#: templates/boards/thread.html:60 templates/boards/rss/post.html:10 msgid "Tags" msgstr "Теги" -#: templates/boards/posting_general.html:125 +#: templates/boards/posting_general.html:126 msgid "No threads exist. Create the first one!" msgstr "Нет тем. Создайте первую!" -#: templates/boards/posting_general.html:131 +#: templates/boards/posting_general.html:132 msgid "Create new thread" msgstr "Создать новую тему" -#: templates/boards/posting_general.html:134 templates/boards/thread.html:77 +#: templates/boards/posting_general.html:135 templates/boards/thread.html:80 msgid "Title" msgstr "Заголовок" -#: templates/boards/posting_general.html:139 templates/boards/thread.html:82 +#: templates/boards/posting_general.html:140 templates/boards/thread.html:85 msgid "Text" msgstr "Текст" -#: templates/boards/posting_general.html:144 templates/boards/thread.html:87 +#: templates/boards/posting_general.html:145 templates/boards/thread.html:90 msgid "Image" msgstr "Изображение" -#: templates/boards/posting_general.html:162 templates/boards/thread.html:101 +#: templates/boards/posting_general.html:163 templates/boards/thread.html:104 msgid "Post" msgstr "Отправить" -#: templates/boards/posting_general.html:164 +#: templates/boards/posting_general.html:165 msgid "Tags must be delimited by spaces. Text or image is required." msgstr "" "Теги должны быть разделены пробелами. Текст или изображение обязательны." -#: templates/boards/posting_general.html:167 templates/boards/thread.html:103 +#: templates/boards/posting_general.html:168 templates/boards/thread.html:106 msgid "Text syntax" msgstr "Синтаксис текста" -#: templates/boards/posting_general.html:177 +#: templates/boards/posting_general.html:178 msgid "Pages:" msgstr "Страницы: " @@ -160,11 +160,19 @@ msgstr "Вы модератор." msgid "Posts:" msgstr "Сообщений:" -#: templates/boards/settings.html:23 +#: templates/boards/settings.html:19 +msgid "First access:" +msgstr "Первый доступ:" + +#: templates/boards/settings.html:21 +msgid "Last access:" +msgstr "Последний доступ: " + +#: templates/boards/settings.html:27 msgid "Theme" msgstr "Тема" -#: templates/boards/settings.html:39 +#: templates/boards/settings.html:43 msgid "Save" msgstr "Сохранить" @@ -176,11 +184,11 @@ msgstr "тем" msgid "No tags found." msgstr "Теги не найдены." -#: templates/boards/thread.html:74 +#: templates/boards/thread.html:77 msgid "Reply to thread" msgstr "Ответить в тему" -#: templates/boards/thread.html:114 +#: templates/boards/thread.html:118 msgid "Last update: " msgstr "Последнее обновление: " diff --git a/boards/models.py b/boards/models.py --- a/boards/models.py +++ b/boards/models.py @@ -279,7 +279,6 @@ class User(models.Model): rank = models.IntegerField() registration_time = models.DateTimeField() - last_access_time = models.DateTimeField() fav_tags = models.ManyToManyField(Tag, null=True, blank=True) fav_threads = models.ManyToManyField(Post, related_name='+', null=True, @@ -316,6 +315,11 @@ class User(models.Model): def __unicode__(self): return self.user_id + '(' + str(self.rank) + ')' + def get_last_access_time(self): + posts = Post.objects.filter(user=self) + if posts.count() > 0: + return posts.latest('pub_time').pub_time + class Setting(models.Model): diff --git a/boards/profiler.py b/boards/profiler.py new file mode 100644 --- /dev/null +++ b/boards/profiler.py @@ -0,0 +1,23 @@ +import sys +import cProfile +from cStringIO import StringIO +from django.conf import settings +import line_profiler + +class ProfilerMiddleware(object): + def process_view(self, request, callback, callback_args, callback_kwargs): + if settings.DEBUG and 'prof' in request.GET: + self.profiler = line_profiler.LineProfiler() + self.profiler.add_function(callback) + self.profiler.enable() + args = (request,) + callback_args + return callback(*args, **callback_kwargs) + + def process_response(self, request, response): + if settings.DEBUG and 'prof' in request.GET: + out = StringIO() + old_stdout, sys.stdout = sys.stdout, out + self.profiler.print_stats() + sys.stdout = old_stdout + response.content = '
%s
' % out.getvalue() + return response diff --git a/boards/templates/boards/settings.html b/boards/templates/boards/settings.html --- a/boards/templates/boards/settings.html +++ b/boards/templates/boards/settings.html @@ -16,6 +16,10 @@ {% endif %}

{% trans 'Posts:' %} {{ user.get_post_count }}

+

{% trans 'First access:' %} {{ user.registration_time }}

+ {% if user.get_last_access_time %} +

{% trans 'Last access:' %} {{ user.get_last_access_time }}

+ {% endif %}
diff --git a/boards/views.py b/boards/views.py --- a/boards/views.py +++ b/boards/views.py @@ -343,10 +343,6 @@ def _get_user(request): else: user = User.objects.get(id=session['user_id']) - # TODO We need to determine if we need this and increas the performance - #user.last_access_time = timezone.now() - #user.save() - return user