示例#1
0
def job_detail(jid):
	if 'user' in session:
		cursor = db_curs.cursor()
		if request.method=="POST":
			uid = session['user']
			if request.form['btn'] == "Accept":
				#returns boolean and employee id if true, boolean and error message if false
				resp, e = acceptJob.main(uid, jid)
				if resp:
					flash("Job accepted!")
					return redirect(url_for('view_account', uid=e))
				else:
					flash(e)
					return render_template("view_job.html", jid=jid, page_title=deetsList[0], deetsList=deetsList, is_logged=True, 
					is_owner=(session['user']==job[1]), uid=uid)
			else:
				deleteJob.deleteJob(cursor, uid, jid)
				flash("Job has been deleted.")
				return redirect(url_for('view_jobs'))
    	#job is a symbol separated string of job info
		job = showJobs.showJob(cursor, jid)
		#split job into list so easy to add pieces of info to template
		if job[0] == "":
			flash("We're sorry, that job can't be found.")
			return redirect(url_for('view_jobs'))
		deetsList = job[0].split('(~/~)')
		return render_template("view_job.html", jid=jid, page_title=deetsList[0], deetsList=deetsList, is_logged=True, 
		is_owner=(session['user']==job[1]), uid=session['user'])
	else:
		flash("Please login to view this job.")
		return redirect(url_for('login'))
def main(uid,jid):
	'''removes specified job from listing'''
	if int(uid)==0:
		return deleteJob(db_curs.cursor(), uid, jid)
	else:
		print "enter uid = 0 to confirm deletion"
		return False
示例#3
0
def main(uid, jid):
    '''Checks if actor is in database, if not inserts actor and returns success message,
    else returns message saying actor is already in the database'''
    if int(uid) != 0:
        return acceptJob(db_curs.cursor(), uid, jid)
    else:
        print "only enter 0 to confirm a deletion"
        return False
示例#4
0
def login():
	'''Logs user into the app'''
	if request.method=="POST":
		cursor = db_curs.cursor()
		resp, user_id, err = db_acct.login(cursor, request.form)
		if resp:
			session['user'] = user_id
			flash("Login successful")
			return redirect(url_for('view_jobs'))
		else:
			flash(err)
	return render_template("login.html", page_title="Login", is_custom=True)
示例#5
0
def search_account():
	if 'user' in session:
		cursor = db_curs.cursor()
		if request.method == "POST":
			return redirect(url_for('view_account',uid=request.form['uid']))
		all_accounts = db_allAccts.list_users(cursor, session['user'])
		if all_accounts == {}:
			flash("You haven't connected with anyone yet.")
		return render_template("search_account.html",all_accounts=all_accounts,page_title="View Past Connections", 
		is_logged=True, uid=session['user'])
	flash("Must be logged in to view page.")
	return redirect(url_for('login'))
示例#6
0
def create_job():
## '''inserts data from form into job table'''
	if 'user' in session:
		if request.method=="POST":
			cursor = db_curs.cursor()
			a, b = db_job.create_job(cursor,request.form, session['user'])
			if a:
				flash("Job has been created successfully!")
				return redirect(url_for('job_detail', jid=b))
			else:
				flash("We're sorry, something went wrong...")
		return render_template("create_job.html",page_title="Post a New Job", is_logged=True, uid=session['user'])
	else:
		flash("Please login to create jobs.")
		return redirect(url_for('login'))
示例#7
0
def create_account():
## '''inserts data from form into account table'''
	if request.method=="POST":
		cursor = db_curs.cursor()
		skills = request.form.getlist('skills')
		f = request.files['file']
		a, b, c = db_acct.create_account(cursor,request.form,skills,f)
		if a:
			flash("Account has been created successfully!")
			if b != "":
				flash(b)
			if c != "":
				flash(c)
		return redirect(url_for('login'))
		flash("We're sorry, something went wrong...")
	return render_template("create_account.html")
示例#8
0
def review(oid):
## '''allows both employees and employers to review, link from account page'''
	if 'user' in session:
		cursor = db_curs.cursor()
		if db_viewAcct.can_view(cursor,session['user'],oid):
			if request.method=="POST":
				if db_review.insert_review(cursor,request.form, oid):
					flash("Review submitted.")
					return redirect(url_for('search_account'))
				else:
					flash("We're sorry, something went wrong...")
			jobs = db_review.jobs_incommon(cursor, session['user'], oid)
			return render_template("review.html",page_title="Leave a Review", jobs_worked=jobs, is_logged=True)
		else:
			flash("The user must be in your connections in order to leave a review.")
			return redirect (url_for('search_account'))
	else:
		flash("Please login to leave a review.")
		return redirect(url_for('login'))
示例#9
0
def view_account(uid):
	if 'user' in session:
		cursor = db_curs.cursor()
		if db_viewAcct.can_view(cursor,session['user'],uid):
			if db_viewAcct.isActive(cursor,uid):
				if request.method == "POST":
					if  db_acct.deleteAcct(cursor,uid):
						flash("You have successfully deleted your account.")
						return redirect(url_for('home'))
				acct_info = db_viewAcct.search_uid(cursor,uid)
				return render_template("view_account.html",acct_info=acct_info, 
				page_title=acct_info['name']+"'s Profile", is_logged=True, uid=session['user'], 
				is_owner=(str(session['user'])==str(uid)), rev_id=uid)
			else:
				flash("We're sorry, this account has been deleted.")
				return redirect(url_for('home'))
		else:
			flash("Must be account owner, hired the person, or have worked a job associated with account to view.")
			return redirect (url_for('search_account'))
	flash("Must be logged in to view account.")
	return redirect(url_for('login'))
示例#10
0
def main():
    '''Returns a list of available jobs'''
    return getJobs(db_curs.cursor())
示例#11
0
def showJob(cursor, jid):
    '''Returns a single job with all details'''
    q1 = "select title,description,dt,pay,poster,skills_required,available from job where jid=%s;"
    cursor.execute(q1, (jid, ))
    row1 = cursor.fetchone()
    if row1 == None:
        return [""]
    #collect the id of the poster to compare for delete/accept privileges in template
    uid = row1["poster"]
    # get the name of the poster
    q2 = "select nm from account inner join job on (account.uid=job.poster) where job.poster=%s;"
    cursor.execute(q2, (row1["poster"], ))
    row2 = cursor.fetchone()
    # use name of poster instead of poster id in returned query
    row1["poster"] = row2["nm"]
    return [
        "{title}(~/~){description}(~/~){dt}(~/~){pay}(~/~){poster}(~/~){skills_required}(~/~){available}"
        .format(**row1), uid
    ]


def main():
    '''Returns a list of available jobs'''
    return getJobs(db_curs.cursor())


if __name__ == '__main__':
    print main()
    print showJob(db_curs.cursor(), 3)