예제 #1
0
def add_event():
    form = EventForm()
    form.speakers.query_factory = speaker_query
    if form.validate_on_submit():
        address = Address(street=form.street.data, city=form.city.data, state=form.state.data, zip=form.zip.data)
        event = Event(topic=form.topic.data, date=form.date.data)
        db.session.add(event)
        db.session.commit()
        event.address = address
        for speaker in form.speakers.data:
            event.speakers.append(speaker)
        db.session.commit()
        flash("Event Saved.")
        return redirect(url_for('index'))
    return render_template('add_event.html', title='Add Event', form=form)
예제 #2
0
def create(userid):
    user = User.query.get(userid)
    data = request.get_json()
    event = Event()
    event.name = data.get('name')
    event.category = data.get('category')
    event.place = data.get('place')
    event.address = data.get('address')
    event.start_date = data.get('start_dadte')
    event.end_date = data.get('end_date')
    event.method = True if data.get('method') == 'true' else False
    event.owner = user
    db.session.add(event)
    db.session.commit()
    return jsonify(event.serialize())
예제 #3
0
    event_type = session.query(EventType).filter(
        EventType.code == event_item.get('type')).first()

    locations_list = event_item.get('location').split(', ')
    locations = session.query(Location).filter(
        Location.code.in_(locations_list)).all()

    categories_list = event_item.get('category').split(', ')
    categories = session.query(EventCategory).filter(
        EventCategory.code.in_(categories_list)).all()

    date_time_template = '{} {}'.format(event_item.get('date'),
                                        event_item.get('time'))
    date_time = datetime.datetime.strptime(date_time_template,
                                           '%d.%m.%Y %H:%M')

    event = Event()
    event.title = event_item.get('title')
    event.description = event_item.get('description')
    event.date = date_time.date()
    event.time = date_time.time()
    event.address = event_item.get('address')
    event.seats = event_item.get('seats')
    event.type = event_type
    event.locations = locations
    event.categories = categories

    session.add(event)

session.commit()