Kaynağa Gözat

union de 5 archivos para el admin ver perfiles

los archivos que contenien las funciones que hacen queries a la base de datos para que el admin vea los siguiente perfiles ahora estan en un solo archivo, amdinver.py:
-facultad
-estudiante
-administracion
-enfermeria
-encargados
Oniel Méndez Nieves 4 yıl önce
ebeveyn
işleme
e7936dc319

BIN
__pycache__/adminver.cpython-36.pyc Dosyayı Görüntüle


BIN
__pycache__/enfermeriaver.cpython-36.pyc Dosyayı Görüntüle


BIN
__pycache__/visitas_enfermeria.cpython-36.pyc Dosyayı Görüntüle


+ 0
- 97
adminadmin.py Dosyayı Görüntüle

@@ -1,97 +0,0 @@
1
-# from sqlalchemy import metadata
2
-import sqlalchemy as db
3
-
4
-
5
-# connect to server
6
-engine = db.create_engine('mysql+pymysql://root:@0.0.0.0/registro_escolar_1')
7
-
8
-connection = engine.connect()
9
-# estudiantes = db.Table('estudiantes', metadata, autoload=True, autoload_with=engine)
10
-# usuarios = db.Table('usuarios', metadata, autoload=True, autoload_with=engine)
11
-
12
-def admin():
13
-    query = 'SELECT u.id, u.nombres, u.apellidos, u.email FROM usuarios u,administracion a WHERE u.id = a.user_id'
14
-    result_db = connection.execute(query).fetchall()
15
-
16
-    ###### headers
17
-
18
-    headers = '['
19
-    headers += '{"nombre":"Nombre"}'
20
-    headers += ','
21
-    headers += '{"nombre":"Posicion"}'
22
-    headers += ','
23
-    headers += '{"nombre":"Email"}'
24
-    headers += ','
25
-    headers += '{"nombre":"Informacion"}'
26
-    headers += ','
27
-    headers += '{"nombre":"Editar"}'
28
-    headers += ']'
29
-
30
-    ###### tabla
31
-
32
-
33
-    modal_content = '['
34
-    tabla = '['
35
-    i = 0
36
-    len_result = len(result_db)
37
-    for q in result_db:
38
-        i = i+1
39
-        tabla += '{'
40
-        modal_content += '{'
41
-        tabla += '"Nombre":"'+(q[1])+' '+(q[2])+'"'
42
-        modal_content += '"Nombre":"'+(q[1])+' '+(q[2])+'"'
43
-        tabla += ','
44
-        modal_content += ','
45
-
46
-        query = 'SELECT posicion FROM administracion a WHERE a.user_id = ' + str(q[0])
47
-        posicion = connection.execute(query).fetchall()
48
-
49
-        tabla += '"Posicion":"'+(str(posicion[0][0]))+'"'
50
-        modal_content += '"Posicion":"'+(str(posicion[0][0]))+'"'
51
-
52
-        tabla += ','
53
-        modal_content += ','
54
-        tabla += '"Email":"'+(q[3])+'"'
55
-        modal_content += '"Email":"'+(q[3])+'"'
56
-        tabla += ','
57
-        modal_content += ','
58
-        tabla += '"user_id":"'+(str(q[0]))+'"'
59
-        modal_content += '"user_id":"'+(str(q[0]))+'"'
60
-        tabla += '}'
61
-        modal_content += '}'
62
-        if i < len_result:
63
-            tabla += ','
64
-            modal_content += ','
65
-    tabla += ']'
66
-    modal_content += ']'
67
-
68
-    ###### info
69
-
70
-    info = '{'
71
-    info += '"dash_name":"Manejar Administracion"'
72
-    info += ','
73
-    info += '"dash_link":"/admin/ver/"'
74
-    info += ','
75
-    info += '"dash_sub_name":"Administracion Registrados"'
76
-    info += ','
77
-    info += '"add":"Anadir Administracion"'
78
-    info += ','
79
-    info += '"add_link":"/admin/forma/add/administracion/"'
80
-    info += ','
81
-    info += '"dir1":"#"'
82
-    info += ','
83
-    info += '"dir2":"/admin/forma/edit/administracion/"'
84
-    info += '}'
85
-
86
-    ###### modal
87
-
88
-    modal = '{'
89
-    modal += '"infoName":"Ver informacion"'
90
-    modal += ','
91
-    modal += '"editName":"/admin/ver/"'
92
-    modal += '}'
93
-
94
-    result = '{"headers":'+headers+',"tabla":'+tabla+',"modal_content":'+modal_content+',"info":'+info+',"modal":'+modal+'}'
95
-
96
-    # print(result)
97
-    return(result)

+ 0
- 96
adminencargados.py Dosyayı Görüntüle

@@ -1,96 +0,0 @@
1
-# from sqlalchemy import metadata
2
-import sqlalchemy as db
3
-
4
-# connect to server
5
-engine = db.create_engine('mysql+pymysql://root:@0.0.0.0/registro_escolar_1')
6
-
7
-connection = engine.connect()
8
-# estudiantes = db.Table('estudiantes', metadata, autoload=True, autoload_with=engine)
9
-# usuarios = db.Table('usuarios', metadata, autoload=True, autoload_with=engine)
10
-
11
-def encargados():
12
-    query = 'SELECT u.id, u.nombres, u.apellidos, u.email FROM usuarios u,madres m WHERE u.id = m.user_id'
13
-    result_db = connection.execute(query).fetchall()
14
-
15
-    ###### headers
16
-
17
-    headers = '['
18
-    headers += '{"nombre":"Nombre"}'
19
-    headers += ','
20
-    headers += '{"nombre":"Hijos matriculados"}'
21
-    headers += ','
22
-    headers += '{"nombre":"Especialidad"}'
23
-    headers += ','
24
-    headers += '{"nombre":"Informacion"}'
25
-    headers += ','
26
-    headers += '{"nombre":"Editar"}'
27
-    headers += ']'
28
-
29
-    ###### tabla
30
-
31
-
32
-    tabla = '['
33
-    modal_content = '['
34
-    i = 0
35
-    len_result = len(result_db)
36
-    for q in result_db:
37
-        i = i+1
38
-        tabla += '{'
39
-        modal_content += '{'
40
-        tabla += '"Nombre":"'+(q[1])+' '+(q[2])+'"'
41
-        modal_content += '"Nombre":"'+(q[1])+' '+(q[2])+'"'
42
-        tabla += ','
43
-        modal_content += ','
44
-
45
-        query = 'SELECT count(*) FROM madres_estudiantes me WHERE me.madre_id = ' + str(q[0])
46
-        total_hijos = connection.execute(query).fetchall()
47
-
48
-        tabla += '"Hijos Matriculados":"'+str(total_hijos[0][0])+'"'
49
-        modal_content += '"Hijos Matriculados":"'+str(total_hijos[0][0])+'"'
50
-
51
-        tabla += ','
52
-        modal_content += ','
53
-        tabla += '"Email":"'+(q[3])+'"'
54
-        modal_content += '"Email":"'+(q[3])+'"'
55
-        tabla += ','
56
-        modal_content += ','
57
-        tabla += '"user_id":"'+str(q[0])+'"'
58
-        modal_content += '"user_id":"'+str(q[0])+'"'
59
-        tabla += '}'
60
-        modal_content += '}'
61
-        if i < len_result:
62
-            tabla += ','
63
-            modal_content += ','
64
-    tabla += ']'
65
-    modal_content += ']'
66
-
67
-    ###### info
68
-
69
-    info = '{'
70
-    info += '"dash_name":"Manejar Encargados"'
71
-    info += ','
72
-    info += '"dash_link":"/admin/ver/"'
73
-    info += ','
74
-    info += '"dash_sub_name":"Encargados Registrados"'
75
-    info += ','
76
-    info += '"add":"Anadir Encargados"'
77
-    info += ','
78
-    info += '"add_link":"/admin/forma/add/madre/"'
79
-    info += ','
80
-    info += '"dir1":"#"'
81
-    info += ','
82
-    info += '"dir2":"/admin/forma/edit/madre/"'
83
-    info += '}'
84
-
85
-    ###### modal
86
-
87
-    modal = '{'
88
-    modal += '"infoName":"Ver informacion"'
89
-    modal += ','
90
-    modal += '"editName":"/admin/ver/"'
91
-    modal += '}'
92
-
93
-    result = '{"headers":'+headers+',"tabla":'+tabla+',"modal_content":'+modal_content+',"info":'+info+',"modal":'+modal+'}'
94
-
95
-    # print(result)
96
-    return(result)

+ 0
- 96
adminenfermeria.py Dosyayı Görüntüle

@@ -1,96 +0,0 @@
1
-# from sqlalchemy import metadata
2
-import sqlalchemy as db
3
-
4
-# connect to server
5
-engine = db.create_engine('mysql+pymysql://root:@0.0.0.0/registro_escolar_1')
6
-
7
-connection = engine.connect()
8
-# estudiantes = db.Table('estudiantes', metadata, autoload=True, autoload_with=engine)
9
-# usuarios = db.Table('usuarios', metadata, autoload=True, autoload_with=engine)
10
-
11
-def enfermeria():
12
-    query = 'SELECT u.id, u.nombres, u.apellidos, u.email FROM usuarios u,enfermeras e WHERE u.id = e.user_id'
13
-    result_db = connection.execute(query).fetchall()
14
-
15
-    ###### headers
16
-
17
-    headers = '['
18
-    headers += '{"nombre":"Nombre"}'
19
-    headers += ','
20
-    headers += '{"nombre":"Especialidad"}'
21
-    headers += ','
22
-    headers += '{"nombre":"Email"}'
23
-    headers += ','
24
-    headers += '{"nombre":"Informacion"}'
25
-    headers += ','
26
-    headers += '{"nombre":"Editar"}'
27
-    headers += ']'
28
-
29
-    ###### tabla
30
-
31
-
32
-    tabla = '['
33
-    modal_content = '['
34
-    i = 0
35
-    len_result = len(result_db)
36
-    for q in result_db:
37
-        i = i+1
38
-        tabla += '{'
39
-        modal_content += '{'
40
-        tabla += '"Nombre":"'+(q[1])+' '+(q[2])+'"'
41
-        modal_content += '"Nombre":"'+(q[1])+' '+(q[2])+'"'
42
-        tabla += ','
43
-        modal_content += ','
44
-
45
-        query = 'SELECT especialidad FROM enfermeras e WHERE e.user_id = ' + str(q[0])
46
-        especialidad = connection.execute(query).fetchall()
47
-
48
-        tabla += '"Especialidad":"'+(str(especialidad[0][0]))+'"'
49
-        modal_content += '"Especialidad":"'+(str(especialidad[0][0]))+'"'
50
-
51
-        tabla += ','
52
-        modal_content += ','
53
-        tabla += '"Email":"'+(q[3])+'"'
54
-        modal_content += '"Email":"'+(q[3])+'"'
55
-        tabla += ','
56
-        modal_content += ','
57
-        tabla += '"user_id":"'+str(q[0])+'"'
58
-        modal_content += '"user_id":"'+str(q[0])+'"'
59
-        tabla += '}'
60
-        modal_content += '}'
61
-        if i < len_result:
62
-            tabla += ','
63
-            modal_content += ','
64
-    tabla += ']'
65
-    modal_content += ']'
66
-
67
-    ###### info
68
-
69
-    info = '{'
70
-    info += '"dash_name":"Manejar Enfermeria"'
71
-    info += ','
72
-    info += '"dash_link":"/admin/ver/"'
73
-    info += ','
74
-    info += '"dash_sub_name":"Enfermeras Registrados"'
75
-    info += ','
76
-    info += '"add":"Anadir Enfermera"'
77
-    info += ','
78
-    info += '"add_link":"/admin/forma/add/enfermera/"'
79
-    info += ','
80
-    info += '"dir1":"#"'
81
-    info += ','
82
-    info += '"dir2":"/admin/forma/edit/enfermera/"'
83
-    info += '}'
84
-
85
-    ###### modal
86
-
87
-    modal = '{'
88
-    modal += '"infoName":"Ver informacion"'
89
-    modal += ','
90
-    modal += '"editName":"/admin/ver/"'
91
-    modal += '}'
92
-
93
-    result = '{"headers":'+headers+',"tabla":'+tabla+',"modal_content":'+modal_content+',"info":'+info+',"modal":'+modal+'}'
94
-
95
-    # print(result)
96
-    return(result)

+ 0
- 98
adminestudiantes.py Dosyayı Görüntüle

@@ -1,98 +0,0 @@
1
-# from sqlalchemy import metadata
2
-import sqlalchemy as db
3
-
4
-
5
-# connect to server
6
-engine = db.create_engine('mysql+pymysql://root:@0.0.0.0/registro_escolar_1')
7
-
8
-connection = engine.connect()
9
-# estudiantes = db.Table('estudiantes', metadata, autoload=True, autoload_with=engine)
10
-# usuarios = db.Table('usuarios', metadata, autoload=True, autoload_with=engine)
11
-
12
-def estudiantes():
13
-    query = 'SELECT u.id, u.nombres, u.apellidos, u.email FROM usuarios u, estudiantes m WHERE u.id = m.user_id'
14
-    result_db = connection.execute(query).fetchall()
15
-
16
-    ###### headers
17
-
18
-    headers = '['
19
-    headers += '{"nombre":"Nombre"}'
20
-    headers += ','
21
-    headers += '{"nombre":"Grado"}'
22
-    headers += ','
23
-    headers += '{"nombre":"Email"}'
24
-    headers += ','
25
-    headers += '{"nombre":"Informacion"}'
26
-    headers += ','
27
-    headers += '{"nombre":"Editar"}'
28
-    headers += ']'
29
-    # headers = '[{"nombre":"Nombre"},{"nombre":"Posicion"},{"nombre":"Informacion"},{"nombre":"Editar"}]'
30
-
31
-    ###### tabla
32
-
33
-
34
-    tabla = '['
35
-    modal_content = '['
36
-    i = 0
37
-    len_result = len(result_db)
38
-    for q in result_db:
39
-        i = i+1
40
-        tabla += '{'
41
-        modal_content += '{'
42
-        tabla += '"Nombre":"'+(q[1])+' '+(q[2])+'"'
43
-        modal_content += '"Nombre":"'+(q[1])+' '+(q[2])+'"'
44
-        tabla += ','
45
-        modal_content += ','
46
-
47
-        query = 'SELECT grado FROM estudiantes e WHERE e.user_id = ' + str(q[0])
48
-        total_hijos = connection.execute(query).fetchall()
49
-
50
-        tabla += '"Hijos Matriculados":"'+str(total_hijos[0][0])+'"'
51
-        modal_content += '"Hijos Matriculados":"'+str(total_hijos[0][0])+'"'
52
-
53
-        tabla += ','
54
-        modal_content += ','
55
-        tabla += '"Email":"'+(q[3])+'"'
56
-        modal_content += '"Email":"'+(q[3])+'"'
57
-        tabla += ','
58
-        modal_content += ','
59
-        tabla += '"user_id":"'+str(q[0])+'"'
60
-        modal_content += '"user_id":"'+str(q[0])+'"'
61
-        tabla += '}'
62
-        modal_content += '}'
63
-        if i < len_result:
64
-            tabla += ','
65
-            modal_content += ','
66
-    tabla += ']'
67
-    modal_content += ']'
68
-
69
-    ###### info
70
-
71
-    info = '{'
72
-    info += '"dash_name":"Manejar Estudiantes"'
73
-    info += ','
74
-    info += '"dash_link":"/admin/ver/"'
75
-    info += ','
76
-    info += '"dash_sub_name":"Estudiantes Registrados"'
77
-    info += ','
78
-    info += '"add":"Anadir Estudiantes"'
79
-    info += ','
80
-    info += '"add_link":"/admin/forma/add/estudiante/"'
81
-    info += ','
82
-    info += '"dir1":"#"'
83
-    info += ','
84
-    info += '"dir2":"/admin/forma/edit/estudiante/"'
85
-    info += '}'
86
-
87
-    ###### modal
88
-
89
-    modal = '{'
90
-    modal += '"infoName":"Ver informacion"'
91
-    modal += ','
92
-    modal += '"editName":"/admin/ver/"'
93
-    modal += '}'
94
-
95
-    result = '{"headers":'+headers+',"tabla":'+tabla+',"modal_content":'+modal_content+',"info":'+info+',"modal":'+modal+'}'
96
-
97
-    # print(result)
98
-    return(result)

+ 0
- 99
adminfacultad.py Dosyayı Görüntüle

@@ -1,99 +0,0 @@
1
-# from sqlalchemy import metadata
2
-import sqlalchemy as db
3
-
4
-# connect to server
5
-engine = db.create_engine('mysql+pymysql://root:@0.0.0.0/registro_escolar_1')
6
-
7
-connection = engine.connect()
8
-# estudiantes = db.Table('estudiantes', metadata, autoload=True, autoload_with=engine)
9
-# usuarios = db.Table('usuarios', metadata, autoload=True, autoload_with=engine)
10
-
11
-def facultad():
12
-
13
-    ###### headers
14
-
15
-    headers = '['
16
-    headers += '{"nombre":"Nombre"}'
17
-    headers += ','
18
-    headers += '{"nombre":"Especialidad"}'
19
-    headers += ','
20
-    headers += '{"nombre":"Email"}'
21
-    headers += ','
22
-    headers += '{"nombre":"Informacion"}'
23
-    headers += ','
24
-    headers += '{"nombre":"Editar"}'
25
-    headers += ']'
26
-    # headers = '[{"nombre":"Nombre"},{"nombre":"Posicion"},{"nombre":"Informacion"},{"nombre":"Editar"}]'
27
-
28
-
29
-    ###### tabla
30
-
31
-    query = 'SELECT u.id, u.nombres, u.apellidos, u.email FROM usuarios u,facultad f WHERE u.id = f.user_id'
32
-    result_db = connection.execute(query).fetchall()
33
-
34
-
35
-    tabla = '['
36
-    modal_content = '['
37
-    i = 0
38
-    len_result = len(result_db)
39
-    for q in result_db:
40
-        i = i+1
41
-        tabla += '{'
42
-        modal_content += '{'
43
-        tabla += '"Nombre":"'+(q[1])+' '+(q[2])+'"'
44
-        modal_content += '"Nombre":"'+(q[1])+' '+(q[2])+'"'
45
-        tabla += ','
46
-        modal_content += ','
47
-
48
-        query = 'SELECT f.especialidad FROM facultad f WHERE f.user_id =' + str(q[0])
49
-        total_hijos = connection.execute(query).fetchall()
50
-
51
-        tabla += '"Hijos Matriculados":"'+str(total_hijos[0][0])+'"'
52
-        modal_content += '"Hijos Matriculados":"'+str(total_hijos[0][0])+'"'
53
-
54
-        tabla += ','
55
-        modal_content += ','
56
-        tabla += '"Email":"'+(q[3])+'"'
57
-        modal_content += '"Email":"'+(q[3])+'"'
58
-        tabla += ','
59
-        modal_content += ','
60
-        tabla += '"user_id":"'+str(q[0])+'"'
61
-        modal_content += '"user_id":"'+str(q[0])+'"'
62
-        tabla += '}'
63
-        modal_content += '}'
64
-        if i < len_result:
65
-            tabla += ','
66
-            modal_content += ','
67
-    tabla += ']'
68
-    modal_content += ']'
69
-
70
-    ###### info
71
-
72
-    info = '{'
73
-    info += '"dash_name":"Manejar Facultad"'
74
-    info += ','
75
-    info += '"dash_link":"/admin/ver/"'
76
-    info += ','
77
-    info += '"dash_sub_name":"Facultad Registrados"'
78
-    info += ','
79
-    info += '"add":"Anadir Facultad"'
80
-    info += ','
81
-    info += '"add_link":"/admin/forma/add/facultad/"'
82
-    info += ','
83
-    info += '"dir1":"#"'
84
-    info += ','
85
-    info += '"dir2":"/admin/forma/edit/facultad/"'
86
-    info += '}'
87
-
88
-    ###### modal
89
-
90
-    modal = '{'
91
-    modal += '"infoName":"Ver informacion"'
92
-    modal += ','
93
-    modal += '"editName":"/admin/ver/"'
94
-    modal += '}'
95
-
96
-    result = '{"headers":'+headers+',"tabla":'+tabla+',"modal_content":'+modal_content+',"info":'+info+',"modal":'+modal+'}'
97
-
98
-    # print(result)
99
-    return(result)

+ 0
- 98
adminusers.py Dosyayı Görüntüle

@@ -1,98 +0,0 @@
1
-# from sqlalchemy import metadata
2
-import sqlalchemy as db
3
-
4
-
5
-import cgi
6
-
7
-# connect to server
8
-engine = db.create_engine('mysql+pymysql://root:@0.0.0.0/registro_escolar_1')
9
-
10
-connection = engine.connect()
11
-# estudiantes = db.Table('estudiantes', metadata, autoload=True, autoload_with=engine)
12
-# usuarios = db.Table('usuarios', metadata, autoload=True, autoload_with=engine)
13
-
14
-def users():
15
-    query = 'SELECT u.id, u.nombres, u.apellidos, u.email FROM usuarios u'
16
-    result_db = connection.execute(query).fetchall()
17
-
18
-    ###### headers
19
-
20
-    headers = '['
21
-    headers += '{"nombre":"Nombre"}'
22
-    headers += ','
23
-    headers += '{"nombre":"Email"}'
24
-    headers += ','
25
-    headers += '{"nombre":"Informacion"}'
26
-    headers += ','
27
-    headers += '{"nombre":"Editar"}'
28
-    headers += ']'
29
-    # headers = '[{"nombre":"Nombre"},{"nombre":"Posicion"},{"nombre":"Informacion"},{"nombre":"Editar"}]'
30
-
31
-    ###### tabla
32
-
33
-    # <a href="https://www.w3schools.com">Visit W3Schools</a>
34
-
35
-    # <head><base href="https://www.w3schools.com/images/"></head>
36
-
37
-    # <link rel="stylesheet" type="text/css" href="theme.css">
38
-
39
-    tabla = '['
40
-    i = 0
41
-    len_result = len(result_db)
42
-    for q in result_db:
43
-        i = i+1
44
-        tabla += '{'
45
-        name = q[1]+' '+q[2]
46
-        # name = 'aa'
47
-        name = cgi.escape(name)
48
-        tabla += '"Nombre":"'+name+'"'
49
-        tabla += ','
50
-        tabla += '"Email":"'+cgi.escape(q[3])+'"'
51
-        tabla += ','
52
-        tabla += '"user_id":"'+cgi.escape(str(q[0]))+'"'
53
-        tabla += '}'
54
-        if i < len_result:
55
-            tabla += ','
56
-    tabla += ']'
57
-
58
-    ###### info
59
-
60
-    info = '{'
61
-    info += '"dash_name":"Manejar test"'
62
-    info += ','
63
-    info += '"dash_link":"/admin/ver/"'
64
-    info += ','
65
-    info += '"dash_sub_name":"user Registrados"'
66
-    info += ','
67
-    info += '"add":"Anadir nada"'
68
-    info += ','
69
-    info += '"add_link":"#"'
70
-    info += ','
71
-    info += '"dir1":"#"'
72
-    info += ','
73
-    info += '"dir2":"#"'
74
-    info += '}'
75
-
76
-    ###### modal
77
-
78
-    modal = '{'
79
-    modal += '"infoName":"Ver informacion"'
80
-    modal += ','
81
-    modal += '"editName":"/admin/ver/"'
82
-    modal += '}'
83
-    # modal = '{"yeas":"yes"}'
84
-
85
-    # # result = '{'+headers+','+tabla+','+info+','+modal+'}'
86
-    # result = '{'
87
-    # result += '"headers":{'+headers+'}'
88
-    # result += ','
89
-    # result += '"tabla":{'+tabla+'}'
90
-    # result += ','
91
-    # result += '"info":'+info
92
-    # result += ','
93
-    # result += '"modal":{'+modal+'}'
94
-    # result += '}'
95
-    result = '{"headers":'+headers+',"tabla":'+tabla+',"info":'+info+',"modal":'+modal+'}'
96
-
97
-    # print(result)
98
-    return(result)

+ 459
- 0
adminver.py Dosyayı Görüntüle

@@ -9,6 +9,465 @@ connection = engine.connect()
9 9
 # estudiantes = db.Table('estudiantes', metadata, autoload=True, autoload_with=engine)
10 10
 # usuarios = db.Table('usuarios', metadata, autoload=True, autoload_with=engine)
11 11
 
12
+
13
+# esta funcion se obtiene cuando un administrador quiere ver los perfiles de administradores
14
+#   url: /admin/ver/admin
15
+def admin():
16
+    query = 'SELECT u.id, u.nombres, u.apellidos, u.email FROM usuarios u,administracion a WHERE u.id = a.user_id'
17
+    result_db = connection.execute(query).fetchall()
18
+
19
+    ###### headers
20
+
21
+    headers = '['
22
+    headers += '{"nombre":"Nombre"}'
23
+    headers += ','
24
+    headers += '{"nombre":"Posicion"}'
25
+    headers += ','
26
+    headers += '{"nombre":"Email"}'
27
+    headers += ','
28
+    headers += '{"nombre":"Informacion"}'
29
+    headers += ','
30
+    headers += '{"nombre":"Editar"}'
31
+    headers += ']'
32
+
33
+    ###### tabla
34
+
35
+
36
+    modal_content = '['
37
+    tabla = '['
38
+    i = 0
39
+    len_result = len(result_db)
40
+    for q in result_db:
41
+        i = i+1
42
+        tabla += '{'
43
+        modal_content += '{'
44
+        tabla += '"Nombre":"'+(q[1])+' '+(q[2])+'"'
45
+        modal_content += '"Nombre":"'+(q[1])+' '+(q[2])+'"'
46
+        tabla += ','
47
+        modal_content += ','
48
+
49
+        query = 'SELECT posicion FROM administracion a WHERE a.user_id = ' + str(q[0])
50
+        posicion = connection.execute(query).fetchall()
51
+
52
+        tabla += '"Posicion":"'+(str(posicion[0][0]))+'"'
53
+        modal_content += '"Posicion":"'+(str(posicion[0][0]))+'"'
54
+
55
+        tabla += ','
56
+        modal_content += ','
57
+        tabla += '"Email":"'+(q[3])+'"'
58
+        modal_content += '"Email":"'+(q[3])+'"'
59
+        tabla += ','
60
+        modal_content += ','
61
+        tabla += '"user_id":"'+(str(q[0]))+'"'
62
+        modal_content += '"user_id":"'+(str(q[0]))+'"'
63
+        tabla += '}'
64
+        modal_content += '}'
65
+        if i < len_result:
66
+            tabla += ','
67
+            modal_content += ','
68
+    tabla += ']'
69
+    modal_content += ']'
70
+
71
+    ###### info
72
+
73
+    info = '{'
74
+    info += '"dash_name":"Manejar Administracion"'
75
+    info += ','
76
+    info += '"dash_link":"/admin/ver/"'
77
+    info += ','
78
+    info += '"dash_sub_name":"Administracion Registrados"'
79
+    info += ','
80
+    info += '"add":"Anadir Administracion"'
81
+    info += ','
82
+    info += '"add_link":"/admin/forma/add/administracion/"'
83
+    info += ','
84
+    info += '"dir1":"#"'
85
+    info += ','
86
+    info += '"dir2":"/admin/forma/edit/administracion/"'
87
+    info += '}'
88
+
89
+    ###### modal
90
+
91
+    modal = '{'
92
+    modal += '"infoName":"Ver informacion"'
93
+    modal += ','
94
+    modal += '"editName":"/admin/ver/"'
95
+    modal += '}'
96
+
97
+    result = '{"headers":'+headers+',"tabla":'+tabla+',"modal_content":'+modal_content+',"info":'+info+',"modal":'+modal+'}'
98
+
99
+    # print(result)
100
+    return(result)
101
+
102
+# esta funcion se obtiene cuando un administrador quiere ver los perfiles de encargados
103
+#   url: /admin/ver/encargados
104
+def encargados():
105
+    query = 'SELECT u.id, u.nombres, u.apellidos, u.email FROM usuarios u,madres m WHERE u.id = m.user_id'
106
+    result_db = connection.execute(query).fetchall()
107
+
108
+    ###### headers
109
+
110
+    headers = '['
111
+    headers += '{"nombre":"Nombre"}'
112
+    headers += ','
113
+    headers += '{"nombre":"Hijos matriculados"}'
114
+    headers += ','
115
+    headers += '{"nombre":"Especialidad"}'
116
+    headers += ','
117
+    headers += '{"nombre":"Informacion"}'
118
+    headers += ','
119
+    headers += '{"nombre":"Editar"}'
120
+    headers += ']'
121
+
122
+    ###### tabla
123
+
124
+
125
+    tabla = '['
126
+    modal_content = '['
127
+    i = 0
128
+    len_result = len(result_db)
129
+    for q in result_db:
130
+        i = i+1
131
+        tabla += '{'
132
+        modal_content += '{'
133
+        tabla += '"Nombre":"'+(q[1])+' '+(q[2])+'"'
134
+        modal_content += '"Nombre":"'+(q[1])+' '+(q[2])+'"'
135
+        tabla += ','
136
+        modal_content += ','
137
+
138
+        query = 'SELECT count(*) FROM madres_estudiantes me WHERE me.madre_id = ' + str(q[0])
139
+        total_hijos = connection.execute(query).fetchall()
140
+
141
+        tabla += '"Hijos Matriculados":"'+str(total_hijos[0][0])+'"'
142
+        modal_content += '"Hijos Matriculados":"'+str(total_hijos[0][0])+'"'
143
+
144
+        tabla += ','
145
+        modal_content += ','
146
+        tabla += '"Email":"'+(q[3])+'"'
147
+        modal_content += '"Email":"'+(q[3])+'"'
148
+        tabla += ','
149
+        modal_content += ','
150
+        tabla += '"user_id":"'+str(q[0])+'"'
151
+        modal_content += '"user_id":"'+str(q[0])+'"'
152
+        tabla += '}'
153
+        modal_content += '}'
154
+        if i < len_result:
155
+            tabla += ','
156
+            modal_content += ','
157
+    tabla += ']'
158
+    modal_content += ']'
159
+
160
+    ###### info
161
+
162
+    info = '{'
163
+    info += '"dash_name":"Manejar Encargados"'
164
+    info += ','
165
+    info += '"dash_link":"/admin/ver/"'
166
+    info += ','
167
+    info += '"dash_sub_name":"Encargados Registrados"'
168
+    info += ','
169
+    info += '"add":"Anadir Encargados"'
170
+    info += ','
171
+    info += '"add_link":"/admin/forma/add/madre/"'
172
+    info += ','
173
+    info += '"dir1":"#"'
174
+    info += ','
175
+    info += '"dir2":"/admin/forma/edit/madre/"'
176
+    info += '}'
177
+
178
+    ###### modal
179
+
180
+    modal = '{'
181
+    modal += '"infoName":"Ver informacion"'
182
+    modal += ','
183
+    modal += '"editName":"/admin/ver/"'
184
+    modal += '}'
185
+
186
+    result = '{"headers":'+headers+',"tabla":'+tabla+',"modal_content":'+modal_content+',"info":'+info+',"modal":'+modal+'}'
187
+
188
+    # print(result)
189
+    return(result)
190
+
191
+
192
+# esta funcion se obtiene cuando un administrador quiere ver los perfiles de enfermeras
193
+#   url: /admin/ver/enfermeria
194
+def enfermeria():
195
+    query = 'SELECT u.id, u.nombres, u.apellidos, u.email FROM usuarios u,enfermeras e WHERE u.id = e.user_id'
196
+    result_db = connection.execute(query).fetchall()
197
+
198
+    ###### headers
199
+
200
+    headers = '['
201
+    headers += '{"nombre":"Nombre"}'
202
+    headers += ','
203
+    headers += '{"nombre":"Especialidad"}'
204
+    headers += ','
205
+    headers += '{"nombre":"Email"}'
206
+    headers += ','
207
+    headers += '{"nombre":"Informacion"}'
208
+    headers += ','
209
+    headers += '{"nombre":"Editar"}'
210
+    headers += ']'
211
+
212
+    ###### tabla
213
+
214
+
215
+    tabla = '['
216
+    modal_content = '['
217
+    i = 0
218
+    len_result = len(result_db)
219
+    for q in result_db:
220
+        i = i+1
221
+        tabla += '{'
222
+        modal_content += '{'
223
+        tabla += '"Nombre":"'+(q[1])+' '+(q[2])+'"'
224
+        modal_content += '"Nombre":"'+(q[1])+' '+(q[2])+'"'
225
+        tabla += ','
226
+        modal_content += ','
227
+
228
+        query = 'SELECT especialidad FROM enfermeras e WHERE e.user_id = ' + str(q[0])
229
+        especialidad = connection.execute(query).fetchall()
230
+
231
+        tabla += '"Especialidad":"'+(str(especialidad[0][0]))+'"'
232
+        modal_content += '"Especialidad":"'+(str(especialidad[0][0]))+'"'
233
+
234
+        tabla += ','
235
+        modal_content += ','
236
+        tabla += '"Email":"'+(q[3])+'"'
237
+        modal_content += '"Email":"'+(q[3])+'"'
238
+        tabla += ','
239
+        modal_content += ','
240
+        tabla += '"user_id":"'+str(q[0])+'"'
241
+        modal_content += '"user_id":"'+str(q[0])+'"'
242
+        tabla += '}'
243
+        modal_content += '}'
244
+        if i < len_result:
245
+            tabla += ','
246
+            modal_content += ','
247
+    tabla += ']'
248
+    modal_content += ']'
249
+
250
+    ###### info
251
+
252
+    info = '{'
253
+    info += '"dash_name":"Manejar Enfermeria"'
254
+    info += ','
255
+    info += '"dash_link":"/admin/ver/"'
256
+    info += ','
257
+    info += '"dash_sub_name":"Enfermeras Registrados"'
258
+    info += ','
259
+    info += '"add":"Anadir Enfermera"'
260
+    info += ','
261
+    info += '"add_link":"/admin/forma/add/enfermera/"'
262
+    info += ','
263
+    info += '"dir1":"#"'
264
+    info += ','
265
+    info += '"dir2":"/admin/forma/edit/enfermera/"'
266
+    info += '}'
267
+
268
+    ###### modal
269
+
270
+    modal = '{'
271
+    modal += '"infoName":"Ver informacion"'
272
+    modal += ','
273
+    modal += '"editName":"/admin/ver/"'
274
+    modal += '}'
275
+
276
+    result = '{"headers":'+headers+',"tabla":'+tabla+',"modal_content":'+modal_content+',"info":'+info+',"modal":'+modal+'}'
277
+
278
+    # print(result)
279
+    return(result)
280
+
281
+
282
+# esta funcion se obtiene cuando un administrador quiere ver los perfiles de estudiantes
283
+#   url: /admin/ver/estudiantes
284
+def estudiantes():
285
+    query = 'SELECT u.id, u.nombres, u.apellidos, u.email FROM usuarios u, estudiantes m WHERE u.id = m.user_id'
286
+    result_db = connection.execute(query).fetchall()
287
+
288
+    ###### headers
289
+
290
+    headers = '['
291
+    headers += '{"nombre":"Nombre"}'
292
+    headers += ','
293
+    headers += '{"nombre":"Grado"}'
294
+    headers += ','
295
+    headers += '{"nombre":"Email"}'
296
+    headers += ','
297
+    headers += '{"nombre":"Informacion"}'
298
+    headers += ','
299
+    headers += '{"nombre":"Editar"}'
300
+    headers += ']'
301
+    # headers = '[{"nombre":"Nombre"},{"nombre":"Posicion"},{"nombre":"Informacion"},{"nombre":"Editar"}]'
302
+
303
+    ###### tabla
304
+
305
+
306
+    tabla = '['
307
+    modal_content = '['
308
+    i = 0
309
+    len_result = len(result_db)
310
+    for q in result_db:
311
+        i = i+1
312
+        tabla += '{'
313
+        modal_content += '{'
314
+        tabla += '"Nombre":"'+(q[1])+' '+(q[2])+'"'
315
+        modal_content += '"Nombre":"'+(q[1])+' '+(q[2])+'"'
316
+        tabla += ','
317
+        modal_content += ','
318
+
319
+        query = 'SELECT grado FROM estudiantes e WHERE e.user_id = ' + str(q[0])
320
+        total_hijos = connection.execute(query).fetchall()
321
+
322
+        tabla += '"Hijos Matriculados":"'+str(total_hijos[0][0])+'"'
323
+        modal_content += '"Hijos Matriculados":"'+str(total_hijos[0][0])+'"'
324
+
325
+        tabla += ','
326
+        modal_content += ','
327
+        tabla += '"Email":"'+(q[3])+'"'
328
+        modal_content += '"Email":"'+(q[3])+'"'
329
+        tabla += ','
330
+        modal_content += ','
331
+        tabla += '"user_id":"'+str(q[0])+'"'
332
+        modal_content += '"user_id":"'+str(q[0])+'"'
333
+        tabla += '}'
334
+        modal_content += '}'
335
+        if i < len_result:
336
+            tabla += ','
337
+            modal_content += ','
338
+    tabla += ']'
339
+    modal_content += ']'
340
+
341
+    ###### info
342
+
343
+    info = '{'
344
+    info += '"dash_name":"Manejar Estudiantes"'
345
+    info += ','
346
+    info += '"dash_link":"/admin/ver/"'
347
+    info += ','
348
+    info += '"dash_sub_name":"Estudiantes Registrados"'
349
+    info += ','
350
+    info += '"add":"Anadir Estudiantes"'
351
+    info += ','
352
+    info += '"add_link":"/admin/forma/add/estudiante/"'
353
+    info += ','
354
+    info += '"dir1":"#"'
355
+    info += ','
356
+    info += '"dir2":"/admin/forma/edit/estudiante/"'
357
+    info += '}'
358
+
359
+    ###### modal
360
+
361
+    modal = '{'
362
+    modal += '"infoName":"Ver informacion"'
363
+    modal += ','
364
+    modal += '"editName":"/admin/ver/"'
365
+    modal += '}'
366
+
367
+    result = '{"headers":'+headers+',"tabla":'+tabla+',"modal_content":'+modal_content+',"info":'+info+',"modal":'+modal+'}'
368
+
369
+    # print(result)
370
+    return(result)
371
+
372
+
373
+
374
+
375
+# esta funcion se obtiene cuando un administrador quiere ver los perfiles de
376
+#   url: /admin/ver/facultad
377
+def facultad():
378
+
379
+    ###### headers
380
+
381
+    headers = '['
382
+    headers += '{"nombre":"Nombre"}'
383
+    headers += ','
384
+    headers += '{"nombre":"Especialidad"}'
385
+    headers += ','
386
+    headers += '{"nombre":"Email"}'
387
+    headers += ','
388
+    headers += '{"nombre":"Informacion"}'
389
+    headers += ','
390
+    headers += '{"nombre":"Editar"}'
391
+    headers += ']'
392
+    # headers = '[{"nombre":"Nombre"},{"nombre":"Posicion"},{"nombre":"Informacion"},{"nombre":"Editar"}]'
393
+
394
+
395
+    ###### tabla
396
+
397
+    query = 'SELECT u.id, u.nombres, u.apellidos, u.email FROM usuarios u,facultad f WHERE u.id = f.user_id'
398
+    result_db = connection.execute(query).fetchall()
399
+
400
+
401
+    tabla = '['
402
+    modal_content = '['
403
+    i = 0
404
+    len_result = len(result_db)
405
+    for q in result_db:
406
+        i = i+1
407
+        tabla += '{'
408
+        modal_content += '{'
409
+        tabla += '"Nombre":"'+(q[1])+' '+(q[2])+'"'
410
+        modal_content += '"Nombre":"'+(q[1])+' '+(q[2])+'"'
411
+        tabla += ','
412
+        modal_content += ','
413
+
414
+        query = 'SELECT f.especialidad FROM facultad f WHERE f.user_id =' + str(q[0])
415
+        total_hijos = connection.execute(query).fetchall()
416
+
417
+        tabla += '"Hijos Matriculados":"'+str(total_hijos[0][0])+'"'
418
+        modal_content += '"Hijos Matriculados":"'+str(total_hijos[0][0])+'"'
419
+
420
+        tabla += ','
421
+        modal_content += ','
422
+        tabla += '"Email":"'+(q[3])+'"'
423
+        modal_content += '"Email":"'+(q[3])+'"'
424
+        tabla += ','
425
+        modal_content += ','
426
+        tabla += '"user_id":"'+str(q[0])+'"'
427
+        modal_content += '"user_id":"'+str(q[0])+'"'
428
+        tabla += '}'
429
+        modal_content += '}'
430
+        if i < len_result:
431
+            tabla += ','
432
+            modal_content += ','
433
+    tabla += ']'
434
+    modal_content += ']'
435
+
436
+    ###### info
437
+
438
+    info = '{'
439
+    info += '"dash_name":"Manejar Facultad"'
440
+    info += ','
441
+    info += '"dash_link":"/admin/ver/"'
442
+    info += ','
443
+    info += '"dash_sub_name":"Facultad Registrados"'
444
+    info += ','
445
+    info += '"add":"Anadir Facultad"'
446
+    info += ','
447
+    info += '"add_link":"/admin/forma/add/facultad/"'
448
+    info += ','
449
+    info += '"dir1":"#"'
450
+    info += ','
451
+    info += '"dir2":"/admin/forma/edit/facultad/"'
452
+    info += '}'
453
+
454
+    ###### modal
455
+
456
+    modal = '{'
457
+    modal += '"infoName":"Ver informacion"'
458
+    modal += ','
459
+    modal += '"editName":"/admin/ver/"'
460
+    modal += '}'
461
+
462
+    result = '{"headers":'+headers+',"tabla":'+tabla+',"modal_content":'+modal_content+',"info":'+info+',"modal":'+modal+'}'
463
+
464
+    # print(result)
465
+    return(result)
466
+
467
+
468
+# esta funcion se obtiene cuando un administrador quiere ver las visitas a la oficina
469
+#   url: /admin/ver/visitas_oficina
470
+
12 471
 def visita():
13 472
     query ='SELECT t1.id, t2.nombres e_nombre, t2.apellidos e_apellido,\
14 473
                 t1.nombres p_nombre, t1.apellidos p_apellido, t1.razon, t1.acciones\

+ 9
- 20
dash-run.py Dosyayı Görüntüle

@@ -2,8 +2,8 @@
2 2
 from flask import Flask, render_template, render_template_string, redirect, request, session, escape, url_for, jsonify, abort
3 3
 import os
4 4
 
5
-import adminadmin, adminfacultad, adminenfermeria, adminencargados, adminestudiantes, adminver
6
-import enfermeria
5
+import adminver
6
+import enfermeriaver
7 7
 
8 8
 
9 9
 app = Flask(__name__)
@@ -14,14 +14,6 @@ def home():
14 14
     return render_template('dash.html', jscript="perfilesInfo.js")
15 15
 
16 16
 
17
-#################################
18
-import adminusers
19
-@app.route("/users/", methods=['GET', 'POST'])
20
-def users():
21
-    return render_template('table.html', jscript="adminver.js", pagina='users')
22
-#################################
23
-
24
-
25 17
 @app.route("/<perfil>/ver/", methods=['GET', 'POST'])
26 18
 @app.route("/<perfil>/ver/<pagina>/", methods=['GET', 'POST'])
27 19
 def perfil(perfil, pagina=None):
@@ -52,24 +44,21 @@ def perfil(perfil, pagina=None):
52 44
 def datos(perfil, pagina=None):
53 45
     if(perfil=="admin"):
54 46
         if(pagina=="admin"):
55
-            return adminadmin.admin()
47
+            return adminver.admin()
56 48
         if(pagina=="facultad"):
57
-            return adminfacultad.facultad()
49
+            return adminver.facultad()
58 50
         if(pagina=="enfermeria"):
59
-            return adminenfermeria.enfermeria()
51
+            return adminver.enfermeria()
60 52
         if(pagina=="encargados"):
61
-            return adminencargados.encargados()
53
+            return adminver.encargados()
62 54
         if(pagina=="estudiantes"):
63
-            return adminestudiantes.estudiantes()
55
+            return adminver.estudiantes()
64 56
         if(pagina=="visita"):
65 57
             return adminver.visita()
66 58
     if(perfil=="enfermeria"):
67 59
         if(pagina=="visitas"):
68
-            return enfermeria.visitas()
69
-#################################
70
-        if(pagina=="users"):
71
-            return adminusers.users()
72
-#################################
60
+            return enfermeriaver.visitas()
61
+
73 62
 
74 63
 from flask import Flask, render_template, request, redirect, url_for
75 64
 import json

enfermeria.py → enfermeriaver.py Dosyayı Görüntüle