コード例 #1
0
ファイル: event.py プロジェクト: dineshk22/hacknight
def event_new(profile):
    if profile.userid not in g.user.user_organizations_owned_ids():
        abort(403)
    form = EventForm(parent=profile, model=Event)
    if form.validate_on_submit():
        event = Event(profile=profile)
        form.populate_obj(event)
        if not event.name:
            event.make_name()
        db.session.add(event)
        participant = Participant(user=g.user,
                                  event=event,
                                  status=PARTICIPANT_STATUS.CONFIRMED)
        db.session.add(participant)
        db.session.commit()
        flash(u"New event created", "success")
        return render_redirect(url_for('event_view',
                                       profile=profile.name,
                                       event=event.name),
                               code=303)
    return render_form(form=form,
                       title="New Event",
                       submit=u"Create",
                       cancel_url=url_for('profile_view',
                                          profile=profile.name),
                       ajax=False)
コード例 #2
0
def event_edit(profile, event):
    workflow = event.workflow()
    if not workflow.can_edit():
        abort(403)
    form = EventForm(obj=event)
    if form.venue.data:
        form.start_datetime.timezone = form.venue.data.timezone
        form.end_datetime.timezone = form.venue.data.timezone
    else:
        form.start_datetime.timezone = app.config['TIMEZONE']
        form.end_datetime.timezone = app.config['TIMEZONE']
    if form.validate_on_submit():
        old_name = event.name
        form.populate_obj(event)
        if not event.name:
            event.make_name()
        if event.name != old_name:
            redirect_to = EventRedirect.query.filter_by(name=old_name, profile=profile).first()
            if redirect_to:
                redirect_to.event = event
            else:
                redirect_to = EventRedirect(name=old_name, profile=profile, event=event)
                db.session.add(redirect_to)
        db.session.commit()
        flash(u"Your edits to %s are saved" % event.title, "success")
        return render_redirect(event.url_for(), code=303)
    return render_form(form=form, title="Edit Event", submit=u"Save",
        cancel_url=event.url_for(), ajax=False)
コード例 #3
0
ファイル: event.py プロジェクト: blackhat06/hacknight
def event_edit(profile, event):
    workflow = event.workflow()
    if not workflow.can_edit():
        abort(403)
    form = EventForm(obj=event)
    if form.validate_on_submit():
        form.populate_obj(event)
        event.make_name()
        event.profile_id = profile.id
        db.session.commit()
        flash(u"Your edits to %s are saved" % event.title, "success")
        return render_redirect(event.url_for(), code=303)
    return render_form(form=form, title="Edit Event", submit=u"Save",
        cancel_url=event.url_for(), ajax=False)
コード例 #4
0
ファイル: event.py プロジェクト: sidharthkuruvila/hacknight
def event_edit(profile, event):
    workflow = event.workflow()
    if not workflow.can_edit():
        abort(403)
    form = EventForm(obj=event)
    if form.validate_on_submit():
        form.populate_obj(event)
        if not event.name:
            event.make_name()
        event.profile_id = profile.id
        db.session.commit()
        flash(u"Your edits to %s are saved" % event.title, "success")
        return render_redirect(url_for('event_view', event=event.name, profile=profile.name), code=303)
    return render_form(form=form, title="Edit Event", submit=u"Save",
        cancel_url=url_for('event_view', event=event.name, profile=profile.name), ajax=False)
コード例 #5
0
ファイル: event.py プロジェクト: sidharthkuruvila/hacknight
def event_new(profile):
    if profile.userid not in g.user.user_organizations_owned_ids():
        abort(403)
    form = EventForm(parent=profile, model=Event)
    if form.validate_on_submit():
        event = Event(profile=profile)
        form.populate_obj(event)
        if not event.name:
            event.make_name()
        db.session.add(event)
        participant = Participant(user=g.user, event=event, status=PARTICIPANT_STATUS.CONFIRMED)
        db.session.add(participant)
        db.session.commit()
        flash(u"New event created", "success")
        return render_redirect(url_for('event_view', profile=profile.name, event=event.name), code=303)
    return render_form(form=form, title="New Event", submit=u"Create",
        cancel_url=url_for('profile_view', profile=profile.name), ajax=False)
コード例 #6
0
def event_new(profile):
    if profile.userid not in g.user.user_organizations_owned_ids():
        abort(403)
    form = EventForm(parent=profile, model=Event)
    form.start_datetime.timezone = app.config['TIMEZONE']
    form.end_datetime.timezone = app.config['TIMEZONE']
    if request.method == 'POST' and form.venue.data:
        form.start_datetime.timezone = form.venue.data.timezone
        form.end_datetime.timezone = form.venue.data.timezone

    if form.validate_on_submit():
        event = Event(profile=profile)
        form.populate_obj(event)
        if not event.name:
            event.make_name()
        db.session.add(event)
        participant = Participant(user=g.user, event=event)
        participant.status = PARTICIPANT_STATUS.CONFIRMED
        db.session.add(participant)
        db.session.commit()
        flash(u"New event created", "success")
        return render_redirect(url_for('event_view', profile=profile.name, event=event.name), code=303)
    return render_form(form=form, title="New Event", submit=u"Create",
        cancel_url=profile.url_for(), ajax=False)