Переглянути джерело

añadi mis archivos, (oniel)

no deberian haber cambios en index.py, los borré
Oniel Méndez Nieves 4 роки тому
джерело
коміт
d30749ba21

+ 111
- 0
adminadmin.py Переглянути файл

@@ -0,0 +1,111 @@
1
+# from sqlalchemy import metadata
2
+import sqlalchemy as db
3
+
4
+#########################
5
+# stack overflow:
6
+    # Python sanitizing html from a string
7
+def escape(htmlstring):
8
+    escapes = {'\"': '"',
9
+               '\'': ''',
10
+               '<': '&lt;',
11
+               '>': '&gt;'}
12
+    # This is done first to prevent escaping other escapes.
13
+    htmlstring = htmlstring.replace('&', '&amp;')
14
+    for seq, esc in escapes.iteritems():
15
+        htmlstring = htmlstring.replace(seq, esc)
16
+    return htmlstring
17
+#########################
18
+
19
+# connect to server
20
+engine = db.create_engine('mysql+pymysql://root:@0.0.0.0/registro_escolar_1')
21
+
22
+connection = engine.connect()
23
+# estudiantes = db.Table('estudiantes', metadata, autoload=True, autoload_with=engine)
24
+# usuarios = db.Table('usuarios', metadata, autoload=True, autoload_with=engine)
25
+
26
+def admin():
27
+    query = 'SELECT u.id, u.nombres, u.apellidos, u.email FROM usuarios u,administracion a WHERE u.id = a.user_id'
28
+    result_db = connection.execute(query).fetchall()
29
+
30
+    ###### headers
31
+
32
+    headers = '['
33
+    headers += '{"nombre":"Nombre"}'
34
+    headers += ','
35
+    headers += '{"nombre":"Posicion"}'
36
+    headers += ','
37
+    headers += '{"nombre":"Email"}'
38
+    headers += ','
39
+    headers += '{"nombre":"Informacion"}'
40
+    headers += ','
41
+    headers += '{"nombre":"Editar"}'
42
+    headers += ']'
43
+    # headers = '[{"nombre":"Nombre"},{"nombre":"Posicion"},{"nombre":"Informacion"},{"nombre":"Editar"}]'
44
+
45
+    ###### tabla
46
+
47
+
48
+    tabla = '['
49
+    i = 0
50
+    len_result = len(result_db)
51
+    for q in result_db:
52
+        i = i+1
53
+        tabla += '{'
54
+        tabla += '"Nombre":"'+escape(q[1])+escape(q[2])+'"'
55
+        tabla += ','
56
+
57
+        query = 'SELECT posicion FROM administracion a WHERE a.user_id = ' + str(q[0])
58
+        posicion = connection.execute(query).fetchall()
59
+
60
+        tabla += '"Posicion":"'+escape(str(posicion[0][0]))+'"'
61
+        # tabla += '"ID":"'+str(q[0])+'"'
62
+        tabla += ','
63
+        tabla += '"Email":"'+escape(q[3])+'"'
64
+        tabla += ','
65
+        tabla += '"user_id":"'+escape(str(q[0]))+'"'
66
+        tabla += '}'
67
+        if i < len_result:
68
+            tabla += ','
69
+    tabla += ']'
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":"#"'
83
+    info += ','
84
+    info += '"dir1":"#"'
85
+    info += ','
86
+    info += '"dir2":"#"'
87
+    info += '}'
88
+
89
+    ###### modal
90
+
91
+    modal = '{'
92
+    modal += '"infoName":"Ver informacion"'
93
+    modal += ','
94
+    modal += '"editName":"/admin/ver/"'
95
+    modal += '}'
96
+    # modal = '{"yeas":"yes"}'
97
+
98
+    # # result = '{'+headers+','+tabla+','+info+','+modal+'}'
99
+    # result = '{'
100
+    # result += '"headers":{'+headers+'}'
101
+    # result += ','
102
+    # result += '"tabla":{'+tabla+'}'
103
+    # result += ','
104
+    # result += '"info":'+info
105
+    # result += ','
106
+    # result += '"modal":{'+modal+'}'
107
+    # result += '}'
108
+    result = '{"headers":'+headers+',"tabla":'+tabla+',"info":'+info+',"modal":'+modal+'}'
109
+
110
+    # print(result)
111
+    return(result)

BIN
adminadmin.pyc Переглянути файл


+ 111
- 0
adminencargados.py Переглянути файл

@@ -0,0 +1,111 @@
1
+# from sqlalchemy import metadata
2
+import sqlalchemy as db
3
+
4
+#########################
5
+# stack overflow:
6
+    # Python sanitizing html from a string
7
+def escape(htmlstring):
8
+    escapes = {'\"': '&quot;',
9
+               '\'': '&#39;',
10
+               '<': '&lt;',
11
+               '>': '&gt;'}
12
+    # This is done first to prevent escaping other escapes.
13
+    htmlstring = htmlstring.replace('&', '&amp;')
14
+    for seq, esc in escapes.iteritems():
15
+        htmlstring = htmlstring.replace(seq, esc)
16
+    return htmlstring
17
+#########################
18
+
19
+# connect to server
20
+engine = db.create_engine('mysql+pymysql://root:@0.0.0.0/registro_escolar_1')
21
+
22
+connection = engine.connect()
23
+# estudiantes = db.Table('estudiantes', metadata, autoload=True, autoload_with=engine)
24
+# usuarios = db.Table('usuarios', metadata, autoload=True, autoload_with=engine)
25
+
26
+def encargados():
27
+    query = 'SELECT u.id, u.nombres, u.apellidos, u.email FROM usuarios u,madres m WHERE u.id = m.user_id'
28
+    result_db = connection.execute(query).fetchall()
29
+
30
+    ###### headers
31
+
32
+    headers = '['
33
+    headers += '{"nombre":"Nombre"}'
34
+    headers += ','
35
+    headers += '{"nombre":"Hijos matriculados"}'
36
+    headers += ','
37
+    headers += '{"nombre":"Especialidad"}'
38
+    headers += ','
39
+    headers += '{"nombre":"Informacion"}'
40
+    headers += ','
41
+    headers += '{"nombre":"Editar"}'
42
+    headers += ']'
43
+    # headers = '[{"nombre":"Nombre"},{"nombre":"Posicion"},{"nombre":"Informacion"},{"nombre":"Editar"}]'
44
+
45
+    ###### tabla
46
+
47
+
48
+    tabla = '['
49
+    i = 0
50
+    len_result = len(result_db)
51
+    for q in result_db:
52
+        i = i+1
53
+        tabla += '{'
54
+        tabla += '"Nombre":"'+escape(q[1])+' '+escape(q[2])+'"'
55
+        tabla += ','
56
+
57
+        query = 'SELECT count(*) FROM madres_estudiantes me WHERE me.madre_id = ' + str(q[0])
58
+        total_hijos = connection.execute(query).fetchall()
59
+
60
+        tabla += '"Hijos Matriculados":"'+str(total_hijos[0][0])+'"'
61
+        # tabla += '"ID":"'+str(q[0])+'"'
62
+        tabla += ','
63
+        tabla += '"Email":"'+escape(q[3])+'"'
64
+        tabla += ','
65
+        tabla += '"user_id":"'+str(q[0])+'"'
66
+        tabla += '}'
67
+        if i < len_result:
68
+            tabla += ','
69
+    tabla += ']'
70
+
71
+    ###### info
72
+
73
+    info = '{'
74
+    info += '"dash_name":"Manejar Encargados"'
75
+    info += ','
76
+    info += '"dash_link":"/admin/ver/"'
77
+    info += ','
78
+    info += '"dash_sub_name":"Encargados Registrados"'
79
+    info += ','
80
+    info += '"add":"Anadir Encargados"'
81
+    info += ','
82
+    info += '"add_link":"#"'
83
+    info += ','
84
+    info += '"dir1":"#"'
85
+    info += ','
86
+    info += '"dir2":"#"'
87
+    info += '}'
88
+
89
+    ###### modal
90
+
91
+    modal = '{'
92
+    modal += '"infoName":"Ver informacion"'
93
+    modal += ','
94
+    modal += '"editName":"/admin/ver/"'
95
+    modal += '}'
96
+    # modal = '{"yeas":"yes"}'
97
+
98
+    # # result = '{'+headers+','+tabla+','+info+','+modal+'}'
99
+    # result = '{'
100
+    # result += '"headers":{'+headers+'}'
101
+    # result += ','
102
+    # result += '"tabla":{'+tabla+'}'
103
+    # result += ','
104
+    # result += '"info":'+info
105
+    # result += ','
106
+    # result += '"modal":{'+modal+'}'
107
+    # result += '}'
108
+    result = '{"headers":'+headers+',"tabla":'+tabla+',"info":'+info+',"modal":'+modal+'}'
109
+
110
+    # print(result)
111
+    return(result)

BIN
adminencargados.pyc Переглянути файл


+ 111
- 0
adminenfermeria.py Переглянути файл

@@ -0,0 +1,111 @@
1
+# from sqlalchemy import metadata
2
+import sqlalchemy as db
3
+
4
+#########################
5
+# stack overflow:
6
+    # Python sanitizing html from a string
7
+def escape(htmlstring):
8
+    escapes = {'\"': '&quot;',
9
+               '\'': '&#39;',
10
+               '<': '&lt;',
11
+               '>': '&gt;'}
12
+    # This is done first to prevent escaping other escapes.
13
+    htmlstring = htmlstring.replace('&', '&amp;')
14
+    for seq, esc in escapes.iteritems():
15
+        htmlstring = htmlstring.replace(seq, esc)
16
+    return htmlstring
17
+#########################
18
+
19
+# connect to server
20
+engine = db.create_engine('mysql+pymysql://root:@0.0.0.0/registro_escolar_1')
21
+
22
+connection = engine.connect()
23
+# estudiantes = db.Table('estudiantes', metadata, autoload=True, autoload_with=engine)
24
+# usuarios = db.Table('usuarios', metadata, autoload=True, autoload_with=engine)
25
+
26
+def enfermeria():
27
+    query = 'SELECT u.id, u.nombres, u.apellidos, u.email FROM usuarios u,enfermeras e WHERE u.id = e.user_id'
28
+    result_db = connection.execute(query).fetchall()
29
+
30
+    ###### headers
31
+
32
+    headers = '['
33
+    headers += '{"nombre":"Nombre"}'
34
+    headers += ','
35
+    headers += '{"nombre":"Especialidad"}'
36
+    headers += ','
37
+    headers += '{"nombre":"Email"}'
38
+    headers += ','
39
+    headers += '{"nombre":"Informacion"}'
40
+    headers += ','
41
+    headers += '{"nombre":"Editar"}'
42
+    headers += ']'
43
+    # headers = '[{"nombre":"Nombre"},{"nombre":"Posicion"},{"nombre":"Informacion"},{"nombre":"Editar"}]'
44
+
45
+    ###### tabla
46
+
47
+
48
+    tabla = '['
49
+    i = 0
50
+    len_result = len(result_db)
51
+    for q in result_db:
52
+        i = i+1
53
+        tabla += '{'
54
+        tabla += '"Nombre":"'+escape(q[1])+' '+escape(q[2])+'"'
55
+        tabla += ','
56
+
57
+        query = 'SELECT especialidad FROM enfermeras e WHERE e.user_id = ' + str(q[0])
58
+        especialidad = connection.execute(query).fetchall()
59
+
60
+        tabla += '"Especialidad":"'+escape(str(especialidad[0][0]))+'"'
61
+        # tabla += '"ID":"'+str(q[0])+'"'
62
+        tabla += ','
63
+        tabla += '"Email":"'+escape(q[3])+'"'
64
+        tabla += ','
65
+        tabla += '"user_id":"'+str(q[0])+'"'
66
+        tabla += '}'
67
+        if i < len_result:
68
+            tabla += ','
69
+    tabla += ']'
70
+
71
+    ###### info
72
+
73
+    info = '{'
74
+    info += '"dash_name":"Manejar Enfermeria"'
75
+    info += ','
76
+    info += '"dash_link":"/admin/ver/"'
77
+    info += ','
78
+    info += '"dash_sub_name":"Enfermeras Registrados"'
79
+    info += ','
80
+    info += '"add":"Anadir Enfermera"'
81
+    info += ','
82
+    info += '"add_link":"#"'
83
+    info += ','
84
+    info += '"dir1":"#"'
85
+    info += ','
86
+    info += '"dir2":"#"'
87
+    info += '}'
88
+
89
+    ###### modal
90
+
91
+    modal = '{'
92
+    modal += '"infoName":"Ver informacion"'
93
+    modal += ','
94
+    modal += '"editName":"/admin/ver/"'
95
+    modal += '}'
96
+    # modal = '{"yeas":"yes"}'
97
+
98
+    # # result = '{'+headers+','+tabla+','+info+','+modal+'}'
99
+    # result = '{'
100
+    # result += '"headers":{'+headers+'}'
101
+    # result += ','
102
+    # result += '"tabla":{'+tabla+'}'
103
+    # result += ','
104
+    # result += '"info":'+info
105
+    # result += ','
106
+    # result += '"modal":{'+modal+'}'
107
+    # result += '}'
108
+    result = '{"headers":'+headers+',"tabla":'+tabla+',"info":'+info+',"modal":'+modal+'}'
109
+
110
+    # print(result)
111
+    return(result)

BIN
adminenfermeria.pyc Переглянути файл


+ 111
- 0
adminestudiantes.py Переглянути файл

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

BIN
adminestudiantes.pyc Переглянути файл


+ 113
- 0
adminfacultad.py Переглянути файл

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

BIN
adminfacultad.pyc Переглянути файл


+ 112
- 0
adminusers.py Переглянути файл

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

BIN
adminusers.pyc Переглянути файл


+ 73
- 0
dash-run.py Переглянути файл

@@ -0,0 +1,73 @@
1
+from flask import Flask, render_template, render_template_string, redirect, request, session, escape, url_for, jsonify, abort
2
+import os
3
+
4
+##############################################
5
+# de stack overflow:
6
+#   Changing default encoding of Python?
7
+import sys
8
+# sys.setdefaultencoding() does not exist, here!
9
+reload(sys)  # Reload does the trick!
10
+sys.setdefaultencoding('UTF8')
11
+##############################################
12
+
13
+import adminadmin, adminfacultad, adminenfermeria, adminencargados, adminestudiantes
14
+
15
+
16
+app = Flask(__name__)
17
+
18
+@app.route("/", methods=['GET', 'POST'])
19
+@app.route("/home/", methods=['GET', 'POST'])
20
+def home():
21
+    return render_template('dash.html', jscript="perfilesInfo.js")
22
+
23
+
24
+#################################
25
+import adminusers
26
+@app.route("/users/", methods=['GET', 'POST'])
27
+def users():
28
+    return render_template('table.html', jscript="adminver.js", pagina='users')
29
+#################################
30
+
31
+
32
+@app.route("/<perfil>/ver/", methods=['GET', 'POST'])
33
+@app.route("/<perfil>/ver/<pagina>/", methods=['GET', 'POST'])
34
+def perfil(perfil, pagina=None):
35
+    if (perfil=='admin'):
36
+        if (pagina==None):
37
+            return render_template('dash.html', jscript="admin.js", pagina=pagina)
38
+        if(pagina in ['admin','facultad','enfermeria','encargados','estudiantes']):
39
+            return render_template('table.html', jscript="adminver.js", pagina=pagina)
40
+    return render_template('error.html')
41
+
42
+# @app.route("/<perfil>/editar/<pagina>/", methods=['GET', 'POST'])
43
+# @app.route("/<perfil>/editar/<pagina>/<id>", methods=['GET', 'POST'])
44
+# def perfil(perfil, pagina, id=None):
45
+#     if (perfil=='admin'):
46
+#         if (pagina=='estudiante'):
47
+#             return render_template('dash.html', jscript="admin.js", pagina=pagina)
48
+#         if(pagina in ['admin','facultad','enfermeria','encargados','estudiantes']):
49
+#             return render_template('table.html', jscript="adminver.js", pagina=pagina)
50
+#     return render_template('error.html')
51
+
52
+@app.route('/<perfil>/datos/', methods=['GET', 'POST'])
53
+@app.route('/<perfil>/datos/<pagina>/', methods=['GET', 'POST'])
54
+def datos(perfil, pagina=None):
55
+    if(perfil=="admin"):
56
+        if(pagina=="admin"):
57
+            return adminadmin.admin()
58
+        if(pagina=="facultad"):
59
+            return adminfacultad.facultad()
60
+        if(pagina=="enfermeria"):
61
+            return adminenfermeria.enfermeria()
62
+        if(pagina=="encargados"):
63
+            return adminencargados.encargados()
64
+        if(pagina=="estudiantes"):
65
+            return adminestudiantes.estudiantes()
66
+#################################
67
+        if(pagina=="users"):
68
+            return adminusers.users()
69
+#################################
70
+
71
+app.secret_key = os.urandom(52)
72
+if __name__ == "__main__":
73
+    app.run(host='0.0.0.0', port=9000, debug=True)

+ 3
- 3
index.py Переглянути файл

@@ -15,13 +15,13 @@ def procesaUser():
15 15
 	data = request.form
16 16
 	tipo_accion = getattr(__import__(data["tipo"]), data["accion"])
17 17
 	return tipo_accion(data)
18
-		
18
+
19 19
 @app.route('/admin/forma/<accion>/<tipo>/', methods=['GET', 'POST'])
20 20
 @app.route('/admin/forma/<accion>/<tipo>/<id>', methods=['GET', 'POST'])
21 21
 def formas(accion,tipo,id=None):
22 22
 	return render_template('forma.html', tipo=tipo, accion=accion, id=id, user_type="admin")
23 23
 
24
-    
24
+
25 25
 @app.route('/admin/formaDatos/<accion>/<tipo>/', methods=['GET', 'POST'])
26 26
 @app.route('/admin/formaDatos/<accion>/<tipo>/<id>', methods=['GET', 'POST'])
27 27
 def formaEst(accion, tipo, id=None):
@@ -55,4 +55,4 @@ def dashAdmin():
55 55
 def maneja_error_user(tipo):
56 56
 	return render_template('error.html',tipo=tipo)
57 57
 
58
-# print(formaEst("edit","estudiante",3))
58
+# print(formaEst("edit","estudiante",3))

+ 58
- 0
static/admin.js Переглянути файл

@@ -0,0 +1,58 @@
1
+var dash = angular.module('dash',[]);
2
+
3
+dash.controller('dashController', function($scope){
4
+  $scope.opciones = [
5
+    {
6
+      nombre:'Mi info',
7
+      dir:'#1',//info
8
+    }
9
+    ,{
10
+      nombre:'Manejar administracion',
11
+      dir:'admin',//maestros
12
+    }
13
+    ,{
14
+      nombre:'Manejar facultad',
15
+      dir:'facultad',//maestros
16
+    }
17
+    ,{
18
+      nombre:'Manejar enfermeria',
19
+      dir:'enfermeria',//maestros
20
+    }
21
+    ,{
22
+      nombre:'Manejar estudiantes',
23
+      dir:'estudiantes',
24
+    }
25
+    ,{
26
+      nombre:'Manejar encargados',
27
+      dir:'encargados',
28
+    }
29
+    ,{
30
+      nombre:'Manejar clases',
31
+      dir:'#5',
32
+    }
33
+    ,{
34
+      nombre:'Crear ofertas academicas',
35
+      dir:'#6',
36
+    }
37
+    ,{
38
+      nombre:'Matricular',
39
+      dir:'#7',
40
+    }
41
+    ,{
42
+      nombre:'Asignar demeritos',
43
+      dir:'#8',
44
+    }
45
+    ,{
46
+      nombre:'Generar Transcripciones',
47
+      dir:'#9',
48
+    }
49
+    ,{
50
+      nombre:'Visitas oficina',
51
+      dir:'#10',
52
+    }
53
+  ];
54
+  $scope.info = {
55
+      dash_name:'Dashboard de Administracion',
56
+      dash_link:'/',
57
+    };
58
+});

+ 20
- 0
static/adminver.js Переглянути файл

@@ -0,0 +1,20 @@
1
+var table = angular.module('table',['ngSanitize']);
2
+// var table = angular.module('table',[]);
3
+
4
+table.controller('tableController', function tableController($http, $scope, pagina){
5
+
6
+  var url = '/admin/datos/'+pagina+'/'
7
+  console.log(',datos,admin,'+pagina);
8
+
9
+  $http.get(url).then(function(response) {
10
+    $scope.headers = response.data.headers;
11
+    $scope.tabla = response.data.tabla;
12
+    $scope.info = response.data.info;
13
+    $scope.modal = response.data.modal;
14
+    console.log(response.data);
15
+    // document.write(response.data.headers);
16
+    // document.write(response.data.tabla);
17
+    // document.write(response.data.info);
18
+    // document.write(response.data.modal);
19
+  });
20
+});

+ 46
- 0
templates/dash.html Переглянути файл

@@ -0,0 +1,46 @@
1
+<html>
2
+
3
+  <!-- empieza los includes -->
4
+  <head>
5
+    <title>Draft</title>
6
+    <meta name="viewport" content="width=device-width, initial-scale=1">
7
+    <meta charset="UTF-8">
8
+    <link rel="icon" href="/../Icon.ico" sizes="32x32">
9
+    <!-- <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css"> -->
10
+    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
11
+    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>
12
+    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js"></script>
13
+    <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
14
+    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css">
15
+
16
+
17
+    <!-- el .css -->
18
+    <link rel="stylesheet" href="{{ url_for('static', filename='estilo.css') }}" />
19
+
20
+    <!-- los .js que quiero usar -->
21
+    <script type="text/javascript" src="{{ url_for('static', filename=jscript) }}"></script>
22
+    <script>
23
+      dash.value("pagina", "{{pagina}}")
24
+    </script>
25
+    {% raw %}
26
+    {{perfil}}{{pagina}}{{id}}{{jscript}}
27
+    {% endraw %}
28
+
29
+  </head>
30
+  <!-- termina los includes -->
31
+
32
+  <body ng-app="dash" ng-controller="dashController">
33
+    <nav class="navbar header navbar-dark bg-dark navbar-expand">
34
+      {% raw %}
35
+      <a class="navbar-brand" href="{{info.dash_link}}">{{info.dash_name}}</a>
36
+      {% endraw %}
37
+    </nav>
38
+
39
+    <div class="container-fluid text-center">
40
+      {% raw %}
41
+      <a ng-repeat="opcion in opciones" href="{{opcion.dir}}" class="btn task boton mr-4">{{opcion.nombre}}</a>
42
+      {% endraw %}
43
+    </div>
44
+  </body>
45
+
46
+</html>

+ 113
- 0
templates/table.html Переглянути файл

@@ -0,0 +1,113 @@
1
+<html>
2
+
3
+  <!-- empieza los includes -->
4
+  <head>
5
+    <title>Draft</title>
6
+    <meta name="viewport" content="width=device-width, initial-scale=1">
7
+    <meta charset="UTF-8">
8
+    <link rel="icon" href="/../Icon.ico" sizes="32x32">
9
+    <!-- <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css"> -->
10
+    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
11
+    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>
12
+    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js"></script>
13
+    <!-- <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script> -->
14
+    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css">
15
+    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js"></script>
16
+    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular-sanitize.js"></script>
17
+
18
+    <!-- el .css -->
19
+    <link rel="stylesheet" href="{{ url_for('static', filename='estilo.css') }}" />
20
+
21
+    <!-- los .js que quiero usar -->
22
+    <script type="text/javascript" src="{{ url_for('static', filename=jscript) }}"></script>
23
+    <script>
24
+    // la variable 'pagina' la usa el javascript para que el run.py sepa cual python file abrir.
25
+    //        este python file se encarga de comunicarse con la base de datos.
26
+      table.value("pagina", "{{pagina}}")
27
+    </script>
28
+    {% raw %}
29
+    <!-- {{headers}} -->
30
+    <!-- {{tabla}} -->
31
+    <!-- {{info}} -->
32
+    <!-- {{modal}} -->
33
+    {% endraw %}
34
+
35
+  </head>
36
+  <!-- termina los includes -->
37
+
38
+
39
+  <body ng-app="table" ng-controller="tableController">
40
+    <nav class="navbar navbar-dark bg-dark navbar-expand">
41
+      {% raw %}
42
+      <a class="navbar-brand" href="{{info.dash_link}}">{{info.dash_name}}</a>
43
+      {% endraw %}
44
+    </nav>
45
+
46
+    <div class="container-fluid col-12">
47
+      <div class="container-fluid col-12">
48
+        <h1 class="col">
49
+          {% raw %}
50
+          {{info.dash_sub_name}}
51
+          {% endraw %}
52
+        </h1>
53
+        <div class="col" >
54
+          {% raw %}
55
+          <a class="btn button mr-4" href="{{info.add_link}}">{{info.add}}</a>
56
+          {% endraw %}
57
+        </div>
58
+      </div>
59
+
60
+      <table>
61
+        <tr>
62
+          {% raw %}
63
+          <th ng-repeat="header in headers" class="header2">{{header.nombre}}</th>
64
+          {% endraw %}
65
+        </tr>
66
+        <tr ng-repeat="row in tabla">
67
+          {% raw %}
68
+          <!-- la proxima linea asume que las entradas en la tabla tienen un id unico con -->
69
+          <!-- el mismo nombre de identificador a traves de los javascript, json, etc. -->
70
+          <td ng-repeat="stat in row" ng-if="stat != row.user_id">
71
+            <div ng-bind-html="stat"></div>
72
+          </td>
73
+          <td><button type="button" class="btn2 boton mr-4" name="button" data-toggle="modal" data-target="#myModalv{{row.user_id}}">Ver mas</button></td>
74
+          <td><a type="button" class="btn2 boton mr-4" href="{{info.dir2}}{{row.user_id}}">Editar</a></td>
75
+
76
+          {% endraw %}
77
+        </tr>
78
+      </table>
79
+    </div>
80
+  </body>
81
+
82
+  <!-- comienza modal -->
83
+  {% raw %}
84
+  <div ng-repeat="row in tabla" id="myModalv{{row.user_id}}" class="modal fade">
85
+    <div class="modal-dialog">
86
+
87
+      <!-- Modal content-->
88
+      <div class="modal-content">
89
+        <div class="modal-header bg2">
90
+          <button type="button" class="close" data-dismiss="modal">&times;</button>
91
+          <h4 class="modal-title">{{modal.infoName}}</h4>
92
+        </div>
93
+        <div class="modal-body bg1">
94
+            <!-- <div ng-bind-html="stat"></div> -->
95
+            <form action="#">
96
+              <div ng-repeat="(key, value) in row" ng-if="value != row.user_id">
97
+                <label for="{{key}}">{{key}}:</label><br>
98
+                <input type="text" id="{{key}}" name="{{key}}" value="{{value}}" readonly><br>
99
+              </div>
100
+            </form>
101
+
102
+        </div>
103
+        <div class="modal-footer bg2">
104
+          <button type="button" class="btn btn-default boton" data-dismiss="modal">Close</button>
105
+        </div>
106
+      </div>
107
+
108
+    </div>
109
+  </div>
110
+  {% endraw %}
111
+  <!-- termina modal -->
112
+
113
+</html>