diff --git a/article/templates/article/detail.html b/article/templates/article/detail.html index 0d0002a..0791168 100644 --- a/article/templates/article/detail.html +++ b/article/templates/article/detail.html @@ -65,18 +65,19 @@

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

{% for i in comments %}
-
+
 {{i.comment_time|timetonow}}    - {% ifequal request.user.id i.user.id %} + {% ifequal art.author_id.id i.user.id %} 作者 {% endifequal %} # {{forloop.counter}} - Reply + Reply

diff --git a/db.sqlite3 b/db.sqlite3 index ed0d3e9..93f04a5 100644 Binary files a/db.sqlite3 and b/db.sqlite3 differ diff --git a/edconline/__pycache__/settings.cpython-36.pyc b/edconline/__pycache__/settings.cpython-36.pyc index abc3031..e10f79b 100644 Binary files a/edconline/__pycache__/settings.cpython-36.pyc and b/edconline/__pycache__/settings.cpython-36.pyc differ diff --git a/edconline/__pycache__/urls.cpython-36.pyc b/edconline/__pycache__/urls.cpython-36.pyc index a0736df..1c9570c 100644 Binary files a/edconline/__pycache__/urls.cpython-36.pyc and b/edconline/__pycache__/urls.cpython-36.pyc differ diff --git a/edconline/settings.py b/edconline/settings.py index f9884d7..10dc7ca 100644 --- a/edconline/settings.py +++ b/edconline/settings.py @@ -43,7 +43,7 @@ 'reversion', 'tinymce', - + 'article', 'userpage', 'notification', diff --git a/static/avatar/default.png b/static/avatar/default.png new file mode 100644 index 0000000..995447f Binary files /dev/null and b/static/avatar/default.png differ diff --git a/static/avatar/page1_bg.jpg b/static/avatar/page1_bg.jpg new file mode 100644 index 0000000..e758722 Binary files /dev/null and b/static/avatar/page1_bg.jpg differ diff --git a/static/bootstrap/css/style.css b/static/bootstrap/css/style.css index eb13f9f..43d5de5 100755 --- a/static/bootstrap/css/style.css +++ b/static/bootstrap/css/style.css @@ -20,9 +20,11 @@ img{ img.avatar-img { display:inline-block; - width:16px; + width:18px; height:18px; - padding-bottom:2px; + margin-bottom:2px; + + border-radius:50%; } .margintop { @@ -137,11 +139,16 @@ div.container-fluid { } .card .comment .comment-avatar { - margin:10px 0 0 20px; + margin:10px 0 10px 20px; width:80px; height:100px; text-align:center; } +.card .comment img.comment-avatar-img { + border-radius:50%; + width:80px; + height:80px; +} .card .comment .comment-info { width:80%; @@ -184,6 +191,7 @@ span.floor { margin:10px 0 0 20px; width:80px; height:80px; + border-radius:50%; } .card .usercard .usercard-info { @@ -210,6 +218,15 @@ span.floor { border-bottom: 1px solid #e2e2e2 } +p.mid { + text-align:center; +} + +ul.errorlist { + margin:auto; + color:red; +} + footer { diff --git a/templates/base.html b/templates/base.html index cdfca29..cdbf050 100644 --- a/templates/base.html +++ b/templates/base.html @@ -1,6 +1,7 @@ {% load staticfiles %} {% load timetonow %} + @@ -70,30 +71,37 @@

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

{% ifnotequal user.id None %}
-
-
+ +
+
+

-   - {{user.user}} - +   + + {{user.user}} + + +

金币 {{user.point}}     - 未读提醒 + 未读提醒 - {{user.unread}} -     -

+ {{user.unread}} +     +

+

注销

+ {% else %} -

{{i.title}}

-

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

+

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

 {{i.publish_time|timetonow}}     -  {{i.author}} +  {{i.author}}      {{i.section}}     @@ -36,7 +36,7 @@

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

     {% if i.tag %}{{i.tag}}{% endif %} - 阅读全文 + 阅读全文››
diff --git a/userpage/__pycache__/forms.cpython-36.pyc b/userpage/__pycache__/forms.cpython-36.pyc index 4be9639..c4b1665 100644 Binary files a/userpage/__pycache__/forms.cpython-36.pyc and b/userpage/__pycache__/forms.cpython-36.pyc differ diff --git a/userpage/__pycache__/models.cpython-36.pyc b/userpage/__pycache__/models.cpython-36.pyc index f5503da..e41f2d4 100644 Binary files a/userpage/__pycache__/models.cpython-36.pyc and b/userpage/__pycache__/models.cpython-36.pyc differ diff --git a/userpage/__pycache__/urls.cpython-36.pyc b/userpage/__pycache__/urls.cpython-36.pyc index 69fdf70..439136f 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 1569d5d..6e50130 100644 Binary files a/userpage/__pycache__/views.cpython-36.pyc and b/userpage/__pycache__/views.cpython-36.pyc differ diff --git a/userpage/forms.py b/userpage/forms.py index 3b89968..13de2d3 100644 --- a/userpage/forms.py +++ b/userpage/forms.py @@ -46,7 +46,7 @@ class RegisterForm(forms.Form): widget=widgets.PasswordInput(attrs={'class': "form-control",'placeholder': '请再次输入密码!'},render_value=True), required=True, strip=True, - error_messages={'required': '请再次输入密码!',} + error_messages={'required': '请再次输入密码!','invalid':'两次密码不匹配!'} ) diff --git a/userpage/migrations/0006_auto_20180303_2241.py b/userpage/migrations/0006_auto_20180303_2241.py new file mode 100644 index 0000000..499e6cb --- /dev/null +++ b/userpage/migrations/0006_auto_20180303_2241.py @@ -0,0 +1,18 @@ +# Generated by Django 2.0.2 on 2018-03-03 14:41 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('userpage', '0005_auto_20180302_1610'), + ] + + operations = [ + migrations.AlterField( + model_name='profile', + name='avatar', + field=models.ImageField(blank=True, default='static/avatar/default.png', null=True, upload_to='static/avatar/'), + ), + ] diff --git a/userpage/migrations/__pycache__/0006_auto_20180303_2241.cpython-36.pyc b/userpage/migrations/__pycache__/0006_auto_20180303_2241.cpython-36.pyc new file mode 100644 index 0000000..ab371fb Binary files /dev/null and b/userpage/migrations/__pycache__/0006_auto_20180303_2241.cpython-36.pyc differ diff --git a/userpage/models.py b/userpage/models.py index 3404a42..04a8357 100644 --- a/userpage/models.py +++ b/userpage/models.py @@ -12,7 +12,7 @@ class Profile(models.Model): #bio = models.TextField(max_length=500, blank=True) location = models.CharField(max_length=30, blank=True) #birth_date = models.DateField(null=True, blank=True) - avatar = models.ImageField(upload_to='static/avatar/', blank=True, null=True) + avatar = models.ImageField(upload_to='static/avatar/', default='static/avatar/default.png', blank=True, null=True) point = models.IntegerField() unread = models.IntegerField(default=0) diff --git a/userpage/templates/userpage/profile.html b/userpage/templates/userpage/profile.html index 0ba5cb3..626af9a 100644 --- a/userpage/templates/userpage/profile.html +++ b/userpage/templates/userpage/profile.html @@ -1,7 +1,8 @@ {% extends "base.html"%} {% load timetonow %} + {% block header %} - 物志 > {{request.user}} + 物志 › {{request.user}} + {% endfor %} + {% endif %} + + +{% endblock %} \ No newline at end of file diff --git a/userpage/urls.py b/userpage/urls.py index e7b111b..3ae257b 100644 --- a/userpage/urls.py +++ b/userpage/urls.py @@ -5,6 +5,6 @@ urlpatterns = [ path('member//', views.profile, name='profile'), path('login/', views.userlogin, name='login'), - path('logout/', views.logout, name='logout'), + path('logout/', views.userlogout, name='logout'), path('register/', views.register, name='register'), ] diff --git a/userpage/views.py b/userpage/views.py index 2099955..b9e8f6f 100644 --- a/userpage/views.py +++ b/userpage/views.py @@ -10,6 +10,8 @@ from notification.models import * from . import forms from django.contrib.auth import authenticate, login +from django.contrib.auth import logout +from django.contrib.auth.models import User # Create your views here. @@ -70,12 +72,13 @@ def userlogin(request): post_check_code = request.POST.get('check_code') session_check_code = request.session['check_code'] user = authenticate(request, username=username, password=password) + print(request.environ,request.path) if user is not None: if post_check_code.lower() == session_check_code.lower() : login(request, user) if request.POST.get('auto_login'): request.session.set_expiry(60 * 60 * 24 *30) - return redirect('/') + return redirect(request.path) else: errors.append('请输入正确的验证码!') else: @@ -84,35 +87,24 @@ def userlogin(request): else: return render(request,'userpage/login.html') -def logout(request): - try: - #删除is_login对应的value值 - del request.session['is_login'] - del request.session['user'] - except KeyError: - pass - #点击注销之后,直接重定向回登录页面 +def userlogout(request): + logout(request) return redirect('/') def register(request): - # username = models.CharField(max_length=16, verbose_name='用户名') - # password = models.CharField(max_length=16, verbose_name='密码') - # nickname = models.CharField(max_length=16,verbose_name='昵称') - # email = models.EmailField(max_length=16, verbose_name='邮箱') - # img = models.ImageField(verbose_name='头像',upload_to='static/img/user/',default='static/img/user/1.jpg') - # ctime = models.DateTimeField(auto_created=True,verbose_name='创建时间') + errors = [] if request.method == 'GET': - obj = forms.Register() + obj = forms.RegisterForm() # return render(request,'register.html',{'form':obj}) elif request.method == 'POST': # print(request.POST) - obj = forms.Register(request.POST) + obj = forms.RegisterForm(request.POST) post_check_code = request.POST.get('check_code') session_check_code = request.session['check_code'] - print(post_check_code,session_check_code) + if obj.is_valid(): - if post_check_code == session_check_code: + if post_check_code.lower() == session_check_code.lower(): # values = obj.clean() data = obj.cleaned_data print(data) @@ -120,15 +112,15 @@ def register(request): username= data.get('username') password= data.get('pwd') email= data.get('email') - nickname = data.get('username') - # ) - models.User.objects.create(username=username,nickname =nickname,password =password,email = email ) - request.session['is_login'] = 'true' - request.session['user'] = data.get('username') - return redirect('/') + User.objects.create(username=username,email = email ) + u = User.objects.get(username=username) + u.set_password(password) + u.save() + + return redirect('/userpage/login/') else: errors = obj.errors - print('hello') + print(errors) return render(request,'userpage/register.html',{'form':obj})