Skip to content

Commit

Permalink
add register page
Browse files Browse the repository at this point in the history
  • Loading branch information
gothack329 committed Mar 3, 2018
1 parent a336ed8 commit f6c590d
Show file tree
Hide file tree
Showing 22 changed files with 174 additions and 54 deletions.
7 changes: 4 additions & 3 deletions article/templates/article/detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -65,18 +65,19 @@ <h1>{% if art %}{{art.title}}{% endif %} </h1>

{% for i in comments %}
<div class="comment row {% ifequal i.invalid 'Y' %}invalid{% endifequal %}">
<div class="comment-avatar" style="background:url(/{{i.user.avatar}}) no-repeat;background-position:10px 20px;background-size:60px 60px;">
<div class="comment-avatar" > <!--style="background:url(/{{i.user.avatar}}) no-repeat;background-position:10px 20px;background-size:60px 60px;"-->
<a href="/userpage/member/{{i.user}}/">{{i.user}}</a>
<img class="comment-avatar-img" src="/{{i.user.avatar}}">
</div>
<div class="comment-info ">

<span class="glyphicon glyphicon-time fad"> </span>&nbsp;<span class="fad">{{i.comment_time|timetonow}}</span> &nbsp;&nbsp;
{% ifequal request.user.id i.user.id %}
{% ifequal art.author_id.id i.user.id %}
<span class="ico fad" style="padding:2px;border:1px solid gray">作者</span>
{% endifequal %}
<span class="pull-right ico fad floor" id="comment_{{i.id}}"># {{forloop.counter}}</span>
<span class="pull-right ico ">
<a href="javascript:;" onclick="atuser('<a href=#comment_{{i.id}} >#{{forloop.counter}}</a> @<a class=mentioned_user href=/userpage/member/{{i.user}}>{{i.user}}</a>&nbsp;')"><img style="inline-block" src="/static/image/reply.png" align="absmiddle" border="0" alt="Reply"></a>
<a href="javascript:;" onclick="atuser('<a href=#comment_{{i.id}} > [#{{forloop.counter}}]</a> @<a class=mentioned_user href=/userpage/member/{{i.user}}>{{i.user}}</a>&nbsp;')"><img style="inline-block" src="/static/image/reply.png" align="absmiddle" border="0" alt="Reply"></a>
</span>

<p></p>
Expand Down
Binary file modified db.sqlite3
Binary file not shown.
Binary file modified edconline/__pycache__/settings.cpython-36.pyc
Binary file not shown.
Binary file modified edconline/__pycache__/urls.cpython-36.pyc
Binary file not shown.
2 changes: 1 addition & 1 deletion edconline/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
'reversion',

'tinymce',

'article',
'userpage',
'notification',
Expand Down
Binary file added static/avatar/default.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/avatar/page1_bg.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 20 additions & 3 deletions static/bootstrap/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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%;
Expand Down Expand Up @@ -184,6 +191,7 @@ span.floor {
margin:10px 0 0 20px;
width:80px;
height:80px;
border-radius:50%;
}

.card .usercard .usercard-info {
Expand All @@ -210,6 +218,15 @@ span.floor {
border-bottom: 1px solid #e2e2e2
}

p.mid {
text-align:center;
}

ul.errorlist {
margin:auto;
color:red;
}



footer {
Expand Down
28 changes: 18 additions & 10 deletions templates/base.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<!DOCTYPE html>
{% load staticfiles %}
{% load timetonow %}

<html>
<head>
<meta charset="utf-8">
Expand Down Expand Up @@ -70,30 +71,37 @@ <h1>{% if title %}{{title}}{% endif %} </h1>
{% ifnotequal user.id None %}
<div class="usercard row">

<a href="/userpage/member/{{user.user}}/"><div class="usercard-avatar" style="background:url(/{{user.avatar}}) no-repeat;background-size:80px 80px;">
</div></a>
<a href="/userpage/member/{{user.user}}/">
<div class="usercard-avatar" style="background:url(/{{user.avatar}}) no-repeat;background-size:80px 80px;">
</div>
</a>
<div class="usercard-info">
<p>
<a href="/userpage/member/{{user.user}}/"><span class="glyphicon glyphicon-user fad"> </span>&nbsp;<span class="fad">
{{user.user}}
</span> </a>
<a href="/userpage/member/{{user.user}}/"><span class="glyphicon glyphicon-user fad"> </span>&nbsp;
<span class="fad">
{{user.user}}
</span>

</a>
</p>
<p>
<img src="/static/image/coin16.png" style="display:inline-block;padding-bottom: 4px" alt="金币" > <span class="fad">
{{user.point}}
</span> &nbsp;&nbsp;&nbsp;
<img src="/static/image/notice.png" width="16" height="16" style="display:inline-block;padding-bottom: 2px;width:16px;height:20px" alt="未读提醒" >
<a href="/userpage/member/{{user.user}}/"><img src="/static/image/notice.png" width="16" height="16" style="display:inline-block;padding-bottom: 2px;width:16px;height:20px" alt="未读提醒" >
<span class="fad" alt="未读提醒">
<a href="/userpage/member/{{user.user}}/">{{user.unread}}</a>
</span> &nbsp;&nbsp;&nbsp;
</p>
{{user.unread}}
</span></a> &nbsp;&nbsp;&nbsp;
</p>
<p><span class="glyphicon glyphicon-log-out fad"></span><a href="/userpage/logout/"> 注销</a></p>
</div>
</div>
<span class="sep"></span>
<button class="btn btn-default" style="width:100%;margin-top: 10px" type="submit" onclick="window.location.href='/article/publish/'">
<span class="glyphicon glyphicon-pencil"></span>&nbsp; 发布新文章
</button>
{% else %}
<button class="btn btn-info btn-sidebar" style="width:70%;margin-top: 10px" type="submit" onclick="window.location.href='/userpage/login/'">
<button class="btn btn-default btn-sidebar" style="width:70%;margin-top: 10px" type="submit" onclick="window.location.href='/userpage/login/'">
登录
</button>
<button class="btn btn-info btn-sidebar" style="width:70%;margin-top: 10px" type="submit" onclick="window.location.href='/userpage/register/'">
Expand Down
6 changes: 3 additions & 3 deletions templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,19 @@ <h1>{% if title %}{{title}}{% endif %} </h1>
</div>
<div class="preview-info">
<a href="/article/{{i.id}}/"><h2>{{i.title}}</h2></a>
<p class="fad">{{i.detail|striptags|truncatechars:500|safe}} </p>
<p class="fad">{{i.detail|striptags|truncatechars:500|safe|linebreaks}} </p>
<p></p>
<span class="glyphicon glyphicon-time fad"> </span>&nbsp;<span class="fad">{{i.publish_time|timetonow}}</span>
&nbsp;&nbsp;&nbsp;
<a href="/userpage/member/{{i.author_id}}/"><span class="glyphicon glyphicon-user fad"> </span>&nbsp;<span class="fad">{{i.author}}</span></a>
<a href="/userpage/member/{{i.author_id}}/"><img src="/{{i.author_id.avatar}}" class="avatar-img">&nbsp;<span class="fad">{{i.author}}</span></a>
&nbsp;&nbsp;&nbsp;
<span class="glyphicon glyphicon-th-list fad"> </span>&nbsp;<a href="/?catalog={{i.section}}"><span class="fad">{{i.section}}</span></a>
&nbsp;&nbsp;&nbsp;
<span class="glyphicon glyphicon-eye-open fad"> </span>&nbsp;<span class="fad">{{i.readtime}}</span>
&nbsp;&nbsp;&nbsp;
<span class="glyphicon glyphicon-tag fad"> </span>&nbsp;<span class=" fad">{% if i.tag %}{{i.tag}}{% endif %}</span>
<span class="pull-right">
<span><a href="/article/{{i.id}}/">阅读全文</a></span>
<span><a href="/article/{{i.id}}/">阅读全文››</a></span>
</span>
</div>
</div>
Expand Down
Binary file modified userpage/__pycache__/forms.cpython-36.pyc
Binary file not shown.
Binary file modified userpage/__pycache__/models.cpython-36.pyc
Binary file not shown.
Binary file modified userpage/__pycache__/urls.cpython-36.pyc
Binary file not shown.
Binary file modified userpage/__pycache__/views.cpython-36.pyc
Binary file not shown.
2 changes: 1 addition & 1 deletion userpage/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -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':'两次密码不匹配!'}

)

Expand Down
18 changes: 18 additions & 0 deletions userpage/migrations/0006_auto_20180303_2241.py
Original file line number Diff line number Diff line change
@@ -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/'),
),
]
Binary file not shown.
2 changes: 1 addition & 1 deletion userpage/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
11 changes: 6 additions & 5 deletions userpage/templates/userpage/profile.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{% extends "base.html"%}
{% load timetonow %}

{% block header %}
<title> 物志 > {{request.user}} </title>
<title> 物志 {{request.user}} </title>
<script type="text/javascript">
$(function(){
$(".detail-tab").find(".profile-tab:first").show();
Expand Down Expand Up @@ -117,8 +118,8 @@
<p></p>
{% for i in comments %}
<div class="row member_comments">
<p style="background-color: #eee;padding:2px">于 {{i.comment_time|timetonow}} 评论了 <a href="/userpage/member/{{i.article.author_id}}/">{{i.article.author_id}} </a>的文章【 <a href="/article/{{i.article.id}}/">{{i.article}}</a></p>
<p><a href="/article/{{i.article.id}}/#comment_{{i.id}}">{{i.comment|safe|escape}}</a></p>
<p style="background-color: #eee;padding:5px">于 {{i.comment_time|timetonow}} 评论了 <a href="/userpage/member/{{i.article.author_id}}/">{{i.article.author_id}} </a>的文章【 <a href="/article/{{i.article.id}}/">{{i.article}}</a></p>
<p><a href="/article/{{i.article.id}}/#comment_{{i.id}}">{{i.comment|safe|escape|linebreaks}}</a></p>
</div>

{% endfor %}
Expand All @@ -130,8 +131,8 @@
<p></p>
{% for i in notice %}
<div class="row member_comments" style="padding-left:20px">
<p style="background-color: #eee;padding:2px"><a href="/userpage/member/{{i.comment.user}}/">{{i.comment.user}}</a><a href="/article/{{i.comment.article.id}}/">{{i.comment.article}}</a> 的评论中提到了您 <span class="pull-right">{{i.comment_time|timetonow}}</span></p>
<p><a href="/article/{{i.comment.article.id}}/#comment_{{i.comment.id}}">{{i.comment|safe|escape}}</a></p>
<p style="background-color: #eee;padding:5px"><a href="/userpage/member/{{i.comment.user}}/">{{i.comment.user}}</a><a href="/article/{{i.comment.article.id}}/">{{i.comment.article}}</a> 的评论中提到了您 <span class="pull-right">{{i.comment_time|timetonow}}</span></p>
<p><a href="/article/{{i.comment.article.id}}/#comment_{{i.comment.id}}">{{i.comment|striptags|safe|linebreaks}}</a></p>
</div>
{% endfor %}
</div>
Expand Down
83 changes: 83 additions & 0 deletions userpage/templates/userpage/register.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
{% extends 'base.html' %}
{% load timetonow %}

{% block header %}
<title> 物志 › 注册 </title>
{% endblock %}

{% block banner %}
<div style="height:30px">
<p></p>
</div>
{% endblock %}

{% block content %}
<div class="card">
<form class="form-inline " method="post" action="" novalidate>{% csrf_token %}
<a href="/">物志</a> › 注册
<hr>

<p class="mid">
<label style="width:100px;text-align:right" for="username">用户名:</label>
{{ form.username }}
</p>
<p class="mid"><span style="color:red">{{ form.username.errors|striptags }}</span></p>

<p class="mid">
<label style="width:100px;text-align:right" for="email">邮箱:</label>
{{ form.email }}
</p>
<p class="mid"><span style="color:red">{{ form.email.errors|striptags }}</span></p>

<p class="mid">
<label style="width:100px;text-align:right" for="password">密码:</label>
{{ form.pwd }}
</p>
{% for i in form.pwd.errors %}
<p class="mid">
<span style="color:red">{{i}}</span>
</p>
{% endfor %}

<p class="mid">
<label style="width:100px;text-align:right" for="confirm_password">确认密码:</label>
{{ form.pwd_again }}
</p>
<p><span style="color: red">{{ form.pwd_again.errors|striptags }}</span></p>

<p class="mid">
<label style="width:100px;text-align:right"></label>
<img style="display:inline-block;" id="check_code_img" src="/utils/check_code/" onclick="refresh_check_code(this)"></p>
<p class="mid">
<label style="width:100px;text-align:right" for="check_code">验证码:</label>
<input type="text" class="form-control" name="check_code" id="check_code" placeholder="请输入验证码">
</p>

<p class="mid">
<button class="btn btn-primary" type="submit" >注册</button>
</p>

</form>
</div>


{% if errors %}
{% for error in errors %}
<script type="text/javascript">
$.notify({
message: '{{ error|escape }}',
},{
type: 'warning',
delay: 5000,
timer: 1000,
animate: {
enter: 'animated flipInY',
exit: 'animated flipOutX'
},
},);
</script>
{% endfor %}
{% endif %}


{% endblock %}
2 changes: 1 addition & 1 deletion userpage/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
urlpatterns = [
path('member/<str:username>/', 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'),
]
Loading

0 comments on commit f6c590d

Please sign in to comment.