예제 #1
0
def create():
    """Create a new event.

    **Route:** ``/admin/events/create``

    **Methods:** ``GET, POST``
    """

    form = CreateEventForm(request.form)
    if form.validate_on_submit():
        try:
            EventsHelper.create_event(form, g.user)
        except EventumError.GCalAPI as e:
            flash(e.message, ERROR_FLASH)

        return redirect(url_for('.index'))
    if form.errors:
        for error in form.errors:
            for message in form.errors[error]:
                flash(message, ERROR_FLASH)

    upload_form = UploadImageForm()
    delete_form = DeleteEventForm()
    images = Image.objects()
    return render_template('admin/events/create.html',
                           form=form,
                           delete_form=delete_form,
                           upload_form=upload_form,
                           images=images)
예제 #2
0
def edit(event_id):
    """"""
    try:
        event = Event.objects().get(id=event_id)
    except (DoesNotExist, ValidationError):
        flash('Cannont find event with id "%s"' % event_id)
        return redirect(url_for('.index'))

    form = EditEventForm(request.form) if request.method == 'POST' else \
        EventsHelper.create_form(event, request)

    if form.validate_on_submit():
        try:
            EventsHelper.update_event(event, form)
        except GoogleCalendarAPIError as e:
            flash(e.message)

        return redirect(url_for('.index'))
    if form.errors:
        for error in form.errors:
            for message in form.errors[error]:
                flash(message)

    delete_form = DeleteEventForm()
    upload_form = UploadImageForm()
    images = Image.objects()

    return render_template('admin/events/edit.html',
                           form=form,
                           event=event,
                           delete_form=delete_form,
                           upload_form=upload_form,
                           images=images)
예제 #3
0
def create():
    """Create a new event.

    **Route:** ``/admin/events/create``

    **Methods:** ``GET, POST``
    """

    form = CreateEventForm(request.form)
    if form.validate_on_submit():
        try:
            EventsHelper.create_event(form, g.user)
        except EventumError.GCalAPI as e:
            flash(e.message, ERROR_FLASH)

        return redirect(url_for('.index'))
    if form.errors:
        for error in form.errors:
            for message in form.errors[error]:
                flash(message, ERROR_FLASH)

    upload_form = UploadImageForm()
    delete_form = DeleteEventForm()
    images = Image.objects()
    return render_template('admin/events/create.html', form=form,
                           delete_form=delete_form, upload_form=upload_form,
                           images=images)
예제 #4
0
def edit(event_id):
    """"""
    try:
        event = Event.objects().get(id=event_id)
    except (DoesNotExist, ValidationError):
        flash('Cannont find event with id "%s"' % event_id)
        return redirect(url_for('.index'))

    form = EditEventForm(request.form) if request.method == 'POST' else \
        EventsHelper.create_form(event, request)

    if form.validate_on_submit():
        try:
            EventsHelper.update_event(event, form)
        except GoogleCalendarAPIError as e:
            flash(e.message)

        return redirect(url_for('.index'))
    if form.errors:
        for error in form.errors:
            for message in form.errors[error]:
                flash(message)

    delete_form = DeleteEventForm()
    upload_form = UploadImageForm()
    images = Image.objects()

    return render_template('admin/events/edit.html', form=form, event=event,
                           delete_form=delete_form, upload_form=upload_form,
                           images=images)
예제 #5
0
def delete(event_id):
    """"""
    object_id = ObjectId(event_id)
    form = DeleteEventForm(request.form)
    if Event.objects(id=object_id).count() == 1:
        event = Event.objects().with_id(object_id)
        try:
            EventsHelper.delete_event(event, form)
        except GoogleCalendarAPIError as e:
            flash(e.message)
    else:
        flash('Invalid event id')
    return redirect(url_for('.index'))
예제 #6
0
def delete(event_id):
    """"""
    object_id = ObjectId(event_id)
    form = DeleteEventForm(request.form)
    if Event.objects(id=object_id).count() == 1:
        event = Event.objects().with_id(object_id)
        try:
            EventsHelper.delete_event(event, form)
        except GoogleCalendarAPIError as e:
            flash(e.message)
    else:
        flash('Invalid event id')
    return redirect(url_for('.index'))
예제 #7
0
def delete(event_id):
    """Delete an existing event.

    **Route:** ``/admin/events/delete/<event_id>``

    **Methods:** ``POST``

    :param str event_id: The ID of the event to delete.
    """
    object_id = ObjectId(event_id)
    form = DeleteEventForm(request.form)
    if Event.objects(id=object_id).count() == 1:
        event = Event.objects().with_id(object_id)
        try:
            EventsHelper.delete_event(event, form)
        except EventumError.GCalAPI as e:
            flash(e.message, ERROR_FLASH)
    else:
        flash('Invalid event id', ERROR_FLASH)
    return redirect(url_for('.index'))
예제 #8
0
def delete(event_id):
    """Delete an existing event.

    **Route:** ``/admin/events/delete/<event_id>``

    **Methods:** ``POST``

    :param str event_id: The ID of the event to delete.
    """
    object_id = ObjectId(event_id)
    form = DeleteEventForm(request.form)
    if Event.objects(id=object_id).count() == 1:
        event = Event.objects().with_id(object_id)
        try:
            EventsHelper.delete_event(event, form)
        except EventumError.GCalAPI as e:
            flash(e.message, ERROR_FLASH)
    else:
        flash('Invalid event id', ERROR_FLASH)
    return redirect(url_for('.index'))
예제 #9
0
def edit(event_id):
    """Edit an existing event.

    **Route:** ``/admin/events/edit/<event_id>``

    **Methods:** ``GET, POST``

    :param str event_id: The ID of the event to edit.
    """

    try:
        event = Event.objects().get(id=event_id)
    except (DoesNotExist, ValidationError):
        flash('Cannot find event with id "{}"'.format(event_id), ERROR_FLASH)
        return redirect(url_for('.index'))

    form = EditEventForm(event, request.form) if request.method == 'POST' else \
        EventsHelper.create_form(event, request)

    if form.validate_on_submit():
        try:
            EventsHelper.update_event(event, form)
        except EventumError.GCalAPI as e:
            flash(e.message, ERROR_FLASH)

        return redirect(url_for('.index'))
    if form.errors:
        for error in form.errors:
            for message in form.errors[error]:
                flash(message, ERROR_FLASH)

    delete_form = DeleteEventForm()
    upload_form = UploadImageForm()
    images = Image.objects()

    return render_template('admin/events/edit.html',
                           form=form,
                           event=event,
                           delete_form=delete_form,
                           upload_form=upload_form,
                           images=images)
예제 #10
0
def create():
    """"""
    form = CreateEventForm(request.form)
    if form.validate_on_submit():
        try:
            EventsHelper.create_event(form, g.user)
        except GoogleCalendarAPIError as e:
            flash(e.message)

        return redirect(url_for('.index'))
    if form.errors:
        for error in form.errors:
            for message in form.errors[error]:
                flash(message)

    upload_form = UploadImageForm()
    delete_form = DeleteEventForm()
    images = Image.objects()
    return render_template('admin/events/create.html', form=form,
                           delete_form=delete_form, upload_form=upload_form,
                           images=images)
예제 #11
0
def edit(event_id):
    """Edit an existing event.

    **Route:** ``/admin/events/edit/<event_id>``

    **Methods:** ``GET, POST``

    :param str event_id: The ID of the event to edit.
    """

    try:
        event = Event.objects().get(id=event_id)
    except (DoesNotExist, ValidationError):
        flash('Cannot find event with id "{}"'.format(event_id), ERROR_FLASH)
        return redirect(url_for('.index'))

    form = EditEventForm(event, request.form) if request.method == 'POST' else \
        EventsHelper.create_form(event, request)

    if form.validate_on_submit():
        try:
            EventsHelper.update_event(event, form)
        except EventumError.GCalAPI as e:
            flash(e.message, ERROR_FLASH)

        return redirect(url_for('.index'))
    if form.errors:
        for error in form.errors:
            for message in form.errors[error]:
                flash(message, ERROR_FLASH)

    delete_form = DeleteEventForm()
    upload_form = UploadImageForm()
    images = Image.objects()

    return render_template('admin/events/edit.html', form=form, event=event,
                           delete_form=delete_form, upload_form=upload_form,
                           images=images)
예제 #12
0
def create():
    """"""
    form = CreateEventForm(request.form)
    if form.validate_on_submit():
        try:
            EventsHelper.create_event(form, g.user)
        except GoogleCalendarAPIError as e:
            flash(e.message)

        return redirect(url_for('.index'))
    if form.errors:
        for error in form.errors:
            for message in form.errors[error]:
                flash(message)

    upload_form = UploadImageForm()
    delete_form = DeleteEventForm()
    images = Image.objects()
    return render_template('admin/events/create.html',
                           form=form,
                           delete_form=delete_form,
                           upload_form=upload_form,
                           images=images)