1
1
Fork 0

API - don't show unapproved + messages de-debug

master
Jan Kužílek 5 years ago
parent 64f46fd338
commit a87297f968

@ -97,7 +97,8 @@ def modify_user():
if form.op_level.data: el.op_level = form.op_level.data if form.op_level.data: el.op_level = form.op_level.data
db.session.commit() db.session.commit()
flash('New {} has been created.'.format(str(el))) #flash('New {} has been created.'.format(str(el)))
flash('New user has been created.')
else: else:
el = User.query.get(form.id.data) el = User.query.get(form.id.data)
@ -112,7 +113,8 @@ def modify_user():
db.session.delete(el) db.session.delete(el)
db.session.commit() db.session.commit()
flash('{} deleted.'.format(str(el))) #flash('{} deleted.'.format(str(el)))
flash('User deleted.')
elif form.edit.data: elif form.edit.data:
# if form.username.data: el.username = form.username.data # if form.username.data: el.username = form.username.data
@ -122,7 +124,8 @@ def modify_user():
if form.op_level.raw_data and form.op_level.data: el.op_level = form.op_level.data if form.op_level.raw_data and form.op_level.data: el.op_level = form.op_level.data
db.session.commit() db.session.commit()
flash('Changes to {} have been applied.'.format(str(el))) #flash('Changes to {} have been applied.'.format(str(el)))
flash('Changes to user have been applied.')
flasherrors(form) flasherrors(form)
return redirect(url_for('.manage_users')) return redirect(url_for('.manage_users'))
@ -146,7 +149,8 @@ def modify_post():
el.remove_image_files() el.remove_image_files()
db.session.delete(el) db.session.delete(el)
db.session.commit() db.session.commit()
flash('{} deleted.'.format(str(el))) #flash('{} deleted.'.format(str(el)))
flash('Post deleted.')
elif form.edit.data: elif form.edit.data:
if form.rating.raw_data and form.rating.data: el.rating = form.rating.data if form.rating.raw_data and form.rating.data: el.rating = form.rating.data
@ -163,7 +167,8 @@ def modify_post():
el.tags = tags el.tags = tags
db.session.commit() db.session.commit()
flash('Changes to {} have been applied.'.format(str(el))) #flash('Changes to {} have been applied.'.format(str(el)))
flash('Changes to post have been applied.')
elif form.approve.data: elif form.approve.data:
if not current_user.is_moderator: if not current_user.is_moderator:
@ -173,7 +178,8 @@ def modify_post():
el.approver = current_user el.approver = current_user
db.session.commit() db.session.commit()
flash('Approved post {}.'.format(str(el))) #flash('Approved post {}.'.format(str(el)))
flash('Post approved.')
# redirect(url_for('post.post_show', id=el.id)) # redirect(url_for('post.post_show', id=el.id))
flasherrors(form) flasherrors(form)
@ -198,21 +204,24 @@ def modify_tag():
if form.category.raw_data and form.category.data: el.category = form.category.data if form.category.raw_data and form.category.data: el.category = form.category.data
db.session.commit() db.session.commit()
flash('New {} has been created.'.format(str(el))) #flash('New {} has been created.'.format(str(el)))
flash('New tag has been created.')
else: else:
el = Tag.query.get(form.id.data) el = Tag.query.get(form.id.data)
if form.delete.data: if form.delete.data:
db.session.delete(el) db.session.delete(el)
db.session.commit() db.session.commit()
flash('{} deleted.'.format(str(el))) #flash('{} deleted.'.format(str(el)))
flash('Tag deleted.')
elif form.edit.data: elif form.edit.data:
# if form.content.data: el.content = form.content.data # if form.content.data: el.content = form.content.data
if form.category.raw_data and form.category.data: el.category = form.category.data if form.category.raw_data and form.category.data: el.category = form.category.data
db.session.commit() db.session.commit()
flash('Changes to {} have been applied.'.format(str(el))) #flash('Changes to {} have been applied.'.format(str(el)))
flash('Changes to tag have been applied.')
flasherrors(form) flasherrors(form)
return redirect(url_for('.manage_tags')) return redirect(url_for('.manage_tags'))
@ -233,7 +242,8 @@ def modify_comment():
if form.delete.data: if form.delete.data:
db.session.delete(el) db.session.delete(el)
db.session.commit() db.session.commit()
flash('{} deleted.'.format(str(el))) #flash('{} deleted.'.format(str(el)))
flash('Comment deleted.')
elif form.edit.data: elif form.edit.data:
# if form.rating.raw_data and form.rating.data: el.rating = form.rating.data # if form.rating.raw_data and form.rating.data: el.rating = form.rating.data
@ -241,21 +251,24 @@ def modify_comment():
# if form.source.raw_data: el.source = form.source.data # if form.source.raw_data: el.source = form.source.data
# db.session.commit() # db.session.commit()
flash('Changes to {} have been applied.'.format(str(el))) #flash('Changes to {} have been applied.'.format(str(el)))
flash('Changes to comment have been applied.')
elif form.ban.data: elif form.ban.data:
el.ban_reason = form.ban_reason.data el.ban_reason = form.ban_reason.data
el.banned = True el.banned = True
db.session.commit() db.session.commit()
flash('Comment {} has been banned.'.format(str(el))) #flash('Comment {} has been banned.'.format(str(el)))
flash('Comment has been banned.')
elif form.unban.data: elif form.unban.data:
el.ban_reason = None el.ban_reason = None
el.banned = False el.banned = False
db.session.commit() db.session.commit()
flash('Comment {} has been unbanned.'.format(str(el))) #flash('Comment {} has been unbanned.'.format(str(el)))
flash('Comment has been unbanned.')
flasherrors(form) flasherrors(form)
if form.referer.data == 'post_show': if form.referer.data == 'post_show':

@ -111,7 +111,8 @@ def comment():
db.session.add(el) db.session.add(el)
db.session.commit() db.session.commit()
flash('Successfully submitted {}.'.format(str(el))) #flash('Successfully submitted {}.'.format(str(el)))
flash('Comment successfully submitted.')
return redirect(url_for('post.post_show', id=form.post_id.data)) return redirect(url_for('post.post_show', id=form.post_id.data))
else: else:
el = Comment.query.filter_by(id=form.id.data).first() el = Comment.query.filter_by(id=form.id.data).first()
@ -124,12 +125,14 @@ def comment():
if form.delete.data: if form.delete.data:
db.session.delete(el) db.session.delete(el)
db.session.commit() db.session.commit()
flash('{} deleted.'.format(str(el))) #flash('{} deleted.'.format(str(el)))
flash('Comment deleted.')
elif form.edit.data: elif form.edit.data:
if form.content.raw_data and form.content.data: el.content = form.content.data.strip() if form.content.raw_data and form.content.data: el.content = form.content.data.strip()
db.session.commit() db.session.commit()
flash('Changes to {} have been applied.'.format(str(el))) #flash('Changes to {} have been applied.'.format(str(el)))
flash('Changes to comment have been applied.')
elif form.ban.data: elif form.ban.data:
if not current_user.is_moderator: if not current_user.is_moderator:
@ -139,7 +142,8 @@ def comment():
el.deleted = True el.deleted = True
db.session.commit() db.session.commit()
flash('Comment {} has been banned.'.format(str(el))) #flash('Comment {} has been banned.'.format(str(el)))
flash('Comment has been banned.')
elif form.unban.data: elif form.unban.data:
if not current_user.is_moderator: if not current_user.is_moderator:
@ -149,7 +153,8 @@ def comment():
el.deleted = False el.deleted = False
db.session.commit() db.session.commit()
flash('Comment {} has been unbanned.'.format(str(el))) #flash('Comment {} has been unbanned.'.format(str(el)))
flash('Comment has been unbanned.')
return redirect(url_for('post.post_show', id=el.post_id)) return redirect(url_for('post.post_show', id=el.post_id))
@ -175,7 +180,8 @@ def upload():
db.session.add(post) db.session.add(post)
db.session.commit() db.session.commit()
flash('Successfully submitted {}.'.format(str(post))) #flash('Successfully submitted {}.'.format(str(post)))
flash('Upload successfully submitted.')
return redirect(url_for('.posts')) return redirect(url_for('.posts'))
@ -212,7 +218,7 @@ def posts_api():
if f_tags: if f_tags:
posts_query = posts_query.join(Post.tags).group_by(Post.id).filter(Tag.content.in_(f_tags)).having(func.count(Post.id)==len(f_tags)) posts_query = posts_query.join(Post.tags).group_by(Post.id).filter(Tag.content.in_(f_tags)).having(func.count(Post.id)==len(f_tags))
# posts_query = posts_query.filter(Post.rating.in_(m_ratings)).order_by(Post.created.desc()) # posts_query = posts_query.filter(Post.rating.in_(m_ratings)).order_by(Post.created.desc())
posts_query = posts_query.order_by(Post.created.desc()) posts_query = posts_query.filter_by(status=POST_STATUS.active).order_by(Post.created.desc())
posts = posts_query.paginate(int(request.args.get('page', 0))+1, int(request.args.get('limit') or current_app.config.get('POSTS_PER_PAGE'))) posts = posts_query.paginate(int(request.args.get('page', 0))+1, int(request.args.get('limit') or current_app.config.get('POSTS_PER_PAGE')))

Loading…
Cancel
Save