From cb9c42d36c1693893ca7d28ca22c83040581a03c Mon Sep 17 00:00:00 2001 From: gothack329 Date: Mon, 5 Mar 2018 11:25:12 +0800 Subject: [PATCH] update choicefiled display name --- article/__pycache__/views.cpython-36.pyc | Bin 2355 -> 2496 bytes article/templates/article/detail.html | 19 +++++++++++++++++++ article/views.py | 12 +++++++++--- db.sqlite3 | Bin 360448 -> 360448 bytes userpage/templates/userpage/profile.html | 2 +- 5 files changed, 29 insertions(+), 4 deletions(-) diff --git a/article/__pycache__/views.cpython-36.pyc b/article/__pycache__/views.cpython-36.pyc index c6e8e2b96c3bcd8a266b3a76d7eeaad04680120b..bb84aa1aad9f841405165646fb4e8a4ecbbf865d 100644 GIT binary patch delta 1092 zcmZvc%WD%+6vpqp^UUPYG)e7CZEAg`)>dt+eOR@W78HeI5upg7^iFH0kHkBZg>pmC z6sgd-aCTadf}n1!S`ZOI!GA(#<)&?Rx_0F~)6}|faep~EXU_e;a|UK3_BC#Fhr`Cr zkE@fN;djPK90?(Wba6(+vD@8Ie55#w3NlBQO657iemR#SFD;6Vn4)hlm@6Fp47!1wKUj>xSo!2 z-HMhFMpP>VoZ^lIvEo$;!$}B(;l?Q@|Myk1ew5Eh7kW+6pa3rJ} zOGJnt=EQ2ET0P<<-6Y~Djm~0PTNcI~%^wSkv6?xeF;2L|l@OO{d{r(<6DXB%uaMsU z6!zr2Z88SS${!QhdhlxN{o2;*qsoVk%@@zNpDt~`T;E)NSo!j-vbIuLU#h(M^z-w5 zw@4adUSK-AuwX7aCQV5!F1p=ya{ajMNmI=6^lH)eLe(felVuB@D&(@vPVIMFrE5p! z8z2w89?4Ko8)w;>%)IF-xol?9@zkkY&RnGKg4ApTrt;41EK6soyCx-zEGe2;Gk^%B zLY~IVJ9*P~SPdi(01g6@fEIztzlPbQ3UjA(EC$660iosJ?*;QYI^~$Yf!B!ji`wtb zF7Ro0*%_9}+g%eG$L*8bdpbo8X%U>jGBI!j$D{~0a0u(-2of2`NDL<=okU4U)D4LZ zx{u}WYC`m}I(J@a#&LI9nJmKYz2Go&GSl*rL^Ux5-f@mSBrw6KoFG(9!v-c=!Hu|m`1yVwwZ2k({O0w ztp}aNgL*d}jTaBbn0V1|VD<|rA3;yfvu*K0CiB~8p11iwvtM%`v+hDV?H-)G**o+; zxU<-I5ki*U5A<##wTUkuOB6D091`(8vb1e;#LX^g8`21!4icaA*X4{`UEDTxJjLw- zl4jYHX6SYhM%-z$C>`REND}(t5XU;x>U&U_>3i&GSm$J=B^h^ls!Q8W;@QtiTe1}5 zUf-GH=?>mSQ9c}zNMAnMAsE#z>E>hH8AFnk$F%Ko|0(7}U5rs=C6aO5h{h%28A&9S z1|NP)J9HNXSrw66a}NU?vxEB4Q8kKFJDXeEk2lNf8yh>q(=QP_5UJFn3J+*(w3-#6 zJi3FaD$_|46x4INrT)@$1>=bh#m;^!dR7wp`8IRFLtfD~XJa1)TsW{Cx`?*L#pF$q}Ih;d8YhQm@1X>BfpxvDX*3f44URcqF_ zf!rc19sm0L>i3ry0qONy(}_VwOhM6qjqn`eE?^jN4{+9KiSDx`n?1=xP?)Ga6+b@E psv{sZX1)LMNd2&jcwL>?FN-Ts1|x`dK!3P_wX9w{({#oz`~%(~w?_Z~ diff --git a/article/templates/article/detail.html b/article/templates/article/detail.html index 52c8a4d..ff1ce1e 100644 --- a/article/templates/article/detail.html +++ b/article/templates/article/detail.html @@ -118,6 +118,25 @@

{% if art %}{{art.title}}{% endif %}

{% endfor %} {% endif %} +{% if errors %} + {% for error in errors %} + + {% endfor %} +{% endif %}
{% csrf_token %} diff --git a/article/views.py b/article/views.py index f86f373..c16a223 100644 --- a/article/views.py +++ b/article/views.py @@ -17,18 +17,24 @@ def detail(request, article_id): art = Article.objects.get(pk=article_id) comments = Comment.objects.filter(article_id=article_id).order_by('comment_time') + errors = [] if request.method == 'POST': comment_form = CommentForm(request.POST,instance=None) + commenter = User.objects.get(pk=request.user.id) + - if comment_form.is_valid(): + user_p = Profile.objects.get(user=commenter) + if user_p.point < 1: + errors.append('您没有足够的积分进行评论!') + elif comment_form.is_valid(): instance = comment_form.save(commit=False) instance.ip = request.META['REMOTE_ADDR'] instance.save() point=1 author = User.objects.get(pk=art.author_id.id) - commenter = User.objects.get(pk=request.user.id) + updatepoint = Point.objects.create(user=author,point_record=point,event="commented") updatepoint = Point.objects.create(user=commenter,point_record=-point,event="comment") @@ -42,7 +48,7 @@ def detail(request, article_id): comment_form = CommentForm(instance=None) - return render(request,'article/detail.html',{'art':art,'comments':comments,'comment_form':comment_form}) + return render(request,'article/detail.html',{'art':art,'comments':comments,'comment_form':comment_form,'errors':errors}) #return HttpResponse("You're looking at article %s." % article_id) diff --git a/db.sqlite3 b/db.sqlite3 index d6d464ce8b5fd5e9364b3352e82a2c376c76a678..2a388d1ed9d040519239840b55304a583b84a2ec 100644 GIT binary patch delta 44 ycmZo@5Nl`jO<-zGU~Wxd*_yz*PnOYiySyCh!$bg3jt;Q^ diff --git a/userpage/templates/userpage/profile.html b/userpage/templates/userpage/profile.html index ad038c1..73f9f3c 100644 --- a/userpage/templates/userpage/profile.html +++ b/userpage/templates/userpage/profile.html @@ -145,7 +145,7 @@

{% for i in points %}
-

{{i.record_time|timetonow}},{{i.event}},{{i.point_record}}

+

{{i.record_time|timetonow}},{{i.get_event_display}},{{i.point_record}}

{% endfor %}