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_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())