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