Beispiel #1
0
def statusize():
    """Posts a status from the web."""
    email = session.get('email')
    if not email:
        return forbidden('You must be logged in to statusize!')

    user = User.query.filter(User.email == email).first()

    if not user:
        return forbidden('You must have a user account to statusize!')

    message = request.form.get('message', '')

    if not message:
        return page_not_found('You cannot statusize nothing!')

    status = Status(user_id=user.id, content=message, content_html=message)

    project = request.form.get('project', '')
    if project:
        project = Project.query.filter_by(id=project).first()
        if project:
            status.project_id = project.id

    # TODO: reply handling

    db.session.add(status)
    db.session.commit()

    # Try to go back from where we came.
    redirect_url = request.form.get('redirect_to',
        request.headers.get('referer',
            url_for('status.index')))
    return redirect(redirect_url)
Beispiel #2
0
def profile():
    """Shows the user's profile page."""
    email = session.get('email')
    if not email:
        return forbidden('You must be logged in to see a profile!')

    user = User.query.filter(User.email == email).first()

    if not user:
        return forbidden('You must have a user account to see your profile!')

    return render_template(
        'profile.html',
        user=user,
        statuses=user.recent_statuses())
Beispiel #3
0
def statusize():
    """Posts a status from the web."""
    db = get_session(current_app)

    user_id = session.get('user_id')
    if not user_id:
        return forbidden('You must be logged in to statusize!')

    user = db.query(User).get(user_id)

    message = request.form.get('message', '')

    if not message:
        return page_not_found('You cannot statusize nothing!')

    status = Status(user_id=user.id, content=message, content_html=message)

    project = request.form.get('project', '')
    if project:
        project = db.query(Project).filter_by(id=project).first()
        if project:
            status.project_id = project.id

    # TODO: reply handling

    db.add(status)
    db.commit()

    # Try to go back from where we came.
    referer = request.headers.get('referer', url_for('status.index'))
    redirect_url = request.form.get('redirect_to', referer)
    return redirect(redirect_url)
Beispiel #4
0
def statusize():
    """Posts a status from the web."""
    db = get_session(current_app)

    user_id = session.get('user_id')
    if not user_id:
        return forbidden('You must be logged in to statusize!')

    user = db.query(User).get(user_id)

    message = request.form.get('message', '')

    if not message:
        return page_not_found('You cannot statusize nothing!')

    status = Status(user_id=user.id, content=message, content_html=message)

    project = request.form.get('project', '')
    if project:
        project = db.query(Project).filter_by(id=project).first()
        if project:
            status.project_id = project.id

    # TODO: reply handling

    db.add(status)
    db.commit()

    # Try to go back from where we came.
    referer = request.headers.get('referer', url_for('status.index'))
    redirect_url = request.form.get('redirect_to', referer)
    return redirect(redirect_url)
Beispiel #5
0
def profile():
    """Shows the user's profile page."""
    db = get_session(current_app)

    user_id = session.get('user_id')
    if not user_id:
        return forbidden('You must be logged in to see a profile!')

    user = db.query(User).get(user_id)

    if request.method == 'POST':
        data = request.form
    else:
        data = MultiDict(user.dictify())

    form = ProfileForm(data)

    if request.method == 'POST' and form.validate():
        user.name = data['name']
        user.username = data['username']
        user.slug = data['username']
        user.github_handle = data['github_handle']
        db.add(user)
        db.commit()
        flash('Your profile was updated.', 'success')

    return render_template('users/profile.html', form=form)
Beispiel #6
0
def profile():
    """Shows the user's profile page."""
    db = get_session(current_app)

    user_id = session.get('user_id')
    if not user_id:
        return forbidden('You must be logged in to see a profile!')

    user = db.query(User).get(user_id)

    if request.method == 'POST':
        data = request.form
    else:
        data = MultiDict(user.dictify())

    form = ProfileForm(data)

    if request.method == 'POST' and form.validate():
        user.name = data['name']
        user.username = data['username']
        user.slug = data['username']
        user.github_handle = data['github_handle']
        db.add(user)
        db.commit()
        flash('Your profile was updated.', 'success')

    return render_template('users/profile.html', form=form)