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

comenzé a usar python3

comenzé a usar python3. estaba usando python2.
borré los .pyc, y algunas lines en los files admin*.py
Oniel Méndez Nieves 4 роки тому
джерело
коміт
715f544b2f

BIN
__pycache__/adminadmin.cpython-36.pyc Переглянути файл


BIN
__pycache__/adminencargados.cpython-36.pyc Переглянути файл


BIN
__pycache__/adminenfermeria.cpython-36.pyc Переглянути файл


BIN
__pycache__/adminestudiantes.cpython-36.pyc Переглянути файл


BIN
__pycache__/adminfacultad.cpython-36.pyc Переглянути файл


BIN
__pycache__/administracion.cpython-36.pyc Переглянути файл


BIN
__pycache__/adminusers.cpython-36.pyc Переглянути файл


BIN
__pycache__/connect.cpython-36.pyc Переглянути файл


BIN
__pycache__/enfermeria.cpython-36.pyc Переглянути файл


BIN
__pycache__/facultad.cpython-36.pyc Переглянути файл


BIN
__pycache__/funciones.cpython-36.pyc Переглянути файл


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

@@ -1,20 +1,6 @@
1 1
 # from sqlalchemy import metadata
2 2
 import sqlalchemy as db
3 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 4
 
19 5
 # connect to server
20 6
 engine = db.create_engine('mysql+pymysql://root:@0.0.0.0/registro_escolar_1')
@@ -52,25 +38,25 @@ def admin():
52 38
         i = i+1
53 39
         tabla += '{'
54 40
         modal_content += '{'
55
-        tabla += '"Nombre":"'+escape(q[1])+' '+escape(q[2])+'"'
56
-        modal_content += '"Nombre":"'+escape(q[1])+' '+escape(q[2])+'"'
41
+        tabla += '"Nombre":"'+(q[1])+' '+(q[2])+'"'
42
+        modal_content += '"Nombre":"'+(q[1])+' '+(q[2])+'"'
57 43
         tabla += ','
58 44
         modal_content += ','
59 45
 
60 46
         query = 'SELECT posicion FROM administracion a WHERE a.user_id = ' + str(q[0])
61 47
         posicion = connection.execute(query).fetchall()
62 48
 
63
-        tabla += '"Posicion":"'+escape(str(posicion[0][0]))+'"'
64
-        modal_content += '"Posicion":"'+escape(str(posicion[0][0]))+'"'
49
+        tabla += '"Posicion":"'+(str(posicion[0][0]))+'"'
50
+        modal_content += '"Posicion":"'+(str(posicion[0][0]))+'"'
65 51
 
66 52
         tabla += ','
67 53
         modal_content += ','
68
-        tabla += '"Email":"'+escape(q[3])+'"'
69
-        modal_content += '"Email":"'+escape(q[3])+'"'
54
+        tabla += '"Email":"'+(q[3])+'"'
55
+        modal_content += '"Email":"'+(q[3])+'"'
70 56
         tabla += ','
71 57
         modal_content += ','
72
-        tabla += '"user_id":"'+escape(str(q[0]))+'"'
73
-        modal_content += '"user_id":"'+escape(str(q[0]))+'"'
58
+        tabla += '"user_id":"'+(str(q[0]))+'"'
59
+        modal_content += '"user_id":"'+(str(q[0]))+'"'
74 60
         tabla += '}'
75 61
         modal_content += '}'
76 62
         if i < len_result:

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


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

@@ -1,21 +1,6 @@
1 1
 # from sqlalchemy import metadata
2 2
 import sqlalchemy as db
3 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 4
 # connect to server
20 5
 engine = db.create_engine('mysql+pymysql://root:@0.0.0.0/registro_escolar_1')
21 6
 
@@ -52,8 +37,8 @@ def encargados():
52 37
         i = i+1
53 38
         tabla += '{'
54 39
         modal_content += '{'
55
-        tabla += '"Nombre":"'+escape(q[1])+' '+escape(q[2])+'"'
56
-        modal_content += '"Nombre":"'+escape(q[1])+' '+escape(q[2])+'"'
40
+        tabla += '"Nombre":"'+(q[1])+' '+(q[2])+'"'
41
+        modal_content += '"Nombre":"'+(q[1])+' '+(q[2])+'"'
57 42
         tabla += ','
58 43
         modal_content += ','
59 44
 
@@ -65,8 +50,8 @@ def encargados():
65 50
 
66 51
         tabla += ','
67 52
         modal_content += ','
68
-        tabla += '"Email":"'+escape(q[3])+'"'
69
-        modal_content += '"Email":"'+escape(q[3])+'"'
53
+        tabla += '"Email":"'+(q[3])+'"'
54
+        modal_content += '"Email":"'+(q[3])+'"'
70 55
         tabla += ','
71 56
         modal_content += ','
72 57
         tabla += '"user_id":"'+str(q[0])+'"'

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


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

@@ -1,21 +1,6 @@
1 1
 # from sqlalchemy import metadata
2 2
 import sqlalchemy as db
3 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 4
 # connect to server
20 5
 engine = db.create_engine('mysql+pymysql://root:@0.0.0.0/registro_escolar_1')
21 6
 
@@ -52,21 +37,21 @@ def enfermeria():
52 37
         i = i+1
53 38
         tabla += '{'
54 39
         modal_content += '{'
55
-        tabla += '"Nombre":"'+escape(q[1])+' '+escape(q[2])+'"'
56
-        modal_content += '"Nombre":"'+escape(q[1])+' '+escape(q[2])+'"'
40
+        tabla += '"Nombre":"'+(q[1])+' '+(q[2])+'"'
41
+        modal_content += '"Nombre":"'+(q[1])+' '+(q[2])+'"'
57 42
         tabla += ','
58 43
         modal_content += ','
59 44
 
60 45
         query = 'SELECT especialidad FROM enfermeras e WHERE e.user_id = ' + str(q[0])
61 46
         especialidad = connection.execute(query).fetchall()
62 47
 
63
-        tabla += '"Especialidad":"'+escape(str(especialidad[0][0]))+'"'
64
-        modal_content += '"Especialidad":"'+escape(str(especialidad[0][0]))+'"'
48
+        tabla += '"Especialidad":"'+(str(especialidad[0][0]))+'"'
49
+        modal_content += '"Especialidad":"'+(str(especialidad[0][0]))+'"'
65 50
 
66 51
         tabla += ','
67 52
         modal_content += ','
68
-        tabla += '"Email":"'+escape(q[3])+'"'
69
-        modal_content += '"Email":"'+escape(q[3])+'"'
53
+        tabla += '"Email":"'+(q[3])+'"'
54
+        modal_content += '"Email":"'+(q[3])+'"'
70 55
         tabla += ','
71 56
         modal_content += ','
72 57
         tabla += '"user_id":"'+str(q[0])+'"'

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


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

@@ -1,20 +1,6 @@
1 1
 # from sqlalchemy import metadata
2 2
 import sqlalchemy as db
3 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 4
 
19 5
 # connect to server
20 6
 engine = db.create_engine('mysql+pymysql://root:@0.0.0.0/registro_escolar_1')
@@ -53,8 +39,8 @@ def estudiantes():
53 39
         i = i+1
54 40
         tabla += '{'
55 41
         modal_content += '{'
56
-        tabla += '"Nombre":"'+escape(q[1])+' '+escape(q[2])+'"'
57
-        modal_content += '"Nombre":"'+escape(q[1])+' '+escape(q[2])+'"'
42
+        tabla += '"Nombre":"'+(q[1])+' '+(q[2])+'"'
43
+        modal_content += '"Nombre":"'+(q[1])+' '+(q[2])+'"'
58 44
         tabla += ','
59 45
         modal_content += ','
60 46
 
@@ -66,8 +52,8 @@ def estudiantes():
66 52
 
67 53
         tabla += ','
68 54
         modal_content += ','
69
-        tabla += '"Email":"'+escape(q[3])+'"'
70
-        modal_content += '"Email":"'+escape(q[3])+'"'
55
+        tabla += '"Email":"'+(q[3])+'"'
56
+        modal_content += '"Email":"'+(q[3])+'"'
71 57
         tabla += ','
72 58
         modal_content += ','
73 59
         tabla += '"user_id":"'+str(q[0])+'"'

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


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

@@ -1,21 +1,6 @@
1 1
 # from sqlalchemy import metadata
2 2
 import sqlalchemy as db
3 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 4
 # connect to server
20 5
 engine = db.create_engine('mysql+pymysql://root:@0.0.0.0/registro_escolar_1')
21 6
 
@@ -55,8 +40,8 @@ def facultad():
55 40
         i = i+1
56 41
         tabla += '{'
57 42
         modal_content += '{'
58
-        tabla += '"Nombre":"'+escape(q[1])+' '+escape(q[2])+'"'
59
-        modal_content += '"Nombre":"'+escape(q[1])+' '+escape(q[2])+'"'
43
+        tabla += '"Nombre":"'+(q[1])+' '+(q[2])+'"'
44
+        modal_content += '"Nombre":"'+(q[1])+' '+(q[2])+'"'
60 45
         tabla += ','
61 46
         modal_content += ','
62 47
 
@@ -68,8 +53,8 @@ def facultad():
68 53
 
69 54
         tabla += ','
70 55
         modal_content += ','
71
-        tabla += '"Email":"'+escape(q[3])+'"'
72
-        modal_content += '"Email":"'+escape(q[3])+'"'
56
+        tabla += '"Email":"'+(q[3])+'"'
57
+        modal_content += '"Email":"'+(q[3])+'"'
73 58
         tabla += ','
74 59
         modal_content += ','
75 60
         tabla += '"user_id":"'+str(q[0])+'"'

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


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


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

@@ -3,20 +3,6 @@ import sqlalchemy as db
3 3
 
4 4
 
5 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 6
 
21 7
 # connect to server
22 8
 engine = db.create_engine('mysql+pymysql://root:@0.0.0.0/registro_escolar_1')

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



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

@@ -2,15 +2,6 @@
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
-##############################################
6
-# de stack overflow:
7
-#   Changing default encoding of Python?
8
-import sys
9
-# sys.setdefaultencoding() does not exist, here!
10
-reload(sys)  # Reload does the trick!
11
-sys.setdefaultencoding('UTF8')
12
-##############################################
13
-
14 5
 import adminadmin, adminfacultad, adminenfermeria, adminencargados, adminestudiantes
15 6
 import enfermeria
16 7
 
@@ -96,34 +87,50 @@ def procesaUser():
96 87
 	tipo_accion = getattr(__import__(data["tipo"]), data["accion"])
97 88
 	return tipo_accion(data)
98 89
 
99
-@app.route('/admin/forma/<accion>/<tipo>/', methods=['GET', 'POST'])
100
-@app.route('/admin/forma/<accion>/<tipo>/<id>', methods=['GET', 'POST'])
101
-def formas(accion,tipo,id=None):
102
-	return render_template('forma.html', tipo=tipo, accion=accion, id=id, user_type="admin")
103
-
104
-
105
-@app.route('/admin/formaDatos/<accion>/<tipo>/', methods=['GET', 'POST'])
106
-@app.route('/admin/formaDatos/<accion>/<tipo>/<id>', methods=['GET', 'POST'])
107
-def formaEst(accion, tipo, id=None):
108
-# 	data = json.loads('formaEstudiantes.json')
109
-	if tipo not in ["enfermera", "administracion", "estudiante", "madre", "facultad"]:
110
-		return {"error":True,"tipo":"tipo_incorrecto","opcion":tipo,"user_type":"admin"}
111
-	if accion not in ["edit", "add", "view"]:
112
-		return {"error":True,"tipo":"accion_incorrecta","opcion":accion,"user_type":"admin"}
113
-	if (accion=="add"):
114
-		return __import__(tipo).add_form()
115
-	if(accion=="edit"):
116
-		resultado=__import__(tipo).edit_form(id)
117
-		if resultado==False:
118
-			return {"error":True,"tipo":"usuario_incorrecto","opcion":tipo,"user_type":"admin"}
119
-		else:
120
-			return resultado
121
-	if(accion=="view"):
122
-		resultado=__import__(tipo).edit_form(id,disabled=True)
123
-		if resultado==False:
124
-			return {"error":True,"tipo":"usuario_incorrecto","opcion":tipo,"user_type":"admin"}
125
-		else:
126
-			return resultado
90
+# @app.route('/admin/forma/<accion>/<tipo>/', methods=['GET', 'POST'])
91
+# @app.route('/admin/forma/<accion>/<tipo>/<id>', methods=['GET', 'POST'])
92
+# def formas(accion,tipo,id=None):
93
+# 	return render_template('forma.html', tipo=tipo, accion=accion, id=id, user_type="admin")
94
+
95
+################## oniel, editado el original de arriba
96
+@app.route('/<perfil>/forma/<accion>/<tipo>/', methods=['GET', 'POST'])
97
+@app.route('/<perfil>/forma/<accion>/<tipo>/<id>', methods=['GET', 'POST'])
98
+def formas(perfil, accion,tipo,id=None):
99
+    if perfil not in ["enfermera", "enfermeria", "admin", "administracion", "estudiante", "madre", "facultad"]:
100
+        return {"error":True,"tipo":"tipo_incorrecto","opcion":tipo,"user_type":"admin"}
101
+    return render_template('forma.html', tipo=tipo, accion=accion, id=id, user_type=perfil)
102
+##################
103
+
104
+@app.route('/<perfil>/formaDatos/<accion>/<tipo>/', methods=['GET', 'POST'])
105
+@app.route('/<perfil>/formaDatos/<accion>/<tipo>/<id>', methods=['GET', 'POST'])
106
+def formaEst(perfil, accion, tipo, id=None):
107
+    # 	data = json.loads('formaEstudiantes.json')
108
+    # print 'perfil'
109
+    if perfil not in ["enfermera", "enfermeria", "admin", "administracion", "estudiante", "madre", "facultad"]:
110
+        return {"error":True,"tipo":"tipo_incorrecto","opcion":tipo,"user_type":"<perfil>"}
111
+    # print 'tipo'
112
+    if tipo not in ["enfermera", "enfermeria", "administracion", "estudiante", "madre", "facultad", 'visita']:
113
+        return {"error":True,"tipo":"tipo_incorrecto","opcion":tipo,"user_type":"<perfil>"}
114
+    # print 'accion'
115
+    if accion not in ["edit", "add", "view"]:
116
+        return {"error":True,"tipo":"accion_incorrecta","opcion":accion,"user_type":"<perfil>"}
117
+    # print 'add'
118
+    if (accion=="add"):
119
+        return __import__(tipo).add_form()
120
+    # print 'edit'
121
+    if(accion=="edit"):
122
+        resultado=__import__(tipo).edit_form(id)
123
+        if resultado==False:
124
+            return {"error":True,"tipo":"usuario_incorrecto","opcion":tipo,"user_type":"<perfil>"}
125
+        else:
126
+            return resultado
127
+    # print 'view'
128
+    if(accion=="view"):
129
+        resultado=__import__(tipo).edit_form(id,disabled=True)
130
+        if resultado==False:
131
+            return {"error":True,"tipo":"usuario_incorrecto","opcion":tipo,"user_type":"<perfil>"}
132
+        else:
133
+            return resultado
127 134
 
128 135
 @app.route('/admin/dashAdmin', methods=['GET', 'POST'])
129 136
 def dashAdmin():


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

@@ -90,26 +90,26 @@ def visitas():
90 90
     ###### info
91 91
 
92 92
     info = '{'
93
-    info += '"dash_name":"Manejar Encargados"'
93
+    info += '"dash_name":"Enfermeria- Manejar Visitas"'
94 94
     info += ','
95
-    info += '"dash_link":"/admin/ver/"'
95
+    info += '"dash_link":"/enfermeria/ver/"'
96 96
     info += ','
97
-    info += '"dash_sub_name":"Encargados Registrados"'
97
+    info += '"dash_sub_name":"Visitas hechas"'
98 98
     info += ','
99
-    info += '"add":"Anadir Encargados"'
99
+    info += '"add":"Anadir Visita"'
100 100
     info += ','
101
-    info += '"add_link":"/enfermera/forma/add/visita/"'
101
+    info += '"add_link":"/enfermeria/forma/add/visita/"'
102 102
     info += ','
103 103
     info += '"dir1":"#"'
104 104
     info += ','
105
-    info += '"dir2":"/enfermera/forma/edit/visita/"'
105
+    info += '"dir2":"/enfermeria/forma/edit/visita/"'
106 106
     info += '}'
107 107
 
108 108
     ###### modal
109 109
     modal = '{'
110 110
     modal += '"infoName":"Ver informacion"'
111 111
     modal += ','
112
-    modal += '"editName":"/admin/ver/"'
112
+    modal += '"editName":"#"'
113 113
     modal += '}'
114 114
 
115 115
     result = '{"headers":'+headers+',"tabla":'+tabla+',"modal_content":'+modal_content+',"info":'+info+',"modal":'+modal+'}'

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


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