Jose R Ortiz Ubarri пре 4 година
родитељ
комит
b2f7eb5aec
1 измењених фајлова са 32 додато и 1 уклоњено
  1. 32
    1
      estudiante.py

+ 32
- 1
estudiante.py Прегледај датотеку

@@ -1,5 +1,36 @@
1
+from connect import connection, engine, metadata
2
+import sqlalchemy as db
3
+
1 4
 def add():
2 5
 	return '{"titulo":"Estudiante","accion":"A\u00f1adir","entradas":{"col1":[{"label":"Nombres","type":"text","name":"nombres"},{"label":"Apellidos","type":"text","name":"apellidos"},{"label":"Email","type":"text","name":"email"},{"label":"Grado","type":"text","name":"grado"},{"label":"Fecha de Nacimiento","type":"date","name":"fecha_nac"},{"label":"Genero","type":"select","options":["","Femenino","Masculino","Otro"],"name":"genero"},{"label":"Educaci\u00f3n Especial","type":"checkbox","name":"ed_especial"}],"col2":[{"label":"Direcci\u00f3n 1","name":"direccion1"},{"label":"Direcci\u00f3n 2","type":"text","name":"direccion2"},{"label":"Ciudad","type":"text","name":"ciudad"},{"label":"Zipcode","type":"text","name":"zipcode"},{"label":"Tel\u00e9fono 1","type":"tel","name":"tel1"},{"label":"Tel\u00e9fono 2","type":"tel","name":"tel2"}]}}'
3
-	
6
+
4 7
 def edit(id):
5 8
 	return '{"titulo":"Estudiante '+id+'","accion":"Editar","entradas":{"col1":[{"label":"Nombres","type":"text","name":"nombres","value":"Roberta"},{"label":"Apellidos","type":"text","name":"apellidos"},{"label":"Email","type":"text","name":"email"},{"label":"Grado","type":"text","name":"grado"},{"label":"Fecha de Nacimiento","type":"date","name":"fecha_nac"},{"label":"Genero","type":"select","options":["","Femenino","Masculino","Otro"],"name":"genero"},{"label":"Educaci\u00f3n Especial","type":"checkbox","name":"ed_especial"}],"col2":[{"label":"Direcci\u00f3n 1","name":"direccion1"},{"label":"Direcci\u00f3n 2","type":"text","name":"direccion2"},{"label":"Ciudad","type":"text","name":"ciudad"},{"label":"Zipcode","type":"text","name":"zipcode"},{"label":"Tel\u00e9fono 1","type":"tel","name":"tel1"},{"label":"Tel\u00e9fono 2","type":"tel","name":"tel2"}]}}'
9
+
10
+
11
+def get(id):
12
+	estudiantes = db.Table('estudiantes',  metadata, autoload=True, autoload_with=engine))
13
+	usuarios = db.Table('usuarios', metadata, autoload=True, autoload_with=engine)
14
+	query = db.select([estudiantes, usuarios])
15
+	query = query.select_from(usuarios.join(role, usuarios.columns.id == estudiantes.columns.user_id)).where(estudiantes.columns.user_id == id)
16
+	result = connection.execute(query).fetchall()
17
+
18
+	return [{"nombres": "Juana", "apellidos":"Del Barrio", "email": "juana1@gmail.com"},{"nombres": "Juana2", "apellidos":"Del Barrio", "email": "juana2@gmail.com"}]
19
+
20
+def list():
21
+	estudiantes = db.Table('estudiantes',  metadata, autoload=True, autoload_with=engine))
22
+	usuarios = db.Table('usuarios', metadata, autoload=True, autoload_with=engine)
23
+	query = db.select([estudiantes, usuarios])
24
+	query = query.select_from(usuarios.join(role, usuarios.columns.id == estudiantes.columns.user_id)) # .where(role.columns.user_id == self.id)
25
+	result = connection.execute(query).fetchall()
26
+
27
+	return [{"nombres": "Juana", "apellidos":"Del Barrio", "email": "juana1@gmail.com"},{"nombres": "Juana2", "apellidos":"Del Barrio", "email": "juana2@gmail.com"}]
28
+
29
+
30
+
31
+def main()
32
+	list()
33
+	get(1)
34
+
35
+if __name__ == '__main__':
36
+	main()