Example #1
0
def collect(photo_id):
    photo = Photo.query.get_or_404(photo_id)
    if current_user.is_collecting(photo):
        flash(_l('Already collected.'), 'info')
        return redirect(url_for('.show_photo', photo_id=photo_id))

    current_user.collect(photo)
    flash(_l('Photo collected.'), 'success')
    if current_user != photo.author and photo.author.receive_collect_notification:
        push_collect_notification(collector=current_user, photo_id=photo_id, receiver=photo.author)
    return redirect(url_for('.show_photo', photo_id=photo_id))
Example #2
0
def collect(photo_id):
    photo = Photo.query.get_or_404(photo_id)
    if current_user.is_collecting(photo):
        flash('Уже в коллекции', 'info')
        return redirect(url_for('.show_photo', photo_id=photo_id))

    current_user.collect(photo)
    flash('Фото добавлено в коллекцию', 'success')
    if current_user != photo.author and photo.author.receive_collect_notification:
        push_collect_notification(collector=current_user, photo_id=photo_id, receiver=photo.author)
    return redirect(url_for('.show_photo', photo_id=photo_id))
Example #3
0
def collect(photo_id):
    if not current_user.is_authenticated:
        return jsonify(message='Login required.'), 403
    if not current_user.confirmed:
        return jsonify(message='Confirm account required.'), 400
    if not current_user.can('COLLECT'):
        return jsonify(message='No permission.'), 403

    photo = Photo.query.get_or_404(photo_id)
    if current_user.is_collecting(photo):
        return jsonify(message='Already collected.'), 400

    current_user.collect(photo)
    if current_user != photo.author and photo.author.receive_collect_notification:
        push_collect_notification(collector=current_user,
                                  photo_id=photo_id,
                                  receiver=photo.author)
    return jsonify(message='Photo collected.')
Example #4
0
def collect(photo_id):
    if not current_user.is_authenticated:
        return jsonify(message=_l('Необходимо войти.')), 403
    if not current_user.confirmed:
        return jsonify(message=_l('Необходимо подтверждение аккаунта.')), 400
    if not current_user.can('COLLECT'):
        return jsonify(message=_l('Отсутствует разрешение.')), 403

    photo = Photo.query.get_or_404(photo_id)
    if current_user.is_collecting(photo):
        return jsonify(message=_l('Уже в коллекции.')), 400

    current_user.collect(photo)
    if current_user != photo.author and photo.author.receive_collect_notification:
        push_collect_notification(collector=current_user,
                                  photo_id=photo_id,
                                  receiver=photo.author)
    return jsonify(message=_l('Фото в коллекции.'))
Example #5
0
def collect(photo_id):
    if not current_user.is_authenticated:
        return jsonify(message='Требуется войти в свою учетную запись'), 403
    if not current_user.confirmed:
        return jsonify(
            message='Требуется подтверждение регистрации аккаунта'), 400
    if not current_user.can('COLLECT'):
        return jsonify(message='Доступ запрещен'), 403

    photo = Photo.query.get_or_404(photo_id)
    if current_user.is_collecting(photo):
        return jsonify(message='Уже добавлено в коллекцию'), 400

    current_user.collect(photo)
    if current_user != photo.author and photo.author.receive_collect_notification:
        push_collect_notification(collector=current_user,
                                  photo_id=photo_id,
                                  receiver=photo.author)
    return jsonify(message='Фото в коллекции')