Ejemplo n.º 1
0
def project_join(profile, project, event):
    participant = Participant.query.filter_by(user=g.user, event=event, status=PARTICIPANT_STATUS.CONFIRMED).first()
    if participant==None:
        flash("You need to be a confirmed participant to join this team.", "fail")
        return redirect(project.url_for(), code=302)
    elif ProjectMember.query.filter_by(project_id=project.id, user=g.user).first():
        flash("You are already part of this team!", "fail")
    else:
        project_member = ProjectMember()
        project_member.project_id = project.id
        project_member.user_id = g.user.id
        db.session.add(project_member)
        db.session.commit()
        flash("You are now part of this team!", "success")
        return redirect(project.url_for())
    return redirect(project.url_for())
Ejemplo n.º 2
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)
Ejemplo n.º 3
0
def project_join(profile, project, event):
    participant = Participant.query.filter_by(
        user=g.user, event=event, status=PARTICIPANT_STATUS.CONFIRMED).first()
    if participant == None:
        flash("You need to be a confirmed participant to join this team.",
              "fail")
        return redirect(project.url_for(), code=302)
    elif ProjectMember.query.filter_by(project_id=project.id,
                                       user=g.user).first():
        flash("You are already part of this team!", "fail")
    else:
        project_member = ProjectMember()
        project_member.project_id = project.id
        project_member.user_id = g.user.id
        db.session.add(project_member)
        db.session.commit()
        flash("You are now part of this team!", "success")
        return redirect(project.url_for())
    return redirect(project.url_for())
Ejemplo n.º 4
0
def project_join(profile, project, event):
    if not profile:
        abort(404)
    if not event:
        abort(404)
    if not project:
        abort(404)

    user = User.query.filter_by(userid=g.user.userid).first()
    participant = Participant.query.filter_by(
        user_id=user.id,
        event_id=event.id,
        status=PARTICIPANT_STATUS.CONFIRMED).first()
    if participant == None:
        flash("You need to be a confirmed participant to join this team.",
              "fail")
        return redirect(
            url_for('project_view',
                    profile=profile.name,
                    project=project.url_name,
                    event=event.name))
    elif ProjectMember.query.filter_by(project_id=project.id,
                                       participant_id=participant.id).first():
        flash("You are already part of this team!", "fail")
    else:
        project_member = ProjectMember()
        project_member.project_id = project.id
        project_member.participant_id = participant.id
        db.session.add(project_member)
        db.session.commit()
        flash("You are now part of this team!", "success")
        return redirect(
            url_for('project_view',
                    profile=profile.name,
                    project=project.url_name,
                    event=event.name))
    return redirect(
        url_for('project_view',
                profile=profile.name,
                project=project.url_name,
                event=event.name))
Ejemplo n.º 5
0
def project_join(profile, project, event):
    if not profile:
        abort(404)
    if not event:
        abort(404)
    if not project:
        abort(404)

    user = User.query.filter_by(userid=g.user.userid).first()
    participant = Participant.query.filter_by(user_id=user.id, event_id=event.id, status=PARTICIPANT_STATUS.CONFIRMED).first()
    if participant==None:
        flash("You need to be a confirmed participant to join this team.", "fail")
        return redirect(url_for('project_view',profile=profile.name, project=project.url_name, event=event.name))
    elif ProjectMember.query.filter_by(project_id=project.id, participant_id=participant.id).first():
        flash("You are already part of this team!", "fail")
    else:
        project_member = ProjectMember()
        project_member.project_id = project.id
        project_member.participant_id = participant.id
        db.session.add(project_member)
        db.session.commit()
        flash("You are now part of this team!", "success")
        return redirect(url_for('project_view',profile=profile.name, project=project.url_name, event=event.name))
    return redirect(url_for('project_view',profile=profile.name, project=project.url_name, event=event.name))