예제 #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 create_event():
    form = CreateEventForm()
    if form.validate_on_submit():
        event = Event(name=form.name_event.data,
                      description=form.description.data)
        db.session.add(event)
        db.session.commit()
        if form.category1.data != "":
            category = Category(name=form.category1.data, event_id=event.id)
            db.session.add(category)
            db.session.commit()
        if form.category2.data != "":
            category = Category(name=form.category2.data, event_id=event.id)
            db.session.add(category)
            db.session.commit()
        if form.category3.data != "":
            category = Category(name=form.category3.data, event_id=event.id)
            db.session.add(category)
            db.session.commit()
        if form.category4.data != "":
            category = Category(name=form.category4.data, event_id=event.id)
            db.session.add(category)
            db.session.commit()
        if form.category5.data != "":
            category = Category(name=form.category5.data, event_id=event.id)
            db.session.add(category)
            db.session.commit()
        return render_template('event.html', form=form)
    return render_template('create_event.html', form=form)
예제 #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 __creating_events(self):
     """Создание событий"""
     # TODO: доступ только админам.
     form = CreateEventForm()
     if form.validate_on_submit():
         if self.__db_connector.validate_event(form.name.data):
             date = form.date.data
             time = form.time.data
             event_run_date = dt.datetime(date.year, date.month, date.day,
                                          time.hour, time.minute)
             new_event = Event(name=form.name.data,
                               organizer=form.organizer.data,
                               type_game=form.type_game.data,
                               mode_game=form.mode_game.data,
                               max_count_users=form.max_count_users.data,
                               current_count_users=0,
                               run_date=event_run_date,
                               duration=form.duration.data,
                               broadcast_avail=form.broadcast_avail.data,
                               record_avail=form.record_avail.data)
             self.__db_connector.register_event(new_event)
             flash("Событие создано! :)", "success")
         else:
             flash("Такая тусовка у нас уже есть!", "error")
     return render_template("creating_events.html", form=form)
예제 #5
0
def create_event():
    """ Event create view """
    form = CreateEventForm(request.form)
    if request.method == 'POST' and form.validate():
        try:
            format_string = '%Y-%m-%dT%H:%M'
            name = str(request.form['name'])
            year = int(request.form['year'])
            semester = Semester(int(request.form['semester']))
            specialslot = int(request.form['special_slots'])
            specialslotname = str(request.form['special_slots_name'])
            specialslotdescription = str(
                request.form['special_slots_description'])
            timestamp = datetime.now()
            opensignuptimestamp = datetime.strptime(
                str(request.form['open_signup_timestamp']), format_string)
            closesignuptimestamp = datetime.strptime(
                str(request.form['close_signup_timestamp']), format_string)
            place = str(request.form['place'])
            participationfee = str(request.form['participation_fee'])
            signup_open = False
            active = False

        except Exception as e:
            print(e)
            return render_template('error.html',
                                   message=str(
                                       request.form['opensignuptimestamp']))

        try:
            event = Events(name=name,
                           year=year,
                           special_slots=specialslot,
                           special_slots_name=specialslotname,
                           special_slots_description=specialslotdescription,
                           place=place,
                           semester=semester,
                           creation_timestamp=timestamp,
                           signup_open=signup_open,
                           active=active,
                           participation_fee=participationfee,
                           open_signup_timestamp=opensignuptimestamp,
                           close_signup_timestamp=closesignuptimestamp)
            db.session.add(event)
            db.session.commit()
        except Exception as e:
            print(e)
            return render_template('error.html')
        return redirect(url_for('admin'))
    return render_template('create_event.html', form=form)
예제 #6
0
def createevent():
    form = CreateEventForm()
    if form.validate_on_submit():
        event = Event(name=form.name.data,
                      addr_1=form.addr_1.data,
                      location=form.location.data,
                      datetime_start=form.datetime_start.data,
                      user_id=current_user.get_id())
        db.session.add(event)
        db.session.commit()
        flash('Congratulations, your event is been created!')
        next_page = request.args.get('next')
        if not next_page or url_parse(next_page).netloc != '':
            next_page = url_for('index')
        return redirect(next_page)
    return render_template('createevent.html', title='Create Event', form=form)
예제 #7
0
 def create_form(klass, event, request):
     """"""
     form_data = DataBuilder.form_data_from_event(event)
     if event.parent_series:
         updates = DataBuilder.form_data_from_series(event.parent_series)
         form_data.update(updates)
     form_data = klass._remove_none_fields(form_data)
     return CreateEventForm(request.form, **form_data)
예제 #8
0
def edit_event(event_id):
    """ Admin edit event, allows to do changes
        on an already created event """
    event = Events.query.get_or_404(event_id)
    form = CreateEventForm(request.form, obj=event)
    form.special_slots.data = str(int(event.special_slots))
    form.semester.data = str(event.semester.value)
    if request.method == 'POST' and form.validate():
        try:
            form.populate_obj(event)
            semester = Semester(int(request.form['semester']))
            event.special_slots = int(request.form['special_slots'])
            event.semester = semester
            db.session.commit()
        except Exception as e:
            print('Exception of type {} occurred: {}'.format(type(e), str(e)))
            return render_template('error.html')
        return redirect(request.referrer)
    return render_template('edit_event.html', form=form, event=event)
예제 #9
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)
예제 #10
0
def newEvent():

    form = CreateEventForm()
    form.venue.choices = [(v.id, v.name) for v in Venue.query.all()]
    form.artists.choices = [(a.id, a.name) for a in Artist.query.all()]
    if form.validate_on_submit():
        e = Event.query.filter_by(name=form.name.data).first()
        if e is not None:
            flash('Event already exists')
        else:
            e = Event(name=form.name.data,
                      date=form.date.data,
                      venueID=form.venue.data)
            flash('New Event Created!')
            db.session.add(e)
            db.session.commit()
            for aid in form.artists.data:
                a2e = ArtistToEvent(eventID=e.id, artistID=aid)
                db.session.add(a2e)
                db.session.commit()
            return redirect(url_for('Artists'))
    return render_template('newEvent.html', title="Create Events", form=form)
예제 #11
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)
예제 #12
0
def create():
	user = helpers.current_user()
	if not user:
		return abort(403)
	form = CreateEventForm()
	form.category_id.choices = [(ec.id, ec.name) for ec in EventCategory.all()]

	if form.validate_on_submit():
		data = dict(form.data)
		data.pop('image')
		event = Event(**data)
		event.publisher = user
		event.published_on = datetime.now()
		event.save()
		image = form.image.data
		if image:
			path = helpers.save_event_image(event, image)
			event.image_path = path
		event.save(commit=True)
		flash('Event creation successful!', category='success')
		return redirect(url_for('events.show', evt_id=event.id))

	return render_template('events/create.html.j2', form=form)