def post(self): nome = self.request.get("nome") periodos = self.request.get("periodos") semestral = self.request.get("semestral") curso = Curso(nome=nome, periodos=periodos, semestral=semestral) curso.put() time.sleep(.1) self.redirect('/curso')
def home(): if request.method == 'POST': # CARRERA global nombreC global facultad global carrera # ASIGNATURA global nombreA global idA global asignatura # CURSO global cod global curso # PRUEBA global nombreP global fechaP global ponderacionP global unidadP global cantidad global nivelesTax global todasCheck # CARRERA nombreC = request.form['nombreC'] facultad = request.form['facultad'] carrera = Carrera(nombreC, facultad) # ASIGNATURA nombreA = request.form['nombreA'] idA = request.form['idA'] asignatura = Asignatura(nombreA, idA) # CURSO cod = request.form['cod'] curso = Curso(cod) # PRUEBA nombreP = request.form['nombreP'] fechaP = request.form['fechaP'] ponderacionP = request.form['ponderacionP'] unidadP = request.form['unidad'] cantidad = int(request.form['cantidadP']) try: todasCheck = request.form['all'] except BaseException as e: print(e) nivelesTax = [] if todasCheck == 'on': unidadP = "Unidades: 1 & 2" # BUSCANDO DISPONIBLES disponibles = { "Entender": 0, "Recordar": 0, "Aplicar": 0, "Analizar": 0, "Evaluar": 0, "Crear": 0 } fechaHoy = date.today() # date(year, month, day) for p in preguntasRepo: # FECHA ULTIMO USO fechaUlt = p.get_fecha() # COMPROBACION DE TIEMPO restaFechas = str(fechaHoy - fechaUlt) print("---------------------------------" + restaFechas + "-------------------------------") try: if int(restaFechas.rstrip(" days, 0:00:00")) > 730: if (unidadP == p.get_unidad() and nombreA == p.get_nombreAsig()) or ( todasCheck == 'on' and nombreA == p.get_nombreAsig()): nivelTax = p.get_nivel() disponibles[nivelTax] += 1 except ValueError as e: print(p.get_nivel() + " USADA") return render_template('preguntas.html', cantidad=cantidad, disponibles=disponibles) next = request.args.get('next', None) if next: return redirect(next) if logded == True: return render_template('home.html') else: return render_template('authorize.html')