Beispiel #1
0
def unsubscribe(feed):
    """
    Unsubscribe user from given feed
    :param feed: feed to unsubscribe from
    :return:
    """
    current_user.unsubscribe(feed)
    return redirect(feed.route)
Beispiel #2
0
def unsubscribe_event(event_id):
    is_user_subscribed = UserEvents.query.filter_by(user_id=current_user.id,
                                                    event_id=event_id).first()
    if is_user_subscribed:
        current_user.unsubscribe(event_id=event_id)
        return redirect(url_for('event.index'))
    else:
        return redirect(url_for('event.index'))
Beispiel #3
0
def subscription():
    subscription_id = int(request.form['id'])
    if current_user.is_anonymous:
        return "failure", 500
    elif current_user.is_subscribed(subscription_id):
        current_user.unsubscribe(subscription_id)
    else:
        current_user.subscribe(subscription_id)
    return "success", 200
Beispiel #4
0
def unsubscribe():
    user_id = int(request.form['user_id'])
    source_id = int(request.form['source_id'])
    if current_user.id != user_id:
        abort(404)
    if current_user.is_subscribed(source_id):
        current_user.unsubscribe(source_id)
        return jsonify(source_id=source_id, user_id=user_id)
    abort(404)
def subscribe(tag, post_title, action):
    tag = Tags.query.filter_by(tag=tag).first_or_404()
    post = Posts.query.filter_by(title=post_title, tag=tag).first_or_404()
    if action == 'subscribe':
        current_user.subscribe(post)
        db.session.commit()
    elif action == 'unsubscribe':
        current_user.unsubscribe(post)
        db.session.commit()
    return redirect(request.referrer)
Beispiel #6
0
def unsubscribe(feed_id):
    feed = Feed.query.filter_by(id=feed_id).first_or_404()
    user = User.query.filter_by(id=feed.owner_id).first()
    if user.id == current_user.id:
        flash('You cannot unfollow yourself!')
        return redirect(url_for('feeds', user=user))
    current_user.unsubscribe(feed)
    db.session.commit()
    flash('You have unsubscribed from {} feed.'.format(feed.name))
    return redirect(url_for('feeds', user=user))
Beispiel #7
0
def unsubscribe(id):
    topic = Topic.query.filter_by(id=id).first()
    if topic is None:
        flash('Invalid topic.')
        return redirect(url_for('main.index'))
    if not current_user.is_subscribed(topic):
        flash('You are already not subscribed.')
        return redirect(url_for('main.index'))
    current_user.unsubscribe(topic)
    return redirect(url_for('main.topic', name=topic.name))
Beispiel #8
0
def unsubscribe(id):
    event = Event.query.filter_by(id=id).first()
    if event is None:
        flash('Event not found.')
        return redirect(url_for('index'))
    if not current_user.is_subscribed(event):
        flash('You are already unsubscribed')
        return redirect(url_for('event', id=id))
    current_user.unsubscribe(event)
    db.session.commit()
    flash('You are now unsubscribed to {}'.format(event.title))
    return redirect(url_for('event', id=id))
Beispiel #9
0
def unsubscribe(username):
    form = EmptyForm()
    if form.validate_on_submit():
        user = User.query.filter_by(username=username).first()
        if user is None:
            flash('User {} not found.'.format(username))
            return redirect(url_for('index'))
        if user == current_user:
            flash('You cannot unsubscribe yourself!')
            return redirect(url_for('user', username=username))
        current_user.unsubscribe(user)
        db.session.commit()
        flash('You are not subscribing {}.'.format(username))
        return redirect(url_for('user', username=username))
    else:
        return redirect(url_for('index'))
Beispiel #10
0
def post_deactivate():
    pw_form = PasswordForm()
    email_form = EmailForm()
    email_form.fill(current_user)
    deactivate_form = DeactivateForm()

    if deactivate_form.validate(current_user):
        for feed in current_user.subscribed_feeds():
            current_user.unsubscribe(feed)
        User.destroy(current_user.id)
        current_user.logout()
        flash("You account was successfully deactivated", "success")
        redirect("/")

    return render_template(
        "settings-account.html",
        pw_form=pw_form,
        email_form=email_form,
        deactivate_form=deactivate_form,
    )
Beispiel #11
0
def unsubscribe(_id):
    """
	Removes a subscription to specified_room by current_user
	Removes a subscriber to specified_room by current_user
	"""
    try:
        room = Room.query.filter_by(id=_id).first()
    except:
        room = None
    if room is not None:
        try:
            current_user.unsubscribe(room)
            db.session.commit()
        except Exception as e:
            db.session.rollback()
            logging.error(f"{e}")
            return ErrorController.error(e)
        return redirect(url_for("routes.show_room", name=room.name))
    flash(u"Room: {id} doesn't exist".format(id=_id))
    return redirect(url_for("routes.index"))
Beispiel #12
0
def unsubscribe():
    form = UnsubscribeForm()
    if form.validate_on_submit():
        current_user.unsubscribe(form.channel_id.data)
        db.session.commit()
        return redirect(url_for(form.return_to.data))
Beispiel #13
0
def unsubscribe():
    form = UnsubscribeForm()
    if form.validate_on_submit():
        current_user.unsubscribe(form.channel_id.data)
        db.session.commit()
        return redirect(url_for(form.return_to.data))