def recomendate(): if 'username' not in session.keys(): return render_template('landing.html') username = session["username"] adminUser = AdminUser() user = adminUser.getByUsername(username) #adminML = AdminMachineLearning() #correlations = adminML.getMachineLearning() #correlations.recomendate(user) recomendations = [] if user.hasReviews(): for recomendation in user.getRecomendations(): recomendations.append(recomendation.toJSON()) #adminML.closeConnection() adminUser.closeConnection() return render_template('recomendacion.html', recomendations = recomendations, username=username) else: return render_template('landing.html')
def quienessomos(): if 'username' not in session.keys(): return render_template('landing.html') username = session["username"] adminUser = AdminUser() user = adminUser.getByUsername(username) #adminML = AdminMachineLearning() #correlations = adminML.getMachineLearning() #adminML.closeConnection() adminUser.closeConnection() return render_template('quienessomos.html', username=username)
def review(): if 'username' not in session.keys(): return render_template('landing.html') adminExperience = AdminExperience() username = session["username"] adminUser = AdminUser() if request.method == 'POST': experience_name = request.form.getlist('experience')[0] rating_value = float(request.form.getlist('rating')[0]) experience = adminExperience.getByName(experience_name) rating = Rating(rating_value) if experience == None: return 420 # if rating_value > Rating.getMax() or rating_value < Rating.getMin(): # return 421 user = adminUser.getByUsername(username) review = Review(experience, rating) user.addReview(review) adminUser.updateUser(user) adminExperience.closeConnection() adminUser.closeConnection() # Redirigimos a recomendar return redirect(url_for("recomendate")) else: experiences = [] types = [] hasReviews = adminUser.getByUsername(username).hasReviews() for experience in adminExperience.getAll(): experiences.append(experience.toJSON()) type = experience.getType() if type not in types: types.append(type) return render_template('review.html', hasReviews=hasReviews, username=username, experiences = experiences, types = types)
for experience in experiences: if tab < len(experience.getName()): tab = len(experience.getName()) cadena = "%-"+str(tab)+"s" adminExperiences.closeConnection() userDao = AdminUser() #nombre = input("Nombre: ") #password = input ("Contraseña: ") nombre = "carlos" user = userDao.getByUsername(nombre) print ("leido") userDao.closeConnection() #print (cadena %"EXPERIENCIA", "\t%s" %"TIPO") #for experience in experiences: # if experience.getType() == "restaurant": # print(cadena %experience.getName(), "\t%s" %experience.getType()) #experiencia = inputExperience(experiences) #valoracion = inputRating() #user.addReview(Review(experiencia, Rating(valoracion))) #continuar = input ("Desea continuar? (S/N) ") #while continuar == "S" or continuar == "s": # experiencia = inputExperience(experiences) # valoracion = inputRating() # continuar = input ("Desea continuar? (S/N) ")