本文整理汇总了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)
示例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)
示例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)