示例#1
0
def uncollect(id):
    post = Post.query.get(id)
    if post is None:
        flash('the post_id is not valid')
        return redirect(url_for('main.index'))
    current_user.uncollect(post)
    return redirect(request.referrer)
示例#2
0
def uncollect(photo_id):
    photo = Photo.query.get_or_404(photo_id)
    if not current_user.is_collecting(photo):
        flash('Not collect yet.', 'info')
        return redirect(url_for('.show_photo', photo_id=photo_id))
    current_user.uncollect(photo)
    flash('Photo uncollected.', 'success')
    return redirect(url_for('.show_photo', photo_id=photo_id))
示例#3
0
def uncollect_post(post_id: int):
    if not current_user.is_authenticated:
        return jsonify(message="Login required."), 401
    post = Post.query.get_or_404(post_id)
    current_user.uncollect(post)
    if not current_user.is_collecting(post):
        return {"message": "ok"}, 200
    return {"message": "failed"}, 400
示例#4
0
def uncollect(photo_id):
    photo = Photo.query.get_or_404(photo_id)
    if not current_user.is_collecting(photo):
        flash('还没有收藏', 'info')
        return redirect(url_for('main.show_photo', photo_id=photo_id))
    current_user.uncollect(photo)
    flash('已取消收藏', 'info')
    return redirect(url_for('.show_photo', photo_id=photo_id))
示例#5
0
def uncollect(id):
    post = Post.query.get_or_404(id)
    if not current_user.collecting(post):
        flash('你没有收藏这篇文章!')
        return redirect(url_for('public.details', id=post.id))
    current_user.uncollect(post)
    flash('取消收藏成功!')
    return redirect(url_for('public.details', id=post.id))
示例#6
0
def uncollect(id):
    post = Post.query.get_or_404(id)
    if not current_user.is_collecting(post):
        flash('你还没有收藏此文章!', 'info')
        return redirect(url_for('posts.show_post', id=id))
    current_user.uncollect(post)
    flash('收藏已取消!', 'info')
    return redirect_back()
示例#7
0
def uncollect(post_id):
    post = Post.query.get_or_404(post_id)
    if not current_user.is_collecting(post):
        flash('该文章未收藏!', 'info')
        return redirect_back()

    current_user.uncollect(post)
    return redirect_back()
示例#8
0
def uncollect(photo_id):
    photo = Photo.query.get_or_404(photo_id)
    if not current_user.is_collecting(photo):
        flash("Not collect yet.", category="info")
        return redirect(url_for("main.show_photo", photo_id=photo_id))
    current_user.uncollect(photo)
    flash("Photo uncollected.", category="info")
    return redirect(url_for("main.show_photo", photo_id=photo_id))
示例#9
0
文件: main.py 项目: zgfhill/albumy-na
def uncollect(photo_id):
    photo = Photo.query.get_or_404(photo_id)
    if not current_user.is_collecting(photo):
        flash('You have not colleted this photo yet', 'info')
        return redirect(url_for('main.show_photo', photo_id=photo_id))
    current_user.uncollect(photo)
    flash('Photo uncollected', 'info')
    return redirect(url_for('main.show_photo', photo_id=photo_id))
示例#10
0
文件: ajax.py 项目: 925150722/albumy
def uncollect(photo_id):
    if not current_user.is_authenticated:
        return jsonify(message='Login required.'), 403
    photo = Photo.query.get_or_404(photo_id)
    if not current_user.is_collecting(photo):
        return jsonify(message='No collect yet.')
    current_user.uncollect(photo)
    return jsonify(message='Collect canceled')
示例#11
0
文件: ajax.py 项目: guoxy2016/Albumy
def uncollect(photo_id):
    if not current_user.is_authenticated:
        return jsonify(message='用户未登录'), 401
    photo = Photo.query.get_or_404(photo_id)
    if not current_user.is_collecting(photo):
        return jsonify(message='你还没有收藏这张图片'), 400
    current_user.uncollect(photo)
    return jsonify(message='取消收藏成功')
示例#12
0
def collect(post_id):
    post = Post.query.filter_by(id=post_id).first()
    if current_user.is_collecting(post):
        current_user.uncollect(post)
        db.session.commit()
        return jsonify(count=post.collectors.count(), collection_type=0)
    current_user.collect(post)
    db.session.commit()
    return jsonify(count=post.collectors.count(), collection_type=1)
示例#13
0
def uncollect(photo_id):
    photo = Photo.query.get_or_404(photo_id)
    if not current_user.is_collecting(photo):
        flash('Фото еще не в коллекции', 'info')
        return redirect(url_for('.show_photo', photo_id=photo_id))

    current_user.uncollect(photo)
    flash('Фото убрано из коллекци', 'info')
    return redirect(url_for('.show_photo', photo_id=photo_id))
示例#14
0
文件: main.py 项目: gweid/PhotoSocial
def uncollect(photo_id):
    """取消收藏"""
    photo = Photo.query.get_or_404(photo_id)
    if not current_user.is_collecting(photo):
        flash('没有收藏过图片.', 'info')
        return redirect(url_for('main.show_photo', photo_id=photo_id))

    current_user.uncollect(photo)
    return redirect_back()
示例#15
0
def uncollect(blog_id):
    blog = Blog.query.get_or_404(blog_id)
    if not current_user.is_collecting(blog):
        flash('Not collect yet.', 'info')
        return redirect(url_for('blog.show_photo', blog_id=blog_id))

    current_user.uncollect(blog)
    flash('Photo uncollected.', 'info')
    return redirect(url_for('blog.show_photo', blog_id=blog_id))
示例#16
0
def uncollect(travel_id):
    travel = Travels.query.get_or_404(travel_id)
    if not current_user.is_collecting(travel):
        flash('您还未收藏此游记', 'info')
        return redirect(url_for('main.show_travels', travel_id=travel_id))

    current_user.uncollect(travel)
    flash('取消收藏成功.', 'info')
    return redirect(url_for('main.show_travels', travel_id=travel_id))
示例#17
0
def uncollect(topic_id):
    topic = Topic.query.get_or_404(topic_id)
    if not current_user.is_collecting(topic):
        flash('还没有收藏此帖子', 'info')
        return redirect(url_for('main.show_topic', topic_id=topic_id))

    current_user.uncollect(topic)
    flash('已取消收藏此帖子。', 'success')
    return redirect(url_for('main.show_topic', topic_id=topic_id))
示例#18
0
def uncollect(photo_id):
    photo = Photo.query.get_or_404(photo_id)
    if not current_user.is_collecting(photo):
        flash("Not collected yet", "warning")
        return redirect(url_for('.show_photo', photo_id=photo_id))

    current_user.uncollect(photo)
    flash("Photo Uncollected", 'success')
    return redirect(url_for('.show_photo', photo_id=photo_id))
示例#19
0
def uncollect(post_id):
    post = Post.query.get_or_404(post_id)
    if not current_user.is_collecting(post):
        flash('你并没有收藏过该博文。', 'info')
        return redirect(url_for('.show_post', post_id=post_id))

    current_user.uncollect(post)
    flash('已取消收藏该博文。', 'info')
    return redirect(url_for('.show_post', post_id=post_id))
示例#20
0
def uncollect(post_id):
    post = Post.query.get_or_404(post_id)
    if not current_user.is_collecting(post):
        flash('文章没有被收藏.', 'info')
        return redirect(url_for('main.show_post', post_id=post_id))

    current_user.uncollect(post)
    flash('文章已被取消收藏', 'info')
    return redirect(url_for('main.show_post', post_id=post_id))
示例#21
0
def uncollect(photo_id):
    if not current_user.is_authenticated:
        return jsonify(message='请先登录!'), 403

    photo = Photo.query.get_or_404(photo_id)
    if not current_user.is_collecting(photo):
        return jsonify(message='还没有收藏。'), 400

    current_user.uncollect(photo)
    return jsonify(message='取消收藏成功。')
示例#22
0
def uncollect(article_id):
    if not current_user.is_authenticated:
        return jsonify(message='Login required.'), 403

    article = Article.query.get_or_404(article_id)
    if not current_user.is_collecting(article):
        return jsonify(message='Not collect yet.'), 400

    current_user.uncollect(article)
    return jsonify(message='Collect canceled.')
示例#23
0
def uncollect(blog_id):
    if not current_user.is_authenticated:
        return jsonify(message='Login required.'), 403

    blog = Blog.query.get_or_404(blog_id)
    if not current_user.is_collecting(blog):
        return jsonify(message='Not collect yet.'), 400

    current_user.uncollect(blog)
    return jsonify(message='Collect canceled.')
示例#24
0
def uncollect(photo_id):
    if not current_user.is_authenticated:
        return jsonify(message=_l('Необходимо войти')), 403

    photo = Photo.query.get_or_404(photo_id)
    if not current_user.is_collecting(photo):
        return jsonify(message=_l('Фото еще не в коллекции.')), 400

    current_user.uncollect(photo)
    return jsonify(message=_l('Фото больше не в коллекции.'))
示例#25
0
文件: ajax.py 项目: haichong98/albumy
def uncollect(photo_id):
    if not current_user.is_authenticated:
        return jsonify(message='需要登录'), 403

    photo = Photo.query.get_or_404(photo_id)
    if not current_user.is_collecting(photo):
        return jsonify(message='还没有关注该图片哦'), 400

    current_user.uncollect(photo)
    return jsonify(message='取消关注成功')
示例#26
0
def uncollect(photo_id):
    if not current_user.is_authenticated:
        return jsonify(message='Требуется войти в свою учетную запись'), 403

    photo = Photo.query.get_or_404(photo_id)
    if not current_user.is_collecting(photo):
        return jsonify(message='Еще не в коллекции. Not collect yet.'), 400

    current_user.uncollect(photo)
    return jsonify(message='Убрано из коллекции')
示例#27
0
def uncollect(id):
	article=Article.query.get_or_404(id)
	if article is None:
		flash('没有该文章')
		return redirect(url_for('main.index'))
	if not current_user.is_collect(article):
		flash('您还没有收藏该文章')
		return redirect(url_for('main.index'))
	current_user.uncollect(article)
	flash('取消成功')
	return redirect(url_for('main.article',id=id))
示例#28
0
文件: ajax.py 项目: gweid/PhotoSocial
def uncollect(photo_id):
    """取消收藏"""
    if not current_user.is_authenticated:
        return jsonify(message='请先登陆.'), 403

    photo = Photo.query.get_or_404(photo_id)
    if not current_user.is_collecting(photo):
        return jsonify(message='没有收藏过.'), 400

    current_user.uncollect(photo)
    return jsonify(message='收藏取消.')
示例#29
0
def uncollect(photo_id):
    if not current_user.is_authenticated:
        return jsonify(message="Login required"), 403

    photo = Photo.query.get_or_404(photo_id)
    if not current_user.is_collecting(photo):
        return jsonify(message="Not yet collected"), 400

    current_user.uncollect(photo)
    if current_user != photo.author and photo.author.receive_collect_notification:
        push_collect_notification(current_user, photo_id, photo.author)
    return jsonify(message="Photo uncollected")
示例#30
0
def uncollect(photo_id):
	"""
	取消收藏
	:param photo_id: 图片id
	"""
	logger.info('url = ' + str(request.url))
	logger.info('取消收藏的用户名: {},图片ID: {}'.format(current_user.username, photo_id))
	photo = Photo.query.get_or_404(photo_id)
	# 如果没有收藏图片,则直接返回
	if not current_user.is_collecting(photo):
		flash("没有收藏过该图片,无法取消!", "info")
		return redirect(url_for("main.show_photo", photo_id=photo_id))
	# 取消收藏
	current_user.uncollect(photo)
	flash("取消收藏成功!", "info")
	return redirect(url_for(".show_photo", photo_id=photo_id))
示例#31
0
def video_uncollect(id):
    video = Video.query.get_or_404(id)
    if current_user.uncollect(video):
        # flash('视频已经从收藏中移除')
        return 'True:' + str(video.collecters.count())
    else:
        # flash('额, 发生未知错误, 请重试')
        return 'False:' + str(video.collecters.count())