diff --git a/article/__pycache__/models.cpython-36.pyc b/article/__pycache__/models.cpython-36.pyc index f95925a..dd15828 100644 Binary files a/article/__pycache__/models.cpython-36.pyc and b/article/__pycache__/models.cpython-36.pyc differ 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 fd7f9f8..6ad43d3 100644 Binary files a/db.sqlite3 and b/db.sqlite3 differ diff --git a/edconline/__pycache__/globalarg.cpython-36.pyc b/edconline/__pycache__/globalarg.cpython-36.pyc index 1d421a5..1ff3bfa 100644 Binary files a/edconline/__pycache__/globalarg.cpython-36.pyc and b/edconline/__pycache__/globalarg.cpython-36.pyc differ diff --git a/edconline/globalarg.py b/edconline/globalarg.py index 0e29ccf..6a28e6c 100644 --- a/edconline/globalarg.py +++ b/edconline/globalarg.py @@ -3,8 +3,11 @@ def settings(request): - if request.user.is_authenticated : - userid = request.user.id - user =Profile.objects.get(user=userid) secs = Section.objects.all() - return {'secs':secs,'user':user} \ No newline at end of file + if request.user.is_authenticated: + userid = request.user.id + user =Profile.objects.get(user=userid) + + return {'secs':secs,'user':user} + else: + return {'secs':secs} \ No newline at end of file diff --git a/static/bootstrap/css/style.css b/static/bootstrap/css/style.css index b75578c..fa337c3 100755 --- a/static/bootstrap/css/style.css +++ b/static/bootstrap/css/style.css @@ -5,6 +5,12 @@ html,body { height: 100%; } +a,a:hover { + text-decoration:none; + color:#5555aa; + +} + img{ width: auto; height: auto; @@ -89,12 +95,10 @@ div.container-fluid { .card .preview div { display: block; - padding:0 20px 0 20px; + padding:0 20px 10px 20px; } -.card a { - color:#d73a49; -} + .card p { padding:0 10px 0 10px; @@ -185,7 +189,10 @@ span.floor { padding-right:20px; } - +.btn-sidebar { + display:block; + margin:auto; +} diff --git a/templates/base.html b/templates/base.html index bf3ac1d..0d94e31 100644 --- a/templates/base.html +++ b/templates/base.html @@ -30,11 +30,7 @@ @@ -71,33 +67,44 @@

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

{% block sidebar %}
+ {% ifnotequal user.id None %}
+

-   +   {{user.user}} - +

金币 {{user.point}}     {% ifnotequal user.msg 0 %} -   +   {% else %} -   +   {% endifnotequal %} {{user.msg}}    

-
+
- + {% else %} + + + + {% endifnotequal %}
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 1dcea9e..c0a37bb 100644 Binary files a/userpage/__pycache__/urls.cpython-36.pyc and b/userpage/__pycache__/urls.cpython-36.pyc differ diff --git a/userpage/__pycache__/views.cpython-36.pyc b/userpage/__pycache__/views.cpython-36.pyc index d821e8f..2b42b88 100644 Binary files a/userpage/__pycache__/views.cpython-36.pyc and b/userpage/__pycache__/views.cpython-36.pyc differ 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)