From 257fda1ec9e6a46272b4f571bfa3c62538ee5c54 Mon Sep 17 00:00:00 2001 From: gothack329 Date: Wed, 28 Feb 2018 23:58:10 +0800 Subject: [PATCH] update member page --- article/__pycache__/models.cpython-36.pyc | Bin 4188 -> 4188 bytes article/models.py | 1 + article/templates/article/detail.html | 4 +- db.sqlite3 | Bin 282624 -> 282624 bytes .../__pycache__/globalarg.cpython-36.pyc | Bin 452 -> 471 bytes edconline/globalarg.py | 11 +- static/bootstrap/css/style.css | 17 ++- templates/base.html | 29 +++-- templates/index.html | 10 +- userpage/__pycache__/urls.cpython-36.pyc | Bin 366 -> 373 bytes userpage/__pycache__/views.cpython-36.pyc | Bin 1332 -> 1564 bytes userpage/templates/userpage/profile.html | 100 +++++++++++++----- userpage/templates/userpage/update.html | 36 +++++++ userpage/urls.py | 2 +- userpage/views.py | 11 +- 15 files changed, 164 insertions(+), 57 deletions(-) create mode 100644 userpage/templates/userpage/update.html diff --git a/article/__pycache__/models.cpython-36.pyc b/article/__pycache__/models.cpython-36.pyc index f95925a06b59370f11398dd53de25272cdb561c4..dd1582895cfb95223eb5f4c5d73f473d4af7e02d 100644 GIT binary patch delta 97 zcmV-n0G|KcAlx7dGYt(2Da)2xDi5&=4g~=$lNklA0WY)11!4gO2M7al7?TeUJF{sA zP6Ginleh|30W-4@3wZ$nRFjGfqyblxFAcu|Nwe<_NC5#{lQ<7U0b7%N58DMB5Ec>= D_G}r# delta 97 zcmV-n0G|KcAlx7dGYt(2YIT-c_71TM4g~=#lNklA0WP!01!4gO1_%Rk7?TeUJF{sA zP6Gimleh|30Wz}?3wZ$nQ= DFpC;( diff --git a/article/models.py b/article/models.py index c70247b..ed98dbb 100644 --- a/article/models.py +++ b/article/models.py @@ -35,6 +35,7 @@ class Article(models.Model): tag = models.CharField(max_length=128, blank=True, null=True) visible = models.CharField(choices=(('Y','是'),('N','否')),max_length=64,default='N') readtime = models.IntegerField(default=0) + #comment_count = models.IntegerField(default=0) #def set_tags(self, tags): # Tag.objects.update_tags(self, tags) diff --git a/article/templates/article/detail.html b/article/templates/article/detail.html index 64b5055..74e50f3 100644 --- a/article/templates/article/detail.html +++ b/article/templates/article/detail.html @@ -35,7 +35,7 @@

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

{% block content %}
- 作者: {{art.author}} + 作者: {{art.author}}           阅读数:{{art.readtime}}           @@ -58,7 +58,7 @@

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

{% for i in comments %}
- {{i.user}} + {{i.user}}
diff --git a/db.sqlite3 b/db.sqlite3 index fd7f9f884a877d3a83066b4300bd7fdad33adce3..6ad43d39f690ca733162624429e096e58c294ccf 100644 GIT binary patch delta 141 zcmZozAlR@#aDp^r#Y7or#)`&-)&$1Z1g5PC%nR1@GcYhX^)|g|+3|Gp+V^`pw@8sKm0LciRDGQ9efb?PBMc_cAi-ZNGA!S>8cP$dB33$Xw3=2o0Hlx?Qc6?4C`X f`K+%4s@L9#?s@A-KJk#zt7i|H&v delta 204 zcmZozAlR@#aDp^r;Y1l{#=^#g)&$1Z1g5PC%nQ~}D`4c{;s4G5mH$2eO9lo8v&|P@ zh_Gya`{D;PjJU`w&dSWl$jS;LSy(_MGcyY_CnM9g1I(g)jMCf1&N1(0WYpb$z zgP?#Pv!Ri>o&gXVG69Wr-TdMCS5za#nYSshuqbR6cy^TyW)0XvNk+MdU@uD}149d4 Z17lr769ofvD?>9Y69YXXGXq02BLHc=MzH_@ diff --git a/edconline/__pycache__/globalarg.cpython-36.pyc b/edconline/__pycache__/globalarg.cpython-36.pyc index 1d421a559e4d6a7a44f858dd50da556d0b8b144c..1ff3bfa1ede9706de79f36fbeebf31d91cdfdf73 100644 GIT binary patch delta 204 zcmW-Zy$ZrW5QKMcPxFI{Phfwow&EjbkxH%99FkKE-d(x`3u}uIu<|kNY%T4Ddm7KM zFf%Z--b!T0W;G8 delta 178 zcmcc4e1w_Pn3tE!t!i2n??le%03!wlh8l(}hAhS+0Wi%}%UHsk#gfHZ!
diff --git a/templates/index.html b/templates/index.html index 0a93a07..f6f2f7d 100644 --- a/templates/index.html +++ b/templates/index.html @@ -18,12 +18,16 @@

{% if title %}{{title}}{% endif %}

-

{{i.title}}

-

{{i.detail|striptags|truncatechars:140|safe}}

+

{{i.title}}

+

{{i.detail|striptags|truncatechars:500|safe}}

 {{i.publish_time}}     -  {{i.author}} +  {{i.author}} +     +  {{i.section}} +     +  {{i.tag}} 阅读全文 diff --git a/userpage/__pycache__/urls.cpython-36.pyc b/userpage/__pycache__/urls.cpython-36.pyc index 1dcea9ed27465c5fa521690f87c2ecdedbe23231..c0a37bb717a4ae564b2aa01300d0bb2dc6dd119e 100644 GIT binary patch delta 52 zcmaFI^p%Ozn3tE!xl IOk8^q0Q43VGynhq delta 45 zcmey$^p1(sn3tDpsrJOErxQ7QB=~GH^Gd8ri&Kl@GgIvJZ*gSg=cX1Urcc~*5CCa4 B5f%Ud diff --git a/userpage/__pycache__/views.cpython-36.pyc b/userpage/__pycache__/views.cpython-36.pyc index d821e8f9d2059c9ba6962b7ea34c9118872cf88f..2b42b88531f77ca9154df8c6c0716a612d42ac92 100644 GIT binary patch delta 599 zcmYjNO-tNR6n$TlWX4R?Qa?aj9mPU6E|h|cQY=DOMFi_6n<377Z8J*JUr0yUP8qtVhQ0V>MV`p@23zP5!!OqPN^tON;dYGwy^1XxS&fjtH!okJ^ zY$CH!c_CAy`m;T5xn4&gqFxkh{w}iPc(vXa(|!`+Z*lkB%?qhUx>;ep)D(F(09W~F hc(Y~`b2fN|<>g4drl_=A5Yh#@juGM;xDY{`(L3E6lzspJ delta 406 zcmYjK!AiqG5Zy`AHl~|UZ5wInAyB2{BBFQ`5d?1*K|B}_C788F8@Fx}5Ybcn1GQIA z-aOlzeu(VVA91#dbeH#-nfGSi3!Pc*ZQHgwo0H(RK*%>)cm~${i1c~VzHeAjc}#*D zb6DlN9?{4ilM##{a3`N%=Nj5{#DTI?q>M!H2rgPqh_7`YnrA%k2<8nqzlm@AUYL1# z%7nL`ZulV7s;|kCV0Sr7Gg(qvFOJ@bs7^n$9oM|#2^)rerf#Pyjew}X+xjVZE;iCo z8?t;X_+>m`hg>AGH2iI*PsUcTj3&`g)Kpacry5q$$%j#xvEJWC1!rjsiRczoU5@A|9LrNZn;)UlDpFyl#lF;^BM=3(<3b2s5pK45!*_Ee21-fkhN Lx(?JZ4Gn$(4^LCn diff --git a/userpage/templates/userpage/profile.html b/userpage/templates/userpage/profile.html index 301c43c..83aee1c 100644 --- a/userpage/templates/userpage/profile.html +++ b/userpage/templates/userpage/profile.html @@ -4,38 +4,80 @@ [ {{request.user}} ]用户详情 - 物志 {% endblock %} - +{% block banner %} +
+

+
+{% endblock %} {% block content%} +
+
+ +
+
+
+

+   + {{member.username}} + +

+

+ 金币 + {{member.profile.point}} +     + {% ifequal member.id user.id %} + {% ifnotequal user.msg 0 %} +   + {% else %} +   + {% endifnotequal %} + {{user.msg}} +     + {% endifequal %} +

+

本站第 {{member.id}} 位会员,于 {{member.date_joined}} 注册,最近一次登录于 {{member.last_login}}. +

+
+
- {% if user_form.errors %} - {% for field in user_form %} - {% for error in field.errors %} - - {% endfor %} - {% endfor %} - {% endif %} +
+ + {% for i in arts %} +
+
+

{{i.title}}

+

{{i.detail|striptags|truncatechars:500|safe}}

+

+  {{i.publish_time}} +     +  {{i.author}} +     +  {{i.section}} +     +  {{i.tag}} + + 查看全文 + +
+
+ + {% endfor %} + + {% for i in comments %} +
+

于 {{i.comment_time}} 评论了 {{i.article.author_id}} 的文章【 {{i.article}} 】 +

{{i.comment|safe|escape}}

+
+ + {% endfor %} -
-
- {% csrf_token %} - {{ user_form.as_p }} - {{ profile_form.as_p }} - -
+ {% endblock %} diff --git a/userpage/templates/userpage/update.html b/userpage/templates/userpage/update.html new file mode 100644 index 0000000..28e6ac5 --- /dev/null +++ b/userpage/templates/userpage/update.html @@ -0,0 +1,36 @@ + +{% block content%} + + {% if user_form.errors %} + {% for field in user_form %} + {% for error in field.errors %} + + {% endfor %} + {% endfor %} + {% endif %} + +
+

+
+ {% csrf_token %} + {{ user_form.as_p }} + {{ profile_form.as_p }} + +
+
+ +{% endblock %} \ No newline at end of file diff --git a/userpage/urls.py b/userpage/urls.py index 260a34a..cc958a6 100644 --- a/userpage/urls.py +++ b/userpage/urls.py @@ -3,6 +3,6 @@ from . import views urlpatterns = [ - path('/', views.homepage, name='homepage'), + path('member//', views.profile, name='profile'), path('update/', views.update_profile, name='update_profile'), ] diff --git a/userpage/views.py b/userpage/views.py index 317906b..7f07fb1 100644 --- a/userpage/views.py +++ b/userpage/views.py @@ -6,16 +6,23 @@ from django.db import transaction from .models import * from django.contrib import messages +from article.models import * # Create your views here. -def homepage(request, user_id): - return HttpResponse("You're looking at user %s." % user_id) +def profile(request, username): + inst_user = User.objects.get(username=username) + inst_profile = Profile.objects.get(user=inst_user) + + arts = Article.objects.filter(author_id=inst_profile) + comments = Comment.objects.filter(user=inst_profile) + return render(request, 'userpage/profile.html', {'member':inst_user,'arts':arts,'comments':comments}) @login_required @transaction.atomic def update_profile(request): + if request.method == 'POST': user_form = UserForm(request.POST, instance=request.user) profile_form = ProfileForm(request.POST, instance=request.user.profile)