|
@@ -6,7 +6,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
@@ -53,79 +53,69 @@ def form_sort(t1, t2, t3):
|
|
|
|
|
|
|
|
|
if t2 == 0:
|
|
|
+ topic_base = Topic.query.join(Topic.board).filter(
|
|
|
+ Topic.publish > time, Topic.is_top == False)
|
|
|
if t3 == 0:
|
|
|
if type == 'parent_b':
|
|
|
- topics = Topic.query.join(Topic.board).filter(
|
|
|
- Topic.publish > time, Board.parent_board ==
|
|
|
- uid).order_by(Topic.publish.desc()).paginate(page, 20,
|
|
|
- True)
|
|
|
+ topics = topic_base.filter(Board.parent_board == uid).paginate(
|
|
|
+ page, 20, True)
|
|
|
elif type == 'child_b':
|
|
|
- topics = Topic.query.join(Topic.board).filter(
|
|
|
- Topic.publish > time,
|
|
|
- Board.id == uid).order_by(Topic.publish.desc()).paginate(
|
|
|
- page, 20, True)
|
|
|
+ topics = topic_base.filter(Board.id == uid).paginate(page, 20,
|
|
|
+ True)
|
|
|
elif type == 'tags':
|
|
|
topics = Topic.query.join(Topic.tags).filter(
|
|
|
- Topic.publish > time, Tags.tagname ==
|
|
|
- uid).order_by(Topic.publish.desc()).paginate(page, 20,
|
|
|
- True)
|
|
|
+ Topic.publish > time, Topic.is_top == False, Tags.tagname
|
|
|
+ == uid).order_by(Topic.publish.desc()).paginate(page, 20,
|
|
|
+ True)
|
|
|
else:
|
|
|
topics = None
|
|
|
return topics
|
|
|
else:
|
|
|
if type == 'parent_b':
|
|
|
- topics = Topic.query.join(Topic.board).filter(
|
|
|
- Topic.publish > time, Board.parent_board ==
|
|
|
- uid).order_by(Topic.publish.asc()).paginate(page, 20, True)
|
|
|
+ topics = topic_base.filter(Board.parent_board == uid).order_by(
|
|
|
+ Topic.publish.asc()).paginate(page, 20, True)
|
|
|
elif type == 'child_b':
|
|
|
- topics = Topic.query.join(Topic.board).filter(
|
|
|
- Topic.publish > time,
|
|
|
- Board.id == uid).order_by(Topic.publish.asc()).paginate(
|
|
|
- page, 20, True)
|
|
|
+ topics = topic_base.filter(Board.id == uid).order_by(
|
|
|
+ Topic.publish.asc()).paginate(page, 20, True)
|
|
|
elif type == 'tags':
|
|
|
topics = Topic.query.join(Topic.tags).filter(
|
|
|
- Topic.publish > time, Tags.tagname ==
|
|
|
+ Topic.publish > time, Topic.is_top == False,
|
|
|
+ Tags.tagname ==
|
|
|
uid).order_by(Topic.publish.asc()).paginate(page, 20, True)
|
|
|
else:
|
|
|
topics = None
|
|
|
return topics
|
|
|
|
|
|
else:
|
|
|
+ topic_base = Topic.query.join(Topic.board).filter(
|
|
|
+ Topic.publish > time, Topic.is_top == False)
|
|
|
if t3 == 0:
|
|
|
if type == 'parent_b':
|
|
|
- topics = Topic.query.join(Topic.board).filter(
|
|
|
- Topic.publish > time, Board.parent_board ==
|
|
|
- uid).order_by(Topic.author_id.desc()).paginate(page, 20,
|
|
|
- True)
|
|
|
+ topics = topic_base.filter(Board.parent_board == uid).order_by(
|
|
|
+ Topic.author_id.desc()).paginate(page, 20, True)
|
|
|
elif type == 'child_b':
|
|
|
- topics = Topic.query.join(Topic.board).filter(
|
|
|
- Topic.publish > time,
|
|
|
- Board.id == uid).order_by(Topic.author_id.desc()).paginate(
|
|
|
- page, 20, True)
|
|
|
+ topics = topic_base.filter(Board.id == uid).order_by(
|
|
|
+ Topic.author_id.desc()).paginate(page, 20, True)
|
|
|
elif type == 'tags':
|
|
|
topics = Topic.query.join(Topic.tags).filter(
|
|
|
- Topic.publish > time, Tags.tagname ==
|
|
|
- uid).order_by(Topic.author_id.desc()).paginate(page, 20,
|
|
|
- True)
|
|
|
+ Topic.publish > time, Topic.is_top == False, Tags.tagname
|
|
|
+ == uid).order_by(Topic.author_id.desc()).paginate(page, 20,
|
|
|
+ True)
|
|
|
else:
|
|
|
topics = None
|
|
|
return topics
|
|
|
else:
|
|
|
if type == 'parent_b':
|
|
|
- topics = Topic.query.join(Topic.board).filter(
|
|
|
- Topic.publish > time, Board.parent_board ==
|
|
|
- uid).order_by(Topic.author_id.asc()).paginate(page, 20,
|
|
|
- True)
|
|
|
+ topics = topic_base.filter(Board.parent_board == uid).order_by(
|
|
|
+ Topic.author_id.asc()).paginate(page, 20, True)
|
|
|
elif type == 'child_b':
|
|
|
- topics = Topic.query.join(Topic.board).filter(
|
|
|
- Topic.publish > time,
|
|
|
- Board.id == uid).order_by(Topic.author_id.asc()).paginate(
|
|
|
- page, 20, True)
|
|
|
+ topics = topic_base.filter(Board.id == uid).order_by(
|
|
|
+ Topic.author_id.asc()).paginate(page, 20, True)
|
|
|
elif type == 'tags':
|
|
|
topics = Topic.query.join(Topic.tags).filter(
|
|
|
- Topic.publish > time, Tags.tagname ==
|
|
|
- uid).order_by(Topic.author_id.asc()).paginate(page, 20,
|
|
|
- True)
|
|
|
+ Topic.publish > time, Topic.is_top == False, Tags.tagname
|
|
|
+ == uid).order_by(Topic.author_id.asc()).paginate(page, 20,
|
|
|
+ True)
|
|
|
else:
|
|
|
topics = None
|
|
|
return topics
|