当前位置: 首页>>代码示例>>Python>>正文


Python EventForm.validate_on_submit方法代码示例

本文整理汇总了Python中forms.EventForm.validate_on_submit方法的典型用法代码示例。如果您正苦于以下问题:Python EventForm.validate_on_submit方法的具体用法?Python EventForm.validate_on_submit怎么用?Python EventForm.validate_on_submit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在forms.EventForm的用法示例。


在下文中一共展示了EventForm.validate_on_submit方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: event_create

# 需要导入模块: from forms import EventForm [as 别名]
# 或者: from forms.EventForm import validate_on_submit [as 别名]
def event_create():
    form = EventForm()
    if request.method == 'POST':
        if form.validate_on_submit():
            event = Event(
                title = form.title.data,
                title_cal = form.title_cal.data,
                content = form.content.data,
                host = form.host.data,
                category_char = form.category_char.data,
                category_host = form.category_host.data,
                date_start = form.date_start.data,
                date_end = form.date_end.data,
                location = form.location.data,
                link = form.link.data,
                poster = form.poster.data,
                contact = form.contact.data,
                contact_open = form.contact_open.data,
            )

            db.session.add(event)
            db.session.commit()

            flash(u'이벤트를 등록했습니다.', 'success')
            return redirect(url_for('event_list'))

    return render_template('event/create.html', form=form)
开发者ID:DongsikHan,项目名称:Calendar,代码行数:29,代码来源:views.py

示例2: add_event

# 需要导入模块: from forms import EventForm [as 别名]
# 或者: from forms.EventForm import validate_on_submit [as 别名]
def add_event():
  if g.user is None:
    return redirect(url_for("index"))

  form = EventForm()
  if form.validate_on_submit():
    what = form.what.data
    where = form.where.data
    length = form.length.data
    wait_time = form.wait_time.data
    pre_delay = form.pre_delay.data
    required_people = form.required_people.data
    description = form.description.data
    if form.public.data:
      public = 1
    else:
      public = 0
    event = models.Event(what=what, where=where, length=length, wait_time=wait_time, pre_delay=pre_delay, required_people=required_people, description=description, public=public)
    db.session.add(event)
    db.session.commit()
    user = models.User.query.get(g.user['id'])
    event_req = models.EventSubscription(user=user, event=event)
    db.session.add(event_req)
    db.session.commit()
    flash("Event successfully created")
    return redirect(url_for("event", id=event.id))
  return render_template("add_event.html", app_id=FB_APP_ID, name=FB_APP_NAME, user = g.user, form=form) 
开发者ID:SebastianMerz,项目名称:together,代码行数:29,代码来源:views.py

示例3: event_examples

# 需要导入模块: from forms import EventForm [as 别名]
# 或者: from forms.EventForm import validate_on_submit [as 别名]
def event_examples():
    """List all events"""
    event = Event.query()
    form = EventForm()
    if form.validate_on_submit():
        event = Event(
            #event_id=
            title=form.title.data,
            day=form.day.data,
            location=form.location.data,
            description=form.descrtiption.data,
            anchor_amount=form.anchor_amount.data,
            amount_min=form.amount_min.data,
            max_attendees=form.max_attendees.data,
            registration_start=form.registration_start.data,
            registration_end=form.registration_end.data,
            added_by=users.get_current_user()
        )
        try:
            event.put()
            event_id = event.key.id()
            flash(u'Event %s successfully saved.' % event_id, 'success')
            return redirect(url_for('event_examples'))
        except CapabilityDisabledError:
            flash(u'App Engine Datastore is currently in read-only mode.', 'info')
            return redirect(url_for('event_examples'))
    return render_template('event_gae.html', event=event, form=form)
开发者ID:meyilmaz,项目名称:rsvplus,代码行数:29,代码来源:views.py

示例4: event_new

# 需要导入模块: from forms import EventForm [as 别名]
# 或者: from forms.EventForm import validate_on_submit [as 别名]
def event_new():
    '''Add a new Event.'''
    user = g.user
    if user.is_director or user.is_admin:
        form = EventForm()
        bands = [(band.id, band.name) for band in Band.query.all()]
        event_types = [(typ.id, typ.name) for typ in EventType.query.all()]
        form.band_id.choices = bands
        form.event_type_id.choices = event_types

        if form.validate_on_submit():
            date = form.date.data
            time = form.calltime.data
            calltime = datetime(year=date.year,
                                month=date.month,
                                day=date.day,
                                hour=time.hour,
                                minute=time.minute)
            band_id = form.band_id.data
            event_type_id = form.event_type_id.data
            opponent = form.opponent.data
            event_id = add_event(date=date, calltime=calltime, band_id=band_id,
                                 event_type_id=event_type_id, opponent=opponent)
            return redirect(url_for('event', event_id=event_id))

        return render_template('event/create_update.html', form=form, user=user)
    abort(404)
开发者ID:kevana,项目名称:ummbNet,代码行数:29,代码来源:views.py

示例5: create

# 需要导入模块: from forms import EventForm [as 别名]
# 或者: from forms.EventForm import validate_on_submit [as 别名]
def create():
    logging.info("create start")
    form = EventForm()

    if request.method == 'POST':
        logging.info("Method: POST")
        if form.validate_on_submit():
            event = Event(
                title = form.title.data,
                title_cal = form.title_cal.data,
                content = form.content.data,
                host = form.host.data,
                category_char = form.category_char.data,
                category_host = form.category_host.data,
                date_start = form.date_start.data,
                date_end = form.date_end.data,
                location = form.location.data,
                link = form.link.data,
                poster = form.poster.data,
                contact = form.contact.data,
                contact_open = form.contact_open.data,
            )
            print event
            logging.info("");    

            db.session.add(event)
            db.session.commit()
            
            print "11111111"
            logging.info("");  

            flash(u'이벤트를 등록했습니다.', 'success')

    return redirect(url_for('index'))
开发者ID:DongsikHan,项目名称:Calendar,代码行数:36,代码来源:views.py

示例6: create_event

# 需要导入模块: from forms import EventForm [as 别名]
# 或者: from forms.EventForm import validate_on_submit [as 别名]
def create_event():
    user = g.user
    if not user.is_admin():
        return redirect(url_for('dashboard')) 
    form = EventForm()
    event = Event() 
    if form.validate_on_submit():
        event = Event(user_id = user.id, name = request.form.get('name'), description = request.form.get('description'), starttime = request.form.get('starttime'), endtime = request.form.get('endtime'), location = request.form.get('location'), max_team = request.form.get('max_team'), max_member_per_team = request.form.get('max_member_per_team'), department = request.form.get('department'))
        sqldb.session.add(event)
        sqldb.session.commit()
        return redirect(url_for('event', event_id = event.id))
    return render_template("event.html", form = form, event = event)
开发者ID:fengjiawei2011,项目名称:hackathonapp,代码行数:14,代码来源:views.py

示例7: edit_event

# 需要导入模块: from forms import EventForm [as 别名]
# 或者: from forms.EventForm import validate_on_submit [as 别名]
def edit_event(event_id):
	event = Event.query.get(event_id)
	form = EventForm(obj=event)
	if form.validate_on_submit():
		event.name = unicode(form.name.data)
		event.description = unicode(form.description.data)
		event.registration_opens = form.registration_opens.data
		event.registration_closes = form.registration_closes.data
		db_session.add(event)
		db_session.commit()
		return redirect(url_for('show_event', event_id=event.id))
	return render_template("admin/edit_event.html", **locals()) 
开发者ID:miku,项目名称:evreg,代码行数:14,代码来源:app.py

示例8: create_event

# 需要导入模块: from forms import EventForm [as 别名]
# 或者: from forms.EventForm import validate_on_submit [as 别名]
def create_event():
	form = EventForm()
	if form.validate_on_submit():
		event = Event()
		event.name = unicode(form.name.data)
		event.description = unicode(form.description.data)
		event.registration_opens = form.registration_opens.data
		event.registration_closes = form.registration_closes.data
		db_session.add(event)
		db_session.commit()
		return redirect(url_for('dashboard'))
	return render_template("admin/create_event.html", form=form)
开发者ID:miku,项目名称:evreg,代码行数:14,代码来源:app.py

示例9: event_update

# 需要导入模块: from forms import EventForm [as 别名]
# 或者: from forms.EventForm import validate_on_submit [as 别名]
def event_update(id):
    event = Event.query.get(id)
    form = EventForm(request.form, obj=event)
    if request.method == 'POST':
        if form.validate_on_submit():
            form.populate_obj(event)
            db.session.commit()
        
            flash(u'이벤트 정보를 수정하였습니다.', 'success')
            return redirect(url_for('event_list'))

    return render_template('event/update.html', form=form)
开发者ID:DongsikHan,项目名称:Calendar,代码行数:14,代码来源:views.py

示例10: createEvent

# 需要导入模块: from forms import EventForm [as 别名]
# 或者: from forms.EventForm import validate_on_submit [as 别名]
def createEvent():
    form = EventForm()
    def add_event(name, category, time, location):
        event = Event(name=name, category=category, time=time, location=location)
        sqldb.session.add(event)
        sqldb.session.commit()
        return event.id
    if form.validate_on_submit():
        eventId = add_event(form.name.data, form.category.data, form.time.data, form.location.data)
        #flash('Event Created.' + " Event ID: " + str(eventId))
        return redirect("addStep/"+str(eventId))

    return render_template("createEvent.html", form=form)
开发者ID:any027,项目名称:EventPlanner,代码行数:15,代码来源:views.py

示例11: family_group_add

# 需要导入模块: from forms import EventForm [as 别名]
# 或者: from forms.EventForm import validate_on_submit [as 别名]
def family_group_add(fg_id):
	if request.method == 'GET':
		form = EventForm(request.args)
	else:
		form = EventForm(coerce=int)

	if form.validate_on_submit():
		event = SmallGroupEvent(name=form.name.data, description=form.description.data, weekNumber=form.week.data, quarter=form.quarter.data, small_group_id=fg_id)
		db.session.add(event)
		db.session.commit()
		flash(('Event added successfully.'))
		return redirect(url_for('family_group_leader_manage', fg_id=fg_id))

	return render_template("smallgroup/add.html", user=g.user, form=form, fg_id=fg_id)
开发者ID:phouse512,项目名称:arkaios,代码行数:16,代码来源:app.py

示例12: event_update

# 需要导入模块: from forms import EventForm [as 别名]
# 或者: from forms.EventForm import validate_on_submit [as 别名]
def event_update(event_id):
    form = EventForm()
    if form.validate_on_submit():
        do_update_event(event_id, form)
        if form.token.data != database.Event(event_id).token:
            flash("Invalid token.")
            return redirect(url_for("event_admin", event_id=event_id))

        return redirect(url_for('event_index', event_id=event_id))
    else:
        flash("There's been errors validating your request. Look below for details.")
        #for field, errors in form.errors.items():
        #    for error in errors:
        #        flash(field + " " + error)
        return render_template("event_edit.html", event=database.Event(event_id), form=form)
开发者ID:zardoru,项目名称:becgi,代码行数:17,代码来源:app.py

示例13: update_event

# 需要导入模块: from forms import EventForm [as 别名]
# 或者: from forms.EventForm import validate_on_submit [as 别名]
def update_event(id):
    db_session = db.get_session()

    form = EventForm()
    event = db_session.query(Event).get(id)

    form.id.data = event.id
    form.populate_obj(event)

    if form.validate_on_submit():
        db_session.add(event)
        db_session.commit()
        return redirect('events')
    else:
        return render_template('events/edit.html', event=event, form=form)
开发者ID:jiffyclub,项目名称:admintool,代码行数:17,代码来源:app.py

示例14: create_event

# 需要导入模块: from forms import EventForm [as 别名]
# 或者: from forms.EventForm import validate_on_submit [as 别名]
def create_event():
    '''Create the event the user posted'''
    form = EventForm(request.form)
        
    #only create the event if they entered in a name for it
    if not form.validate_on_submit():
        return render_template('events.html', user=g.user, form=form, 
                             message='Please enter name for event')
    
    #user can't create two events with the same name
    elif Event.query.filter(
               Event.name == form.name.data and Event.creator == g.user.id
               ).first():
        return render_template('events.html', user=g.user, form=form,
                             message='Event name already exists.')
    else:
        db_utilities.create_event(event_name = form.name.data, user_id = g.user.id)
        return redirect(url_for('events'))
开发者ID:samf2147,项目名称:WhoKnowsWhat,代码行数:20,代码来源:routes.py

示例15: edit_event

# 需要导入模块: from forms import EventForm [as 别名]
# 或者: from forms.EventForm import validate_on_submit [as 别名]
def edit_event(event_id):
    event = Event.get_by_id(event_id)
    form = EventForm(obj=example)
    if request.method == "POST":
        if form.validate_on_submit():
            event.title=form.data.get('title')
            event.day=form.data.get('day')
            event.location=form.data.get('location')
            event.description=form.data.get('descrtiption')
            event.anchor_amount=form.data.get('anchor_amount')
            event.amount_min=form.data.get('amount_min')
            event.max_attendees=form.data.get('max_attendees')
            event.registration_start=form.data.get('registration_start')
            event.registration_end=form.data.get('registration_end')
            
            event.put()
            flash(u'Event %s successfully saved.' % event_id, 'success')
            return redirect(url_for('event_examples'))
    return render_template('edit_event.html', event=event, form=form)
开发者ID:meyilmaz,项目名称:rsvplus,代码行数:21,代码来源:views.py


注:本文中的forms.EventForm.validate_on_submit方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。