Browse Source

fix user model password too short problem,fix tag rss introduce

修复密码太短导致插入数据出错问题,修复tag中rss无介绍导致报错问题
honmaple 8 years ago
parent
commit
bc14a1f2ae

+ 5 - 5
forums/api/tag/views.py

@@ -6,7 +6,7 @@
 # Author: jianglin
 # Email: xiyang0807@gmail.com
 # Created: 2016-12-15 22:07:04 (CST)
-# Last Update:星期日 2017-4-2 14:45:58 (CST)
+# Last Update:星期一 2017-4-3 12:40:9 (CST)
 #          By:
 # Description:
 # **************************************************************************
@@ -50,16 +50,16 @@ class TagsView(MethodView):
 class TagFeedView(MethodView):
     def get(self, name):
         setting = current_app.config.get('SITE', {
-            'title': 'aaa',
-            'introduce': 'asdadj'
+            'title': '',
+            'description': ''
         })
         title = setting['title']
-        introduce = setting['introduce']
+        description = setting['description']
         feed = AtomFeed(
             '%s·%s' % (name, title),
             feed_url=request.url,
             url=request.url_root,
-            subtitle=introduce)
+            subtitle=description)
         topics = Topic.query.filter_by(tags__name=name).limit(10)
         for topic in topics:
             if topic.content_type == Topic.CONTENT_TYPE_MARKDOWN:

+ 3 - 1
forums/api/topic/models.py

@@ -6,7 +6,7 @@
 # Author: jianglin
 # Email: xiyang0807@gmail.com
 # Created: 2016-12-15 20:52:07 (CST)
-# Last Update:星期五 2017-3-31 17:30:1 (CST)
+# Last Update:星期日 2017-4-2 16:57:5 (CST)
 #          By:
 # Description:
 # **************************************************************************
@@ -74,6 +74,8 @@ class Topic(db.Model, ModelMixin):
             'following_topics', lazy='dynamic'),
         lazy='dynamic')
 
+    __mapper_args__ = {"order_by": created_at.desc()}
+
     def is_followed(self, user=None):
         if user is None:
             user = current_user

+ 3 - 3
forums/api/user/models.py

@@ -6,7 +6,7 @@
 # Author: jianglin
 # Email: xiyang0807@gmail.com
 # Created: 2016-12-15 21:09:08 (CST)
-# Last Update:星期六 2017-4-1 22:4:46 (CST)
+# Last Update:星期日 2017-4-2 16:27:2 (CST)
 #          By:
 # Description:
 # **************************************************************************
@@ -34,9 +34,9 @@ user_follower = db.Table(
 class User(db.Model, UserMixin, ModelMixin, MailMixin):
     __tablename__ = 'users'
     id = db.Column(db.Integer, primary_key=True)
-    username = db.Column(db.String(49), unique=True, nullable=False)
+    username = db.Column(db.String(81), unique=True, nullable=False)
     email = db.Column(db.String(81), unique=True, nullable=False)
-    password = db.Column(db.String(81), nullable=False)
+    password = db.Column(db.String(256), nullable=False)
     is_superuser = db.Column(db.Boolean, default=False)
     is_confirmed = db.Column(db.Boolean, default=False)
     register_time = db.Column(db.DateTime, default=datetime.now())

+ 2 - 2
forums/api/user/urls.py

@@ -6,7 +6,7 @@
 # Author: jianglin
 # Email: xiyang0807@gmail.com
 # Created: 2016-12-15 22:24:23 (CST)
-# Last Update:星期六 2017-4-1 21:36:46 (CST)
+# Last Update:星期日 2017-4-2 21:35:21 (CST)
 #          By:
 # Description:
 # **************************************************************************
@@ -16,7 +16,7 @@ from .views import (UserCollectListView, UserFollowingListView,
                     UserFollowerListView, UserListView, UserReplyListView,
                     UserView)
 
-site = Blueprint('user', __name__, url_prefix='/user')
+site = Blueprint('user', __name__, url_prefix='/u')
 
 user_list = UserListView.as_view('list')
 user = UserView.as_view('user')

+ 9 - 1
manager.py

@@ -6,7 +6,7 @@
 # Author: jianglin
 # Email: xiyang0807@gmail.com
 # Created: 2016-10-25 22:08:39 (CST)
-# Last Update:星期六 2017-4-1 21:34:3 (CST)
+# Last Update:星期日 2017-4-2 16:44:25 (CST)
 #          By:
 # Description:
 # **************************************************************************
@@ -74,6 +74,14 @@ def delete_user(username):
 
 
 @manager.option('-u', '--username', dest='username')
+def password_user(username):
+    password = getpass('Password:')
+    user = User.query.filter_by(username=username).first()
+    user.set_password(password)
+    user.save()
+
+
+@manager.option('-u', '--username', dest='username')
 @manager.option('-e', '--email', dest='email')
 @manager.option('-w', '--password', dest='password')
 def create_user(username, email, password):

+ 1 - 1
static/assets/home.js

@@ -28,7 +28,7 @@ $(document).ready(function(){$('button.topic-following').click(function(){var _$
 $(document).ready(function(){$('.like-reply').click(function(){var _$this=$(this);var replyId=_$this.attr('data-id');var like_url="/replies/"+replyId+'/like';var data=JSON.stringify({});if(_$this.hasClass('like-active')){$.ajax({type:"DELETE",url:like_url,data:data,contentType:'application/json;charset=UTF-8',success:function(response){if(response.status==='200')
 {_$this.attr("title","赞");_$this.removeClass("like-active");_$this.addClass("like-no-active");}else{window.location.href=response.url;}}});}else{$.ajax({type:"POST",url:like_url,data:data,contentType:'application/json;charset=UTF-8',success:function(response){if(response.status==='200')
 {_$this.attr("title","取消赞");_$this.removeClass("like-no-active");_$this.addClass("like-active");}else
-{window.location.href=response.url;}}});}});$('.reply-author').click(function(){var _$this=$(this);var author=_$this.attr('data-id');$('#content').focus();$('#content').val('@'+author+' ');});$('#topic-preview').click(function(){var content=$('#content').val();$.post('/topic/preview',{content:$("#content").val(),content_type:$("#content_type").val()},function(data){$("#show-preview").html(data);});});$('#tokenfield').tokenfield({limit:4});$('#topic-put-btn').click(function(){var _$this=$(this);var url='/topic/'+_$this.attr("data-id");var data={csrf_token:$('input[name="csrf_token"]').val(),title:$('input[name="title"]').val(),tags:$('input[name="tags"]').val(),category:$('select[name="category"]').val(),content:$('textarea[name="content"]').val(),content_type:$('select[name="content_type"]').val()};$.ajax({type:"PUT",url:url,data:JSON.stringify(data),contentType:'application/json;charset=UTF-8',success:function(response){if(response.status==='200'){window.location.href=url;}else{if(response.description!==""){alert(response.description);}else{alert(response.message);}}}});});});/*!
+{window.location.href=response.url;}}});}});$('.reply-author').click(function(){var _$this=$(this);var author=_$this.attr('data-id');$('#content').focus();$('#content').val('@'+author+' ');});$('#topic-preview').click(function(){var content=$('#content').val();$.post('/topic/preview',{content:$("#content").val(),content_type:$("#content_type").val()},function(data){$("#show-preview").html(data);});});$('#tokenfield').tokenfield({limit:4});$('#topic-put-btn').click(function(){var _$this=$(this);var url='/topic/'+_$this.attr("data-id");var data={csrf_token:$('input[name="csrf_token"]').val(),title:$('input[name="title"]').val(),tags:$('input[name="tags"]').val(),category:$('select[name="category"]').val(),content:$('textarea[name="content"]').val(),content_type:$('select[name="content_type"]').val()};$.ajax({type:"PUT",url:url,data:JSON.stringify(data),contentType:'application/json;charset=UTF-8',success:function(response){if(response.status==='200'){window.location.href=url;}else{if(response.description!=""){alert(response.description);}else{alert(response.message);}}}});});});/*!
  * bootstrap-tokenfield 0.12.1
  * https://github.com/sliptree/bootstrap-tokenfield
  * Copyright 2013-2014 Sliptree and other contributors; Licensed MIT

+ 1 - 1
static/styles/topic.js

@@ -78,7 +78,7 @@ $(document).ready(function(){
         if (response.status === '200') {
           window.location.href= url;
         }else {
-          if (response.description !==""){
+          if (response.description != ""){
             alert(response.description);
           }else {
             alert(response.message);

+ 1 - 1
templates/base/base.html

@@ -6,7 +6,7 @@
 {% from 'base/head.html' import breadcrumb %}
 
 {% block title -%}
-  {{ title }} - {{ SITE['title'] }} - {{ _(SITE['description']) }}
+  {{ title }} {{ SITE['title'] }} - {{ _(SITE['description']) }}
 {%- endblock title %}
 
 {% block script -%}