浏览代码

final sprint 1 commit

Daniel Suazo 4 年前
父节点
当前提交
064a953c2e
共有 35 个文件被更改,包括 63 次插入7457 次删除
  1. 1
    0
      .gitignore
  2. 3
    0
      .vscode/settings.json
  3. 0
    1
      Miupi Parser/Admi.json
  4. 0
    1
      Miupi Parser/Admi_Grad.json
  5. 0
    1
      Miupi Parser/Arqui.json
  6. 0
    1
      Miupi Parser/Arqui_Grad.json
  7. 0
    1
      Miupi Parser/Asuntos_Aca.json
  8. 0
    1
      Miupi Parser/Ciencia_Tech_Info_Grad.json
  9. 0
    1
      Miupi Parser/Ciencias_Militares.json
  10. 0
    1
      Miupi Parser/Comunicaciones.json
  11. 0
    1
      Miupi Parser/Comunicaciones_Grad.json
  12. 0
    1
      Miupi Parser/Derecho.json
  13. 0
    1
      Miupi Parser/Educacion.json
  14. 0
    1
      Miupi Parser/Educacion_Continua.json
  15. 0
    1
      Miupi Parser/Educacion_Grad.json
  16. 0
    1
      Miupi Parser/Generales.json
  17. 0
    1
      Miupi Parser/Humanidades.json
  18. 0
    1
      Miupi Parser/Humanidades_Grad.json
  19. 0
    7321
      Miupi Parser/Naturales.json
  20. 0
    1
      Miupi Parser/Naturales_Grad.json
  21. 0
    1
      Miupi Parser/Planificacion.json
  22. 0
    1
      Miupi Parser/Sociales.json
  23. 0
    1
      Miupi Parser/Sociales_Grad.json
  24. 0
    96
      Miupi Parser/parse.py
  25. 二进制
      server/CompanionApp/__pycache__/models.cpython-38.pyc
  26. 二进制
      server/CompanionApp/__pycache__/serializers.cpython-38.pyc
  27. 二进制
      server/CompanionApp/__pycache__/urls.cpython-38.pyc
  28. 二进制
      server/CompanionApp/__pycache__/views.cpython-38.pyc
  29. 18
    0
      server/CompanionApp/migrations/0008_auto_20201105_1214.py
  30. 二进制
      server/CompanionApp/migrations/__pycache__/0008_auto_20201105_1214.cpython-38.pyc
  31. 1
    1
      server/CompanionApp/models.py
  32. 2
    2
      server/CompanionApp/serializers.py
  33. 1
    1
      server/CompanionApp/urls.py
  34. 37
    16
      server/CompanionApp/views.py
  35. 二进制
      server/restful/__pycache__/settings.cpython-38.pyc

+ 1
- 0
.gitignore 查看文件

@@ -8,6 +8,7 @@ client/CompanionApp*.key
8 8
 client/CompanionApp*.mobileprovision
9 9
 client/CompanionApp*.orig.*
10 10
 client/CompanionAppweb-build/
11
+server/restful
11 12
 
12 13
 # macOS
13 14
 client/CompanionApp.DS_Store

+ 3
- 0
.vscode/settings.json 查看文件

@@ -0,0 +1,3 @@
1
+{
2
+    "git.ignoreLimitWarning": true
3
+}

+ 0
- 1
Miupi Parser/Admi.json
文件差异内容过多而无法显示
查看文件


+ 0
- 1
Miupi Parser/Admi_Grad.json
文件差异内容过多而无法显示
查看文件


+ 0
- 1
Miupi Parser/Arqui.json
文件差异内容过多而无法显示
查看文件


+ 0
- 1
Miupi Parser/Arqui_Grad.json
文件差异内容过多而无法显示
查看文件


+ 0
- 1
Miupi Parser/Asuntos_Aca.json
文件差异内容过多而无法显示
查看文件


+ 0
- 1
Miupi Parser/Ciencia_Tech_Info_Grad.json
文件差异内容过多而无法显示
查看文件


+ 0
- 1
Miupi Parser/Ciencias_Militares.json 查看文件

@@ -1 +0,0 @@
1
-[{"Curso": "CIMI3011", "Seccion": "001", "Profesor": "MCGEE, SHANNON ", "Creditos": "2", "Nombre": "CURSO BASIC C. MILIT I", "Dias": ["LW"], "Horario": ["01:00PM-01:50PM"], "Salones": ["DM-001"], "Info_Extra": ""}, {"Curso": "CIMI3021", "Seccion": "001", "Profesor": "MEYERS, JOSHUA ", "Creditos": "2", "Nombre": "CURS BASIC C.MILIT III", "Dias": ["LW"], "Horario": ["10:30AM-11:20AM"], "Salones": ["DM-002"], "Info_Extra": ""}, {"Curso": "CIMI4011", "Seccion": "001", "Profesor": "MEYERS, JOSHUA ", "Creditos": "4", "Nombre": "COM Y PSIC EN LID MILITAR", "Dias": ["LW"], "Horario": ["08:00PM-09:50PM"], "Salones": ["DM-001"], "Info_Extra": ""}, {"Curso": "CIMI4021", "Seccion": "001", "Profesor": "ROJAS, ORLANDO ", "Creditos": "4", "Nombre": "LID Y ADM OPERACIONES MIL", "Dias": ["MJ"], "Horario": ["06:30AM-08:50AM"], "Salones": [], "Info_Extra": ""}, {"Curso": "ESAE3001", "Seccion": "001", "Profesor": "TORRES, C. ", "Creditos": "2", "Nombre": "LA FUERZA AEREA DE HOY", "Dias": ["L", "V"], "Horario": ["09:00AM-09:50AM", "09:00AM-10:50AM"], "Salones": ["DM-001", "DM-001"], "Info_Extra": ""}, {"Curso": "ESAE3001", "Seccion": "002", "Profesor": "TORRES, C. ", "Creditos": "2", "Nombre": "LA FUERZA AEREA DE HOY", "Dias": ["D"], "Horario": ["TBA"], "Salones": [], "Info_Extra": ""}, {"Curso": "ESAE3011", "Seccion": "002", "Profesor": "NIEVES,RICARDO ", "Creditos": "2", "Nombre": "DESARR DEL PODERIO AEREO", "Dias": ["W", "V"], "Horario": ["09:00AM-09:50AM", "09:00AM-10:50AM"], "Salones": [], "Info_Extra": ""}, {"Curso": "ESAE4001", "Seccion": "001", "Profesor": "MENDOZA, JOEL ", "Creditos": "4", "Nombre": "GER,LID EN LA FUERZA AERE", "Dias": ["LW", "V"], "Horario": ["10:00AM-11:20AM", "09:00AM-10:50AM"], "Salones": [], "Info_Extra": ""}, {"Curso": "ESAE4011", "Seccion": "001", "Profesor": "NIEVES, RICARDO", "Creditos": "4", "Nombre": "SEG NAC SOC AMER CONTEMP", "Dias": ["LW", "V"], "Horario": ["10:00AM-11:20AM", "09:00AM-10:50AM"], "Salones": [], "Info_Extra": ""}]

+ 0
- 1
Miupi Parser/Comunicaciones.json
文件差异内容过多而无法显示
查看文件


+ 0
- 1
Miupi Parser/Comunicaciones_Grad.json 查看文件

@@ -1 +0,0 @@
1
-[{"Curso": "COPU6500", "Seccion": "2U1", "Profesor": "ROCHE,MARIO ", "Creditos": "3", "Nombre": "TEORIAS DE LA COMUNICACIO", "Dias": ["M"], "Horario": ["06:00PM-08:50PM"], "Salones": ["PLAZU-4112"], "Info_Extra": "* Curso no se ofrecer\u00e1 en el 2DO SEM *"}, {"Curso": "COPU6517", "Seccion": "2U1", "Profesor": "RAMIREZ,RUBEN ", "Creditos": "3", "Nombre": "CULT Y ESTRUC MEDIATICAS", "Dias": ["W"], "Horario": ["06:00PM-08:50PM"], "Salones": ["PLAZU-4112"], "Info_Extra": "* Curso no se ofrecer\u00e1 en el 2DO SEM *"}, {"Curso": "COPU6667", "Seccion": "2U1", "Profesor": "COLON,ELISEO ", "Creditos": "3", "Nombre": "PERSP Y METOD INV EN COM", "Dias": ["L"], "Horario": ["06:00PM-08:50PM"], "Salones": ["PLAZU-4088"], "Info_Extra": "* Curso no se ofrecer\u00e1 en el 2DO SEM *"}, {"Curso": "COPU6698", "Seccion": "0U1", "Profesor": "COLON,ELISEO ", "Creditos": "0", "Nombre": "CONT EXP INVEST DIV MODS", "Dias": ["J"], "Horario": ["06:00PM-08:50PM"], "Salones": [], "Info_Extra": ""}, {"Curso": "COPU6707", "Seccion": "001", "Profesor": "COLON,ELISEO ", "Creditos": "3", "Nombre": "SEMINAR COMUNICACION III", "Dias": ["M"], "Horario": ["06:00PM-08:50PM"], "Salones": ["PLAZU-4110"], "Info_Extra": ""}, {"Curso": "COPU6707", "Seccion": "002", "Profesor": "ALVARADO, G. ", "Creditos": "3", "Nombre": "SEMINAR COMUNICACION III", "Dias": ["L"], "Horario": ["06:00PM-08:50PM"], "Salones": ["PLAZU-4110"], "Info_Extra": ""}, {"Curso": "COPU6726", "Seccion": "2U1", "Profesor": "ROCHE,MARIO ", "Creditos": "3", "Nombre": "SEMINARION EN PERIOD II", "Dias": ["J"], "Horario": ["06:00PM-08:50PM"], "Salones": ["PLAZU-4110"], "Info_Extra": "* Curso no se ofrecer\u00e1 en el 2DO SEM *"}]

+ 0
- 1
Miupi Parser/Derecho.json
文件差异内容过多而无法显示
查看文件


+ 0
- 1
Miupi Parser/Educacion.json
文件差异内容过多而无法显示
查看文件


+ 0
- 1
Miupi Parser/Educacion_Continua.json
文件差异内容过多而无法显示
查看文件


+ 0
- 1
Miupi Parser/Educacion_Grad.json
文件差异内容过多而无法显示
查看文件


+ 0
- 1
Miupi Parser/Generales.json
文件差异内容过多而无法显示
查看文件


+ 0
- 1
Miupi Parser/Humanidades.json
文件差异内容过多而无法显示
查看文件


+ 0
- 1
Miupi Parser/Humanidades_Grad.json
文件差异内容过多而无法显示
查看文件


+ 0
- 7321
Miupi Parser/Naturales.json
文件差异内容过多而无法显示
查看文件


+ 0
- 1
Miupi Parser/Naturales_Grad.json
文件差异内容过多而无法显示
查看文件


+ 0
- 1
Miupi Parser/Planificacion.json 查看文件

@@ -1 +0,0 @@
1
-[{"Curso": "PLAN5005", "Seccion": "3U1", "Profesor": "YOEL VELAZQUEZ ", "Creditos": "4", "Nombre": "ECON ESTA Y MATE PLANIF", "Dias": ["S"], "Horario": ["09:00AM-01:00PM"], "Salones": ["PLAZU-7033"], "Info_Extra": ""}, {"Curso": "PLAN6006", "Seccion": "0U1", "Profesor": "IRIZARRY, R. ", "Creditos": "3", "Nombre": "INTERNADO DE PLANIFICACIO", "Dias": ["D"], "Horario": ["TBA"], "Salones": [], "Info_Extra": ""}, {"Curso": "PLAN6068", "Seccion": "013", "Profesor": "LUGO, J. ", "Creditos": "3", "Nombre": "PRESERV PATRIMON Y PLANIF", "Dias": ["J"], "Horario": ["05:30PM-08:20PM"], "Salones": ["PLAZU-7041"], "Info_Extra": ""}, {"Curso": "PLAN6075", "Seccion": "2U1", "Profesor": "IRIZARRY, R. ", "Creditos": "3", "Nombre": "PROYECTO DE INVESTIG II", "Dias": ["L"], "Horario": ["05:30PM-08:20PM"], "Salones": ["PLAZU-7034"], "Info_Extra": ""}, {"Curso": "PLAN6076", "Seccion": "2U1", "Profesor": "LAMBA DEEPAK ", "Creditos": "3", "Nombre": "HIST & TEORIA PLAN", "Dias": ["L"], "Horario": ["05:30PM-08:20PM"], "Salones": ["PLAZU-7033"], "Info_Extra": ""}, {"Curso": "PLAN6089", "Seccion": "2U1", "Profesor": "ENCARNACION, A.", "Creditos": "3", "Nombre": "PLANIF URB Y TERRITORIAL", "Dias": ["W"], "Horario": ["07:00PM-09:50PM"], "Salones": ["PLAZU-7041"], "Info_Extra": ""}, {"Curso": "PLAN6116", "Seccion": "2U1", "Profesor": "GONZALEZ VERON ", "Creditos": "3", "Nombre": "ORDEN JURIDICO PLAN", "Dias": ["J"], "Horario": ["05:30PM-08:20PM"], "Salones": ["PLAZU-7033"], "Info_Extra": ""}, {"Curso": "PLAN6117", "Seccion": "2U1", "Profesor": "CASTRO, A . ", "Creditos": "4", "Nombre": "APLIC COMPUTADOR EN PLAN", "Dias": ["W"], "Horario": ["05:30PM-09:20PM"], "Salones": ["PLAZU-6015"], "Info_Extra": ""}, {"Curso": "PLAN6135", "Seccion": "2U1", "Profesor": "ENCARNACION, A,", "Creditos": "3", "Nombre": "SOCIEDAD AMBIENTE Y PLAN", "Dias": ["L"], "Horario": ["05:30PM-08:20PM"], "Salones": ["PLAZU-7035"], "Info_Extra": ""}, {"Curso": "PLAN6513", "Seccion": "2U1", "Profesor": "IRIZARRY, R. ", "Creditos": "3", "Nombre": "SEM PROP PROYECTO PLANIFI", "Dias": ["D"], "Horario": ["TBA"], "Salones": [], "Info_Extra": ""}, {"Curso": "PLAN6602", "Seccion": "2U1", "Profesor": "CASTRO, A. ", "Creditos": "4", "Nombre": "SIG PARA PLANIFICACION", "Dias": ["MJ"], "Horario": ["05:30PM-07:20PM"], "Salones": ["PLAZU-6015"], "Info_Extra": ""}, {"Curso": "PLAN6603", "Seccion": "2U1", "Profesor": "NAVARRO, C. ", "Creditos": "3", "Nombre": "ELABORACION DE PLANES", "Dias": ["L"], "Horario": ["05:30PM-08:20PM"], "Salones": ["PLAZU-7041"], "Info_Extra": ""}, {"Curso": "PLAN6604", "Seccion": "2U1", "Profesor": "SANTIAGO, R. ", "Creditos": "3", "Nombre": "TEOR COMUNIDAD Y DES ECON", "Dias": ["J"], "Horario": ["05:30PM-08:20PM"], "Salones": ["PLAZU-7035"], "Info_Extra": ""}, {"Curso": "PLAN6614", "Seccion": "201", "Profesor": "BARRETO, M. ", "Creditos": "3", "Nombre": "PROYECTO DE PLANIFICACION", "Dias": ["D"], "Horario": ["TBA"], "Salones": [], "Info_Extra": ""}, {"Curso": "PLAN6614", "Seccion": "202", "Profesor": "NAVARRO, C. ", "Creditos": "3", "Nombre": "PROYECTO DE PLANIFICACION", "Dias": ["D"], "Horario": ["TBA"], "Salones": [], "Info_Extra": ""}, {"Curso": "PLAN6896", "Seccion": "201", "Profesor": "BARRETO, M. ", "Creditos": "0", "Nombre": "CONTINUACION PROY PLAN", "Dias": ["D"], "Horario": ["TBA"], "Salones": [], "Info_Extra": ""}, {"Curso": "PLAN6896", "Seccion": "202", "Profesor": "PENA, P. ", "Creditos": "0", "Nombre": "CONTINUACION PROY PLAN", "Dias": ["D"], "Horario": ["TBA"], "Salones": [], "Info_Extra": ""}, {"Curso": "PLAN6896", "Seccion": "203", "Profesor": "NAVARRO, C. ", "Creditos": "0", "Nombre": "CONTINUACION PROY PLAN", "Dias": ["D"], "Horario": ["TBA"], "Salones": [], "Info_Extra": ""}, {"Curso": "PLAN6995", "Seccion": "011", "Profesor": "MIRANDA, C. ", "Creditos": "1", "Nombre": "SEM: DESARROLLO PROPUESTA", "Dias": ["LMW", "S"], "Horario": ["05:30PM-08:20PM", "09:00AM-11:00AM"], "Salones": ["PLAZU-7036", "PLAZU-7036"], "Info_Extra": ""}, {"Curso": "PLAN6995", "Seccion": "013", "Profesor": "BARRETO MARITZA", "Creditos": "3", "Nombre": "RIESGOS Y PLANIFICACIONN", "Dias": ["W"], "Horario": ["05:30PM-08:20PM"], "Salones": ["PLAZU-7035"], "Info_Extra": ""}, {"Curso": "PLAN6996", "Seccion": "2U1", "Profesor": "NAVARRO, C. ", "Creditos": "5", "Nombre": "PRACTICA DE PLANIFICACION", "Dias": ["D"], "Horario": ["TBA"], "Salones": [], "Info_Extra": ""}]

+ 0
- 1
Miupi Parser/Sociales.json
文件差异内容过多而无法显示
查看文件


+ 0
- 1
Miupi Parser/Sociales_Grad.json
文件差异内容过多而无法显示
查看文件


+ 0
- 96
Miupi Parser/parse.py 查看文件

@@ -1,96 +0,0 @@
1
-import pandas as pd
2
-import json
3
-from os import remove
4
-
5
-
6
-def initial_parse(name, url):
7
-
8
-    table_MN = pd.read_html(url)
9
-    df = table_MN[0]
10
-    df.columns = ['Curso', 'Nombre', 'c', 'Dias', 'Hora', 'Salon']
11
-
12
-    upi = df[['Curso', 'Nombre', 'Dias', 'Hora', 'Salon']]
13
-    # print(upi.head())
14
-    # print(upi.to_json(orient='records'))
15
-
16
-    # puedes usar esta alternativa o la de la linea 17
17
-    # upi.to_json(r'C:\Users\diego\Documents\miupi_parse\soup\file.json')
18
-    upi.to_json(f'{name}_temp.json', orient='records')
19
-
20
-
21
-def final_parse(name):
22
-
23
-    with open(f"{name}_temp.json") as f_in:
24
-        data = json.load(f_in)
25
-
26
-    newdata = []
27
-
28
-    for item in data:
29
-        if(item["Curso"] == None):
30
-            pass
31
-        else:
32
-            course = {}
33
-
34
-            course["Curso"] = item["Curso"][0:8]
35
-            course["Seccion"] = item["Curso"][9:12]
36
-
37
-            info = item["Nombre"].split("Profesor: ")
38
-            if((profesor := info[1][0:-11]) != ""):
39
-                course["Profesor"] = profesor
40
-            else:
41
-                course["Profesor"] = "TBA"
42
-            
43
-            course["Creditos"] = info[1][-1]
44
-            course["Nombre"] = info[0][0:-1]
45
-            course["Dias"] = item["Dias"].split(" ")
46
-
47
-            horario = []
48
-            if(item["Hora"] != None):
49
-                for i in range(len(course["Dias"])):
50
-                    horario.append(item["Hora"][15*i:15*(i+1)])
51
-            else:
52
-                horario.append("TBA")
53
-            course["Horario"] = horario
54
-
55
-            salones_raw = item["Salon"].split("Edificio: ")
56
-            salones = []
57
-            for i in salones_raw:
58
-                if(i != "-" and i != "- " and i != ""):
59
-                    salones.append(i[:-1])
60
-            course["Salones"] = salones
61
-
62
-            course["Info_Extra"] = item["Curso"][13:-1]
63
-
64
-            newdata.append(course)
65
-
66
-    with open(f'{name}.json', 'w') as f_out:
67
-        json.dump(newdata, f_out)
68
-
69
-
70
-if __name__ == "__main__":
71
-    faculty_urls = {"Asuntos_Aca": "https://miupi.uprrp.edu/horarios/RBA120_AA.HTML",
72
-                    "Admi": "https://miupi.uprrp.edu/horarios/RBA120_AE.HTML",
73
-                    "Admi_Grad": "https://miupi.uprrp.edu/horarios/RBA120_AE2.HTML",
74
-                    "Arqui": "https://miupi.uprrp.edu/horarios/RBA120_AQ.HTML",
75
-                    "Arqui_Grad": "https://miupi.uprrp.edu/horarios/RBA120_AQ2.HTML",
76
-                    "Ciencia_Tech_Info_Grad": "https://miupi.uprrp.edu/horarios/RBA120_CB.HTML",
77
-                    "Ciencias_Militares": "https://miupi.uprrp.edu/horarios/RBA120_CM.HTML",
78
-                    "Naturales": "https://miupi.uprrp.edu/horarios/RBA120_CN.HTML",
79
-                    "Naturales_Grad": "https://miupi.uprrp.edu/horarios/RBA120_CN2.HTML",
80
-                    "Comunicaciones": "https://miupi.uprrp.edu/horarios/RBA120_CP.HTML",
81
-                    "Comunicaciones_Grad": "https://miupi.uprrp.edu/horarios/RBA120_CP2.HTML",
82
-                    "Sociales": "https://miupi.uprrp.edu/horarios/RBA120_CS.HTML",
83
-                    "Sociales_Grad": "https://miupi.uprrp.edu/horarios/RBA120_CS2.HTML	",
84
-                    "Derecho": "https://miupi.uprrp.edu/horarios/RBA120_DE.HTML",
85
-                    "Educacion_Continua": "https://miupi.uprrp.edu/horarios/RBA120_EC.HTML",
86
-                    "Educacion": "https://miupi.uprrp.edu/horarios/RBA120_ED.HTML",
87
-                    "Educacion_Grad": "https://miupi.uprrp.edu/horarios/RBA120_ED2.HTML",
88
-                    "Generales": "https://miupi.uprrp.edu/horarios/RBA120_EG.HTML",
89
-                    "Humanidades": "https://miupi.uprrp.edu/horarios/RBA120_HU.HTML",
90
-                    "Humanidades_Grad": "https://miupi.uprrp.edu/horarios/RBA120_HU2.HTML",
91
-                    "Planificacion": "https://miupi.uprrp.edu/horarios/RBA120_PL.HTML"}
92
-    #initial_parse("Naturales", faculty_urls["Naturales"])
93
-    for key in faculty_urls:
94
-        initial_parse(key, faculty_urls[key])
95
-        final_parse(key)
96
-        remove(f"{key}_temp.json")

二进制
server/CompanionApp/__pycache__/models.cpython-38.pyc 查看文件


二进制
server/CompanionApp/__pycache__/serializers.cpython-38.pyc 查看文件


二进制
server/CompanionApp/__pycache__/urls.cpython-38.pyc 查看文件


二进制
server/CompanionApp/__pycache__/views.cpython-38.pyc 查看文件


+ 18
- 0
server/CompanionApp/migrations/0008_auto_20201105_1214.py 查看文件

@@ -0,0 +1,18 @@
1
+# Generated by Django 3.1.2 on 2020-11-05 16:14
2
+
3
+from django.db import migrations, models
4
+
5
+
6
+class Migration(migrations.Migration):
7
+
8
+    dependencies = [
9
+        ('CompanionApp', '0007_remove_proximosemestre_grade'),
10
+    ]
11
+
12
+    operations = [
13
+        migrations.AlterField(
14
+            model_name='proximosemestre',
15
+            name='rooms',
16
+            field=models.CharField(max_length=100),
17
+        ),
18
+    ]

二进制
server/CompanionApp/migrations/__pycache__/0008_auto_20201105_1214.cpython-38.pyc 查看文件


+ 1
- 1
server/CompanionApp/models.py 查看文件

@@ -28,4 +28,4 @@ class ProximoSemestre(models.Model):
28 28
     prof = models.CharField(max_length=150)
29 29
     hours = models.CharField(max_length=50)
30 30
     days = models.CharField(max_length=12)
31
-    rooms = models.CharField(max_length=30)
31
+    rooms = models.CharField(max_length=100)

+ 2
- 2
server/CompanionApp/serializers.py 查看文件

@@ -30,7 +30,7 @@ class CursoSerializer(serializers.ModelSerializer):
30 30
 
31 31
 class MatriculaSerializer(serializers.ModelSerializer):
32 32
     class Meta:
33
-        model = Curso
33
+        model = Matricula
34 34
         fields = ('__all__')
35 35
 
36 36
     def create(self, validated_data):
@@ -43,7 +43,7 @@ class MatriculaSerializer(serializers.ModelSerializer):
43 43
 
44 44
 class ProximoSemestreSerializer(serializers.ModelSerializer):
45 45
     class Meta:
46
-        model = Curso
46
+        model = ProximoSemestre
47 47
         fields = ('__all__')
48 48
 
49 49
     def create(self, validated_data):

+ 1
- 1
server/CompanionApp/urls.py 查看文件

@@ -11,5 +11,5 @@ urlpatterns = [
11 11
     url(r'^api/hello$', views.hello_world),
12 12
     url(r'^api/insertar_cursos$', views.insertarTodosLosCursos),
13 13
     url(r'api/insert_matricula', views.insertarProximoSemestre),
14
-    url(r'api/test_query', views.testQuery)
14
+    url(r'api/fetch_matricula', views.fetchMatricula)
15 15
 ]

+ 37
- 16
server/CompanionApp/views.py 查看文件

@@ -3,7 +3,7 @@ import sys
3 3
 from django.shortcuts import render
4 4
 from django.http.response import JsonResponse
5 5
 from rest_framework import status
6
-from .models import Facultad, Curso, Matricula
6
+from .models import Facultad, Curso, Matricula, ProximoSemestre
7 7
 from rest_framework.decorators import api_view
8 8
 from rest_framework.parsers import JSONParser
9 9
 from .serializers import FacultadSerializer, CursoSerializer, MatriculaSerializer, ProximoSemestreSerializer
@@ -32,6 +32,7 @@ def insertarFacultades(request):
32 32
 @api_view(['POST', ])
33 33
 def insertarTodosLosCursos(request):
34 34
     if request.method == 'POST':
35
+        i = 1
35 36
         for file in files3:
36 37
             check = file['file'].split('.')
37 38
             path = "C:/Users/danie/Documents/Projects/Companion App/server/segundo_sem" if check[
@@ -44,10 +45,19 @@ def insertarTodosLosCursos(request):
44 45
                         code = key
45 46
                         name = data[key][0]
46 47
                         creds = data[key][1]
47
-                        curso_serializer = CursoSerializer(
48
-                            data={'name': name, 'code': code, 'creditos': creds, 'fac_id': fac_id})
49
-                        if curso_serializer.is_valid():
50
-                            curso_serializer.save()
48
+                        try:
49
+                            curso = Curso.objects.get(code=code)
50
+                        except Curso.DoesNotExist:
51
+                            curso = None
52
+
53
+                        if curso == None:
54
+                            curso_serializer = CursoSerializer(
55
+                                data={'name': name, 'code': code, 'creditos': creds, 'fac_id': fac_id})
56
+                            if curso_serializer.is_valid():
57
+                                curso_serializer.save()
58
+                        else:
59
+                            print('ya se creo', i)
60
+                            i += 1
51 61
         return JsonResponse({'message': 'se insertaron todos los cursos'}, status=status.HTTP_201_CREATED)
52 62
 
53 63
 
@@ -62,12 +72,13 @@ def hello_world(request):
62 72
 def insertarProximoSemestre(request):
63 73
     if request.method == 'POST':
64 74
         for file in files:
65
-            print(f"help {file['file']}")
66 75
             path = "C:/Users/danie/Documents/Projects/Companion App/server/Matricula Parse"
67 76
             with open(path + '/' + file['file']) as f:
68
-                print(f"opened {file['file']}")
69 77
                 data = json.load(f)
70 78
                 for course in data:
79
+                    print(course["Curso"])
80
+                    print(Curso.objects.filter(code=course["Curso"]))
81
+
71 82
                     code = Curso.objects.get(code=course["Curso"])
72 83
                     section = course["Seccion"]
73 84
                     prof = course["Profesor"]
@@ -81,27 +92,37 @@ def insertarProximoSemestre(request):
81 92
                         hours += i
82 93
                         hours += " "
83 94
 
95
+                    if hours == "":
96
+                        hours = "TBA"
97
+
84 98
                     rooms = ""
85 99
                     for i in course["Salones"]:
86 100
                         rooms += i
87 101
                         rooms += " "
88 102
 
103
+                    if rooms == "":
104
+                        rooms = "TBA"
105
+
106
+                    print(
107
+                        f"code {code.code}, section {section}, prof {prof}, hours {hours}, rooms {rooms}, days {days}")
108
+
89 109
                     # extra_info = course["Info_Extra"]
90 110
                     matricula_serializer = ProximoSemestreSerializer(
91
-                        data={'course_id': code, 'section': section, 'prof': prof, 'hours': hours, 'rooms': rooms, 'days': days})
92
-                    print(
93
-                        f"code {code}, section {section}, prof {prof}, hours {hours}, rooms {rooms}, days {days}")
111
+                        data={'code': code.code, 'name': code.name, 'fac_id': code.fac_id.pk, 'course_id': code.pk, 'section': section, 'prof': prof, 'hours': hours, 'rooms': rooms, 'days': days})
112
+
94 113
                     if matricula_serializer.is_valid(raise_exception=True):
95 114
                         matricula_serializer.save()
96
-                        print("inserted some data")
115
+                    print("inserted some data")
97 116
 
98 117
         return JsonResponse({'message': 'se insertaron todos los cursos'}, status=status.HTTP_201_CREATED)
99 118
 
100 119
 
101
-@api_view(['POST', 'GET'])
102
-def testQuery(request):
120
+@api_view(['POST', ])
121
+def fetchMatricula(request):
103 122
     json = []
104
-    for i in Curso.objects.all():
105
-        json.append({"id": i.fac_id.id, "name": i.name,
106
-                     "code": i.code, "credits": i.creditos})
123
+    for i in ProximoSemestre.objects.all():
124
+        json.append({"id": i.course_id.fac_id.id, "name": i.course_id.name,
125
+                     "code": i.course_id.code, "credits": i.course_id.creditos,
126
+                     "section": i.section, "prof": i.prof, "hours": i.hours,
127
+                     "days": i.days, "rooms": i.rooms})
107 128
     return JsonResponse(json, safe=False)

二进制
server/restful/__pycache__/settings.cpython-38.pyc 查看文件