Esempio n. 1
0
def view_event(event_id):
    e = Event(redis=g.r, user=g.user)
    e.load(event_id)
    return render_template('event.html',
        event=e,
        state=g.user.get_event_state(event_id)
    )
Esempio n. 2
0
def event_set_maybe(event_id):
    if not g.logged_in:
        abort(401)
    e = Event(redis=g.r, user=g.user)
    e.load(event_id)
    e.set_maybe()
    flash("You have been marked as maybe attending.", 'success')
    return redirect(url_for('frontend.view_event', event_id=event_id))
Esempio n. 3
0
def event_set_maybe(event_id):
    if not g.logged_in:
        abort(401)
    e = Event(redis=g.r, user=g.user)
    e.load(event_id)
    e.set_maybe()
    flash("You have been marked as maybe attending.", 'success')
    return redirect(url_for('frontend.view_event', event_id=event_id))
Esempio n. 4
0
def event_del_comment(event_id, comment_id):
    e = Event(redis=g.r, user=g.user)
    e.load(event_id)
    user = e.comment_user(comment_id)
    if user != g.user.key and e.data['creator'] != g.user.username:
        abort(401)

    e.del_comment(comment_id)
    flash("Comment has been deleted.", 'success')
    return redirect(url_for('frontend.view_event', event_id=event_id) + '#comments')
Esempio n. 5
0
def event_del_comment(event_id, comment_id):
    e = Event(redis=g.r, user=g.user)
    e.load(event_id)
    user = e.comment_user(comment_id)
    if user != g.user.key and e.data['creator'] != g.user.username:
        abort(401)

    e.del_comment(comment_id)
    flash("Comment has been deleted.", 'success')
    return redirect(
        url_for('frontend.view_event', event_id=event_id) + '#comments')
Esempio n. 6
0
def event_add_comment(event_id):
    try:
        g.user.username
    except AttributeError:
        abort(401)

    e = Event(redis=g.r, user=g.user)
    e.load(event_id)
    try:
        e.add_comment(request.form['text'])
        flash("Comment has been added.", 'success')
    except EventCommentError as detail:
        flash(detail, 'error')
    return redirect(url_for('frontend.view_event', event_id=event_id) + '#comments')
Esempio n. 7
0
def event_add_comment(event_id):
    try:
        g.user.username
    except AttributeError:
        abort(401)

    e = Event(redis=g.r, user=g.user)
    e.load(event_id)
    try:
        e.add_comment(request.form['text'])
        flash("Comment has been added.", 'success')
    except EventCommentError as detail:
        flash(detail, 'error')
    return redirect(
        url_for('frontend.view_event', event_id=event_id) + '#comments')
Esempio n. 8
0
def save_event(event_id=False, new=False):
    try:
        g.user.username
    except AttributeError:
        abort(401)

    e = Event(redis=g.r, user=g.user)

    if not new:
        try:
            e.load(event_id)
        except EventNotFoundError:
            abort(404)
        if e.data['creator'] != g.user.username:
            abort(401)

    if request.method == 'POST':
        e.update(request.form)
        try:
            image = request.files.get('image')
            if image:
                try:
                    e.data['image'] = upload_event_image(image)
                    flash("Upload successful.", 'success')
                except UploadNotAllowed:
                    flash("Upload not allowed.", 'error')
            e.save()
            if new:
                flash("Event created.", 'success')
            else:
                flash("Changes saved.", 'success')
            if new:
                return redirect(url_for('frontend.view_event', event_id=e.key))
            else:
                return redirect(url_for('frontend.edit_event', event_id=e.key))
        except EventValidationError:
            for error in e.validation_errors:
                flash(error, 'error')

    return render_template('forms/event.html',
        new=new,
        event=e
    )
Esempio n. 9
0
def del_event(event_id):
    e = Event(redis=g.r, user=g.user)
    e.load(event_id)

    try:
        if g.user.username != e.data['creator']:
            abort(401)
    except AttributeError:
        abort(401)

    if request.method == "POST":
        e.delete()
        flash('Event deleted.', 'success')
        return redirect(url_for('frontend.list_events'))
    else:
        return render_template('confirm.html',
            _message='Are you sure you wish to DELETE this thread?',
            _ok=url_for('frontend.del_event', event_id=event_id),
            _cancel=url_for('frontend.view_event', event_id=event_id)
        )
Esempio n. 10
0
def del_event(event_id):
    e = Event(redis=g.r, user=g.user)
    e.load(event_id)

    try:
        if g.user.username != e.data['creator']:
            abort(401)
    except AttributeError:
        abort(401)

    if request.method == "POST":
        e.delete()
        flash('Event deleted.', 'success')
        return redirect(url_for('frontend.list_events'))
    else:
        return render_template(
            'confirm.html',
            _message='Are you sure you wish to DELETE this thread?',
            _ok=url_for('frontend.del_event', event_id=event_id),
            _cancel=url_for('frontend.view_event', event_id=event_id))
Esempio n. 11
0
def save_event(event_id=False, new=False):
    try:
        g.user.username
    except AttributeError:
        abort(401)

    e = Event(redis=g.r, user=g.user)

    if not new:
        try:
            e.load(event_id)
        except EventNotFoundError:
            abort(404)
        if e.data['creator'] != g.user.username:
            abort(401)

    if request.method == 'POST':
        e.update(request.form)
        try:
            image = request.files.get('image')
            if image:
                try:
                    e.data['image'] = upload_event_image(image)
                    flash("Upload successful.", 'success')
                except UploadNotAllowed:
                    flash("Upload not allowed.", 'error')
            e.save()
            if new:
                flash("Event created.", 'success')
            else:
                flash("Changes saved.", 'success')
            if new:
                return redirect(url_for('frontend.view_event', event_id=e.key))
            else:
                return redirect(url_for('frontend.edit_event', event_id=e.key))
        except EventValidationError:
            for error in e.validation_errors:
                flash(error, 'error')

    return render_template('forms/event.html', new=new, event=e)
Esempio n. 12
0
def view_event(event_id):
    e = Event(redis=g.r, user=g.user)
    e.load(event_id)
    return render_template('event.html',
                           event=e,
                           state=g.user.get_event_state(event_id))