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


Python Event.get方法代码示例

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


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

示例1: enroll

# 需要导入模块: from app.models import Event [as 别名]
# 或者: from app.models.Event import get [as 别名]
def enroll(evt_id):
	user = helpers.current_user()
	event = Event.get(evt_id)

	if not event:
		return abort(404)
	if not user:
		return abort(403)

	form = EventEnrollmentForm()

	if form.validate_on_submit():
		enrollment = EventEnrollment.filter_by(
			user_id=user.id,
			event_id=event.id
		).first()

		if enrollment:
			flash('You are already enrolled to this event', category='danger')
		else:
			new_enrollment = EventEnrollment(user_id=user.id, event_id=event.id,
				reason=form.reason.data)
			new_enrollment.save(commit=True)
			flash('You successfully enrolled to the event "%s"' % event.title, category='success')

		return redirect(url_for('events.show', evt_id=event.id))

	return render_template('events/enrollment.html.j2', event=event, form=form)
开发者ID:PeterCP,项目名称:Genera-Flask,代码行数:30,代码来源:events.py

示例2: show

# 需要导入模块: from app.models import Event [as 别名]
# 或者: from app.models.Event import get [as 别名]
def show(evt_id):
	event = Event.get(evt_id)

	if not event:
		return abort(404)

	return render_template('events/show.html.j2', event=event,
		can_edit=helpers.current_user() == event.publisher)
开发者ID:PeterCP,项目名称:Genera-Flask,代码行数:10,代码来源:events.py

示例3: attendance

# 需要导入模块: from app.models import Event [as 别名]
# 或者: from app.models.Event import get [as 别名]
def attendance(evt_id):
	user = helpers.current_user()
	event = Event.get(evt_id)

	if not event:
		return abort(404)
	if not user or user != event.publisher:
		return abort(403)

	form = EventAttendanceForm(data=dict(
		attendant_ids=[u.id for u in event.attendants]
	))
	form.attendant_ids.choices = [(user.id, user.full_name) for user in User.all()]

	if form.validate_on_submit():
		new_attendance_list = [User.get(user_id) for user_id in form.attendant_ids.data]
		event.attendants = new_attendance_list
		event.save(commit=True)
		flash('Event attendance registered successfully', category='success')
		return redirect(url_for('events.show', evt_id=evt_id))

	return render_template('events/attendance.html.j2', form=form, evt_id=event.id)
开发者ID:PeterCP,项目名称:Genera-Flask,代码行数:24,代码来源:events.py


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