def clientProjects(): conn = dbconn2.connect(dsn) roleCheck = updateDB.getRole(conn, session) try: if 'uid' in session: uid = session['uid'] roleDB = updateDB.checkUserRole(conn, uid) if 'client' in roleDB['role']: if request.method == 'POST': pid = request.form['projectID'] updateDB.deleteProject(conn, pid) flash("Project Deleted") projects = updateDB.getUserProjects(conn, uid) return render_template('clientProjects.html', projects = projects, role = roleCheck ) else: flash('Only clients have access to this page, please login with a client account') return redirect( url_for('index') ) else: flash('You are not logged in. Please login or join') return redirect( url_for('index') ) except Exception as e: flash(e) return redirect( url_for('index') )
def browseProjects(): conn = dbconn2.connect(dsn) try: if 'uid' in session: uid = session['uid'] roleDB = updateDB.checkUserRole(conn, uid) roleCheck = updateDB.getRole(conn, session) if 'student' in roleDB['role']: if request.method == 'POST': pid = request.form['projectID'] result = updateDB.applyToProject(conn, uid, pid) if result == None: flash('You have already applied to project ' + pid + '. You cannot apply to a project twice. ') else: flash('You have successfully applied to project number ' + pid) projects = updateDB.getProjects(conn) else: projects = updateDB.getProjects(conn) return render_template('browse.html', projects = projects, role = roleCheck ) else: flash('Only students have access to this page, please login with a student account') else: flash('You are not logged in. Please login or join') except Exception as e: flash(e) return redirect( url_for('index') )
def projectApproval(): conn = dbconn2.connect(dsn) roleCheck = updateDB.getRole(conn, session) try: if 'uid' in session: uid = session['uid'] roleDB = updateDB.checkUserRole(conn, uid) if 'admin' in roleDB['role']: if request.method == 'POST': pid = request.form['projectID'] updateDB.approveProject(conn, uid, pid) flash("selection approved") projects = updateDB.getUnapprovedProjects(conn) return render_template('projectApproval.html', projects = projects, role = roleCheck ) else: flash('Only administrators have access to this page, please login with an admin account') return redirect( url_for('index') ) else: flash('You are not logged in. Please login or join') return redirect( url_for('index') ) except Exception as e: flash(e) return redirect( url_for('index') )
def createProject(): conn = dbconn2.connect(dsn) try: roleCheck = updateDB.getRole(conn, session) if 'uid' in session: uid = session['uid'] roleDB = updateDB.checkUserRole(conn, uid) if 'client' in roleDB['role']: if request.method == 'POST': projName = request.form['projectTitle'] projDur = request.form['duration'] projComp = request.form['compensation'] projRoles = request.form['rolesOpen'] projReq = request.form['requirements'] projDesc = request.form['description'] projCreator = uid if (projName == '' or projDur == '' or projComp == '' or projRoles == ''\ or projReq == '' or projDesc == ''): flash('Please fill out all fields.') else: updateDB.addProject(conn, projCreator, projName, projDur, projComp,\ projRoles, projReq, projDesc) flash ("Project Submitted") return render_template('project.html', role = roleCheck) else: return render_template('project.html', role = roleCheck) else: flash('Only clients have access to this page, please login with a client account') return redirect( url_for('index') ) else: flash('You are not logged in. Please login or join') return redirect( url_for('index') ) except Exception as e: flash(e) return redirect( url_for('index') )
def viewApplications(): conn = dbconn2.connect(dsn) try: roleCheck = updateDB.getRole(conn, session) if 'uid' in session: uid = session['uid'] roleDB = updateDB.checkUserRole(conn, uid) if 'client' in roleDB['role']: applications = updateDB.getApplicationsPerClient(conn, uid) print(applications) return render_template('viewApplications.html', applications=applications, role = roleCheck) else: flash('Only clients have access to this page, please login with a client account') else: flash('You are not logged in. Please login or join') except Exception as e: flash(e) return redirect( url_for('index') )
def createProfile(): conn = dbconn2.connect(dsn) try: roleCheck = updateDB.getRole(conn, session) if 'uid' in session: uid = session['uid'] roleDB = updateDB.checkUserRole(conn, uid) if 'student' in roleDB['role']: if request.method == 'POST': major = request.form['major'] prog_languages = request.form['prog_languages'] courses = request.form['courses'] research_exp = request.form['research_exp'] internship_exp = request.form['internship_exp'] bg_info = request.form['bg_info'] updateDB.updateUser(conn, major, prog_languages, courses, research_exp, internship_exp, bg_info, uid) f = request.files['resume'] mimetype = f.content_type.split('/')[1] if mimetype != 'pdf': flash('Please upload a PDF') else: filename = secure_filename(str(uid)+ '.pdf') pathname = 'static/' + filename f.save(pathname) flash('Upload successful') flash ("Profile Update Submitted") return render_template('profile.html', role = roleCheck, src=url_for('resume',fname=filename)) else: return render_template('profile.html', role = roleCheck) else: flash('Only students have access to this page, please login with a student account') return redirect( url_for('index') ) else: flash('You are not logged in. Please login or join') return redirect( url_for('index') ) except Exception as e: flash(e) flash('Incorrectly filled, try again') return redirect( url_for('index') )