コード例 #1
0
ファイル: event.py プロジェクト: iambibhas/hacknight
def event_apply(profile, event):
    workflow = event.workflow()
    if not workflow.can_apply():
        flash("Hacknight is not accepting participants now, please try after sometime.")
        return render_redirect(event.url_for())
    values = {'profile': profile.name, 'event': event.name}
    participant = Participant.get(g.user, event)
    if not participant:
        # If no participant is found create a new participant entry
        # First collect some information about the new participant
        user = g.user
        form = ParticipantForm(obj=user)
        if form.validate_on_submit():
            total_participants = Participant.query.filter_by(event_id=event.id).count()
            participant = Participant(user=user, event=event)
            form.populate_obj(participant)
            participant.save_defaults()
            participant.status = PARTICIPANT_STATUS.PENDING if event.maximum_participants < total_participants else PARTICIPANT_STATUS.WL
            db.session.add(participant)
            db.session.commit()
            flash(u"Your request to participate has been recorded; you will be notified by the event manager", "success")
        else:
            return render_form(form=form, message=Markup(event.apply_instructions) if event.apply_instructions else "",
                title="Participant Details", submit=u"Participate",
                cancel_url=event.url_for(), ajax=False)
    # FIXME: Don't change anything unless this is a POST request
    elif participant.status == PARTICIPANT_STATUS.WITHDRAWN:
        participant.status = PARTICIPANT_STATUS.PENDING
        db.session.commit()
        flash(u"Your request to participate has been recorded; you will be notified by the event manager", "success")
    else:
        flash(u"Your request is pending", "error")
    return render_redirect(event.url_for(), code=303)
コード例 #2
0
def event_apply(profile, event):
    workflow = event.workflow()
    if not workflow.can_apply():
        flash("Hacknight is not accepting participants now, please try after sometime.")
        return render_redirect(event.url_for())
    values = {'profile': profile.name, 'event': event.name}
    participant = Participant.get(g.user, event)
    if not participant:
        # If no participant is found create a new participant entry
        # First collect some information about the new participant
        user = g.user
        form = ParticipantForm(obj=user)
        if form.validate_on_submit():
            total_participants = Participant.query.filter_by(event_id=event.id).count()
            participant = Participant(user=user, event=event)
            form.populate_obj(participant)
            participant.save_defaults()
            participant.status = PARTICIPANT_STATUS.PENDING if event.maximum_participants > total_participants else PARTICIPANT_STATUS.WL
            db.session.add(participant)
            db.session.commit()
            flash(u"Your request to participate has been recorded; you will be notified by the event manager", "success")
        else:
            return render_form(form=form, message=Markup(event.apply_instructions) if event.apply_instructions else "",
                title="Participant Details", submit=u"Participate",
                cancel_url=event.url_for(), ajax=False)
    # FIXME: Don't change anything unless this is a POST request
    elif participant.status == PARTICIPANT_STATUS.WITHDRAWN:
        participant.status = PARTICIPANT_STATUS.PENDING
        db.session.commit()
        flash(u"Your request to participate has been recorded; you will be notified by the event manager", "success")
    else:
        flash(u"Your request is pending", "error")
    return render_redirect(event.url_for(), code=303)
コード例 #3
0
def project_new(profile, event, form=None):
    participant = Participant.get(user=g.user, event=event)
    if participant == None:
        abort(403)
    if participant.status != PARTICIPANT_STATUS.CONFIRMED:
        abort(403)

    form = ProjectForm()
    if form.validate_on_submit():
        project = Project(participant=participant, event=event)
        form.populate_obj(project)
        project.make_name()
        db.session.add(project)
        project.votes.vote(g.user)

        project_member = ProjectMember(project=project,
                                       participant=participant)
        db.session.add(project_member)
        db.session.commit()
        flash("Project saved")
        return render_redirect(
            url_for('project_view',
                    profile=profile.name,
                    event=event.name,
                    project=project.url_name))
    return render_form(form=form,
                       title=u"New Project",
                       submit=u"Save",
                       cancel_url=url_for('event_view',
                                          profile=profile.name,
                                          event=event.name),
                       ajax=False)
コード例 #4
0
def event_view(profile, event):
    workflow = event.workflow()
    participants = [
        r[0] for r in db.session.query(Participant, User).filter(
            Participant.status != PARTICIPANT_STATUS.WITHDRAWN,
            Participant.event == event).join((User, Participant.user)).options(
                joinedload(User.project_memberships)).order_by(
                    func.lower(User.fullname)).all()
    ]

    accepted_participants = [
        p for p in participants if p.status == PARTICIPANT_STATUS.CONFIRMED
    ]
    rest_participants = [
        p for p in participants if p.status != PARTICIPANT_STATUS.CONFIRMED
    ]

    applied = False
    for p in participants:
        if p.user == g.user:
            applied = True
            break
    current_participant = Participant.get(user=g.user,
                                          event=event) if g.user else None
    return render_template('event.html',
                           profile=profile,
                           event=event,
                           projects=event.projects,
                           accepted_participants=accepted_participants,
                           rest_participants=rest_participants,
                           applied=applied,
                           current_participant=current_participant,
                           sponsors=event.sponsors,
                           workflow=workflow)
コード例 #5
0
ファイル: project.py プロジェクト: sidharthkuruvila/hacknight
def project_new(profile, event, form=None):
    participant = Participant.get(user=g.user, event=event)
    if participant == None:
        abort(403)
    if participant.status != PARTICIPANT_STATUS.CONFIRMED:
        abort(403)

    form = ProjectForm()
    if form.validate_on_submit():
        project = Project(participant=participant, event=event)
        form.populate_obj(project)
        project.make_name()
        db.session.add(project)
        project.votes.vote(g.user)

        project_member = ProjectMember(project=project, participant=participant)
        db.session.add(project_member)
        db.session.commit()
        flash("Project saved")
        return render_redirect(url_for('project_view', profile=profile.name, event=event.name, project=project.url_name))
    return render_form(form=form, title=u"New Project", submit=u"Save",
        cancel_url=url_for('event_view', profile=profile.name, event=event.name), ajax=False)
コード例 #6
0
ファイル: event.py プロジェクト: jamna/hacknight
def event_view(profile, event):
    participants = [r[0] for r in db.session.query(Participant, User).filter(
        Participant.status != PARTICIPANT_STATUS.WITHDRAWN, Participant.event == event).join(
        (User, Participant.user)).options(
        joinedload(Participant.project_memberships)).order_by(func.lower(User.fullname)).all()]

    accepted_participants = [p for p in participants if p.status == PARTICIPANT_STATUS.CONFIRMED]
    rest_participants = [p for p in participants if p.status != PARTICIPANT_STATUS.CONFIRMED]

    applied = False
    for p in participants:
        if p.user == g.user:
            applied = True
            break
    current_participant = Participant.get(user=g.user, event=event) if g.user else None
    return render_template('event.html', profile=profile, event=event,
        projects=event.projects,
        accepted_participants=accepted_participants,
        rest_participants=rest_participants,
        applied=applied,
        current_participant=current_participant,
        sponsors=event.sponsors)