def viewRequest(service_id): result = getRequest(service_id) names = getWorkers(service_id) if result and result[0]==session.get('user'): days = formatSchedule('request', service_id) return render_template('request.jade', id=service_id, client_username=result[0], title=result[1], description=result[2], address=result[3], tag=result[4], worker_names=names, days=days) return redirect('/')
def viewPending(service_id): sql=text('''SELECT client_username, title, description, address, interested, tag FROM service_request sr, worker_request wr WHERE sr.service_id=:id AND sr.service_id=wr.service_id;''') results=db.engine.execute(sql, id=service_id) result = results.fetchone() if result: days = formatSchedule('request', service_id) return render_template('pending.jade', id=service_id, client_username=result[0], title=result[1], description=result[2], address=result[3], interested=result[4], tag=result[5], days=days) return redirect('/')
def viewRequest(service_id): result = getRequest(service_id) names = getWorkers(service_id) if result and result[0] == session.get('user'): days = formatSchedule('request', service_id) return render_template('request.jade', id=service_id, client_username=result[0], title=result[1], description=result[2], address=result[3], tag=result[4], worker_names=names, days=days) return redirect('/')
def viewPending(service_id): sql = text( '''SELECT client_username, title, description, address, interested, tag FROM service_request sr, worker_request wr WHERE sr.service_id=:id AND sr.service_id=wr.service_id;''' ) results = db.engine.execute(sql, id=service_id) result = results.fetchone() if result: days = formatSchedule('request', service_id) return render_template('pending.jade', id=service_id, client_username=result[0], title=result[1], description=result[2], address=result[3], interested=result[4], tag=result[5], days=days) return redirect('/')
def profile(username): result, type = getProfile(username) if result: days = formatSchedule('worker', username) sql = text('''SELECT SUM(rating), COUNT(rating) FROM contract WHERE rating IS NOT NULL AND worker_username=:username''') result2 = db.engine.execute(sql, username=username) result2 = result2.fetchone() totalRating = result2[0] numRatings = result2[1] avgRating = None if numRatings != 0: avgRating = 1.0*totalRating/numRatings sql = text('''SELECT to_char(time_finish AT TIME ZONE 'CDT', 'MM/DD/YY'), rating, review, tag FROM contract c, service_request s WHERE worker_username=:username AND time_finish IS NOT NULL AND c.service_id=s.service_id ORDER BY time_finish DESC LIMIT 5;''') reviews = db.engine.execute(sql, username=username).fetchall() return render_template('profile.jade', username=result[0], email=result[1], phone=result[2], type=type, days=days, rating=avgRating, numRatings=totalRating, reviews=reviews) return redirect('/')