From 5edcf3ef9e31cace1ffb98f67704c92a45887738 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E8=BD=A6=E4=BA=AE=E4=BA=AE?=
Date: Sat, 24 Dec 2016 16:51:42 +0800
Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E9=94=9A=E9=93=BE=E6=8E=A5?=
=?UTF-8?q?=EF=BC=8C=E4=BF=AE=E5=A4=8D=E9=83=A8=E5=88=86=E7=95=8C=E9=9D=A2?=
=?UTF-8?q?=E8=B7=B3=E8=BD=AC=E9=94=99=E8=AF=AFbug=EF=BC=8C=E5=AE=8C?=
=?UTF-8?q?=E5=96=84=E7=99=BB=E5=BD=95=E6=B3=A8=E5=86=8C=E9=A1=B5=E9=9D=A2?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
accounts/urls.py | 1 +
accounts/views.py | 6 +++++-
blog/models.py | 4 ++++
blog/templatetags/blog_tags.py | 10 ++++++----
blog/views.py | 9 +++------
comments/forms.py | 6 +++++-
comments/views.py | 3 ++-
templates/account/login.html | 4 ++--
templates/account/registration_form.html | 2 +-
templates/accountbase.html | 2 +-
templates/blog/articledetail.html | 4 +++-
templates/blog/tags/article_info.html | 17 ++++++++++++-----
templates/blog/tags/article_meta_info.html | 8 ++++++--
templates/blog/tags/sidebar.html | 2 +-
templates/comments/tags/comment_item.html | 18 +++++++++++-------
templates/comments/tags/post_comment.html | 4 +++-
16 files changed, 66 insertions(+), 34 deletions(-)
diff --git a/accounts/urls.py b/accounts/urls.py
index e972a46..d753d24 100644
--- a/accounts/urls.py
+++ b/accounts/urls.py
@@ -22,4 +22,5 @@ from .forms import LoginForm
urlpatterns = [
url(r'^login/$', views.LoginView.as_view(success_url='/'), name='login', kwargs={'authentication_form': LoginForm}),
url(r'^register/$', views.RegisterView.as_view(success_url="/"), name='register'),
+ url(r'^logout/$', views.logout, name='logout')
]
diff --git a/accounts/views.py b/accounts/views.py
index f29e8cb..39ffb44 100644
--- a/accounts/views.py
+++ b/accounts/views.py
@@ -1,6 +1,6 @@
from django.shortcuts import render
-from django.contrib.auth.views import login
+from django.contrib.auth.views import login, logout
from .forms import RegisterForm, LoginForm
from django.contrib.auth import authenticate
from django.views.generic.edit import FormView
@@ -25,6 +25,10 @@ class RegisterView(FormView):
return HttpResponseRedirect('/')
+def LogOut(requests):
+ logout(request=requests)
+ return HttpResponseRedirect("/")
+
class LoginView(FormView):
form_class = LoginForm
diff --git a/blog/models.py b/blog/models.py
index 2319f3e..17b408f 100644
--- a/blog/models.py
+++ b/blog/models.py
@@ -83,6 +83,10 @@ class Article(models.Model):
comments = self.comment_set.all()
parent_comments = comments.filter(parent_comment=None)
+ def get_admin_url(self):
+ info = (self._meta.app_label, self._meta.model_name)
+ return reverse('admin:%s_%s_change' % info, args=(self.pk,))
+
'''
class BlogPage(models.Model):
diff --git a/blog/templatetags/blog_tags.py b/blog/templatetags/blog_tags.py
index fc92e54..6d99fed 100644
--- a/blog/templatetags/blog_tags.py
+++ b/blog/templatetags/blog_tags.py
@@ -138,14 +138,15 @@ def load_sidebar(user):
@register.inclusion_tag('blog/tags/article_meta_info.html')
-def load_article_metas(article):
+def load_article_metas(article, user):
"""
获得文章meta信息
:param article:
:return:
"""
return {
- 'article': article
+ 'article': article,
+ 'user': user
}
@@ -160,7 +161,7 @@ def load_nav_info():
@register.inclusion_tag('blog/tags/article_info.html')
-def load_article_detail(article, isindex):
+def load_article_detail(article, isindex, user):
"""
加载文章详情
:param article:
@@ -169,7 +170,8 @@ def load_article_detail(article, isindex):
"""
return {
'article': article,
- 'isindex': isindex
+ 'isindex': isindex,
+ 'user': user
}
diff --git a/blog/views.py b/blog/views.py
index 192025a..8814989 100644
--- a/blog/views.py
+++ b/blog/views.py
@@ -17,7 +17,7 @@ from django import http
from django.http import HttpResponse
from abc import ABCMeta, abstractmethod
-
+"""
class SeoProcessor():
__metaclass__ = ABCMeta
@@ -32,6 +32,7 @@ class SeoProcessor():
@abstractmethod
def get_description(self):
pass
+"""
class ArticleListView(ListView):
@@ -47,11 +48,7 @@ class ArticleListView(ListView):
page_kwarg = 'page'
-class IndexView(ArticleListView, SeoProcessor):
- def get_title(self):
- return '逝去日子的博客'
- def get_keywords(self):
- pass
+class IndexView(ArticleListView):
def get_queryset(self):
article_list = Article.objects.filter(status='p')
diff --git a/comments/forms.py b/comments/forms.py
index 93bfcfb..1790954 100644
--- a/comments/forms.py
+++ b/comments/forms.py
@@ -44,7 +44,10 @@ class LoginCommentForm(ModelForm):
class CommentForm(ModelForm):
url = forms.URLField(label='网址', required=False)
email = forms.EmailField(label='电子邮箱', required=False)
- name = forms.CharField(label='姓名')
+ name = forms.CharField(label='姓名', widget=forms.TextInput(attrs=
+ {'value': "", 'size': "30", 'maxlength': "245",
+ 'aria-required': 'true'}
+ ))
parent_comment_id = forms.IntegerField(widget=forms.HiddenInput, required=False)
"""
if get_user_model().is_authenticated:
@@ -61,6 +64,7 @@ class CommentForm(ModelForm):
'name': forms.CharField(widget=forms.HiddenInput()),
})
"""
+
class Meta:
model = Comment
fields = ['body']
diff --git a/comments/views.py b/comments/views.py
index 96d2965..1b624aa 100644
--- a/comments/views.py
+++ b/comments/views.py
@@ -52,4 +52,5 @@ class CommentPostView(FormView):
comment.save(True)
- return HttpResponseRedirect(article.get_absolute_url())
+ # return HttpResponseRedirect(article.get_absolute_url() + "#div-comment-" + comment.pk)
+ return HttpResponseRedirect("%s#div-comment-%d" % (article.get_absolute_url(), comment.pk))
diff --git a/templates/account/login.html b/templates/account/login.html
index a3e04a3..91335f6 100644
--- a/templates/account/login.html
+++ b/templates/account/login.html
@@ -15,7 +15,7 @@
{% endcomment %}
{{ form.non_field_errors }}
{% for field in form %}
- {{ field }}
+ {{ field }}
{{ field.errors }}
{% endfor %}
@@ -33,7 +33,7 @@
- Create an account
+ Create an account
diff --git a/templates/account/registration_form.html b/templates/account/registration_form.html
index b02901a..f6f126a 100644
--- a/templates/account/registration_form.html
+++ b/templates/account/registration_form.html
@@ -34,7 +34,7 @@
- Create an account
+ LogIn
diff --git a/templates/accountbase.html b/templates/accountbase.html
index ba209fe..e1df7d6 100644
--- a/templates/accountbase.html
+++ b/templates/accountbase.html
@@ -10,7 +10,7 @@
- Signin Template for TODC Bootstrap
+ {{ SITE_NAME }} | {{ SITE_DESCRIPTION }}
diff --git a/templates/blog/articledetail.html b/templates/blog/articledetail.html
index 9f5af18..729ee0a 100755
--- a/templates/blog/articledetail.html
+++ b/templates/blog/articledetail.html
@@ -1,5 +1,6 @@
{% extends 'base.html' %}
{% load blog_tags %}
+
{% block header %}
{{ article.title }} | {{ SITE_DESCRIPTION }}
@@ -15,10 +16,11 @@
{% endfor %}
{% endblock %}
+
{% block content %}
- {% load_article_detail article False %}
+ {% load_article_detail article False user %}
+ class="avatar avatar-96 photo" height="96" width="96">
+
+ {{ comment_item.author.username }}
+
+
+
说道:
+
-
+
{{ comment_item.body }}
diff --git a/templates/comments/tags/post_comment.html b/templates/comments/tags/post_comment.html
index 3a599cf..f7434e9 100644
--- a/templates/comments/tags/post_comment.html
+++ b/templates/comments/tags/post_comment.html
@@ -11,6 +11,7 @@
{% endcomment %}