Bläddra i källkod

everything is updated part 2

dmr1725 4 år sedan
förälder
incheckning
7b7cc5d715

+ 4
- 4
client/Screens/AddTakenCourse.js Visa fil

@@ -34,7 +34,7 @@ const AddTakenCourse = () => {
34 34
   const [grade, setGrade] = useState('A')
35 35
   const [year, setYear] = useState('1')
36 36
   const [semester, setSemester] = useState('1')
37
-  const [animating, setAnimating] = useState('')
37
+  const [animating, setAnimating] = useState(false)
38 38
 
39 39
   const toggle = ()=>{
40 40
     setModalVisible(!modalVisible)
@@ -52,7 +52,7 @@ const AddTakenCourse = () => {
52 52
 
53 53
       let response = await axios({
54 54
         method: 'POST',
55
-        url: 'http://da0406585426.ngrok.io/api/add_taken_course',
55
+        url: 'http://7f9219a069f7.ngrok.io/api/add_taken_course',
56 56
         headers: {
57 57
           'content-type': 'application/json',
58 58
           Authorization: `Token ${token}`
@@ -92,7 +92,7 @@ const AddTakenCourse = () => {
92 92
       const token = await SecureStore.getItemAsync('token')
93 93
       const response = await axios({
94 94
           method: 'GET',
95
-          url: `http://da0406585426.ngrok.io/api/find_course?code=${text}`,
95
+          url: `http://7f9219a069f7.ngrok.io/api/find_course?code=${text}`,
96 96
           headers: {
97 97
             'content-type': 'application/json',
98 98
             Authorization: `Token ${token}`
@@ -121,7 +121,7 @@ const AddTakenCourse = () => {
121 121
     );
122 122
   };
123 123
 
124
-
124
+  console.log(selectedId)
125 125
   return (
126 126
     <View style={{flex: 1, padding: 10}}>
127 127
        <TextInput

+ 268
- 0
client/Screens/Agenda.js Visa fil

@@ -0,0 +1,268 @@
1
+import React, {useState, useEffect} from 'react';
2
+import { StyleSheet, View, Text, ScrollView, RefreshControl } from 'react-native';
3
+import WeeklyCalendar from 'react-native-weekly-calendar';
4
+import * as SecureStore from 'expo-secure-store';
5
+import axios from 'axios'
6
+
7
+ 
8
+export default function App() {
9
+  const [data, setData] = useState('')
10
+  const [sampleEvents, setSampleEvents] = useState([])
11
+  const [refreshing, setRefreshing] = useState(false)
12
+  // const sampleEvents = [
13
+  //   { 'start': '2020-12-06 09:00:00', 'duration': '01:20:00', 'note': 'CCOM4120' },
14
+  //   { 'start': '2020-12-06 14:00:00', 'duration': '01:20:00', 'note': 'MATE3001' },
15
+  //   { 'start': '2020-12-06 17:00:00', 'duration': '00:30:00', 'note': 'INGL1001' },
16
+  //   { 'start': '2020-12-07 14:00:00', 'duration': '02:00:00', 'note': 'SICI3211' },
17
+  //   { 'start': '2020-12-07 10:00:00', 'duration': '02:00:00', 'note': 'BIOL3101' },
18
+  //   { 'start': '2020-12-08 09:00:00', 'duration': '01:20:00', 'note': 'CCOM4120' },
19
+  //   { 'start': '2020-12-08 14:00:00', 'duration': '01:20:00', 'note': 'MATE3001' },
20
+  //   { 'start': '2020-12-08 17:00:00', 'duration': '00:30:00', 'note': 'INGL1001' },
21
+  //   { 'start': '2020-12-09 14:00:00', 'duration': '02:00:00', 'note': 'SICI3211' },
22
+  //   { 'start': '2020-12-09 10:00:00', 'duration': '02:00:00', 'note': 'BIOL3101' },
23
+
24
+  // ]
25
+
26
+  const getMyCurriculum = async()=>{
27
+    const token = await SecureStore.getItemAsync('token')
28
+    let id = await SecureStore.getItemAsync('id')
29
+    let user_id = parseInt(id)
30
+
31
+    let response = await axios({
32
+      method: 'POST',
33
+      url: 'http://7f9219a069f7.ngrok.io/api/get_current_courses',
34
+      headers: {
35
+        'content-type': 'application/json',
36
+        Authorization: `Token ${token}`
37
+      },
38
+      data: {
39
+        user_id: user_id
40
+      }
41
+    })
42
+    // setSampleEvents([])
43
+    console.log(response.data.list, '------------------------------------------------------------------------------d')
44
+
45
+    if(response.data.msg){
46
+      setSampleEvents([])
47
+    }
48
+
49
+    else if(response.data.list[0].horarios === undefined){
50
+      setSampleEvents([])
51
+
52
+    }
53
+
54
+    else {
55
+        // courses
56
+        setData(response.data.list)  
57
+        console.log(data)
58
+
59
+        // Loop para ir curso por curso y a~adir a la agenda
60
+        let courses = []
61
+        data.map((course)=>{
62
+          // console.log(typeof(course.horarios))
63
+          
64
+          let horarios = course.horarios
65
+          let titulo = course.name
66
+          let horario_length = horarios.length
67
+          let horas = 0
68
+          let minutos = 0
69
+          let segundos = "00"
70
+          let dura = ""
71
+          let repetir = 0
72
+
73
+
74
+          let hora =""
75
+          let empieza= ""
76
+          let minuto = ""
77
+          // console.log(horario_length)
78
+          horarios = horarios.replace(/A/g,'')
79
+          horarios = horarios.replace(/M/g,'')
80
+          horarios = horarios.replace(/P/g,'')
81
+          horarios = horarios.replace(/-/g,':')
82
+          // console.log(horarios)
83
+
84
+          // Bregando con la DURACION
85
+          if(horario_length == 15){
86
+            horarios = horarios.split(':')
87
+            horas = horarios[2] - horarios[0]
88
+            minutos = horarios[3] - horarios[1]
89
+            minutos = minutos.toString()
90
+            horas = horas.toString()
91
+            horas = '0' + horas
92
+            // console.log("Horas: ", horas)
93
+            // console.log("Minutos: ", minutos)
94
+            // console.log("Segundos: ", segundos)
95
+            dura = horas + ":" + minutos + ":" + segundos
96
+            // console.log(dura)
97
+            // console.log(typeof(segundos))
98
+            // console.log(typeof(dura))
99
+          }
100
+          // Duracion para mas de un horario de una clase
101
+          else{
102
+            horarios = horarios.replace(/,/g,':')
103
+            horarios = horarios.split(':')
104
+            horario_length = horarios.length
105
+            console.log(horario_length)
106
+            repetir = horario_length/4
107
+            console.log("Repetir: ", repetir)
108
+            console.log(horarios)
109
+
110
+            horas = horarios[2] - horarios[0]
111
+            minutos = horarios[3] - horarios[1]
112
+            minutos = minutos.toString()
113
+            horas = horas.toString()
114
+            horas = '0' + horas
115
+            // console.log("Horas: ", horas)
116
+            // console.log("Minutos: ", minutos)
117
+            // console.log("Segundos: ", segundos)
118
+            dura = horas + ":" + minutos + ":" + segundos
119
+
120
+            // let horas2 = horarios[7] - horarios[5]
121
+            // let minutos2 = horarios[8] - horarios[6]
122
+            // minutos2 = minutos.toString()
123
+            // horas2 = horas.toString()
124
+            // horas2 = '0' + horas
125
+            // // console.log("Horas: ", horas)
126
+            // // console.log("Minutos: ", minutos)
127
+            // // console.log("Segundos: ", segundos)
128
+            // dura2 = horas2 + ":" + minutos2 + ":" + segundos
129
+          }
130
+
131
+          // Bregando con el START
132
+          if (horarios[0] < 7){
133
+            // console.log("Es menor: ", horarios[0])
134
+            hora = Number(horarios[0]) + 12
135
+          }
136
+          else{
137
+            hora = horarios[0]
138
+          }
139
+          minuto = horarios[1]
140
+          hora = hora.toString()
141
+          // console.log("Hora: ", hora)
142
+          // console.log(typeof(hora))
143
+          // console.log("Min: ", minuto)
144
+          // console.log(typeof(minuto))
145
+          empieza = hora + ":" + minuto + ":" + segundos
146
+
147
+          let date =""
148
+          let i = 0
149
+          let dias = course.dias
150
+          for (i = 0; i < dias.length; i++ ){
151
+            console.log("Esta es la letra ahora: ", dias[i])
152
+            let month_year = "2020-12"
153
+            let date_time = ""
154
+
155
+            if(dias[i] == "L"){
156
+              date = "-14 "
157
+              date_time = month_year + date + empieza
158
+              console.log()
159
+              console.log("Starts: ", date_time)
160
+              // console.log("Duracion: ", dura)
161
+              // console.log(typeof(empieza))
162
+              courses.push({start: date_time, duration: dura , note: course.code})
163
+              console.log(dias)
164
+            }
165
+
166
+            if(dias[i] == "M"){
167
+              date = "-15 "
168
+              date_time = month_year + date + empieza
169
+              console.log()
170
+              console.log("Starts: ", date_time)
171
+              // console.log("Duracion: ", dura)
172
+              // console.log(typeof(empieza))
173
+              courses.push({start: date_time, duration: dura , note: course.code})
174
+              console.log(dias)
175
+            }
176
+
177
+            if(dias[i] == "W"){
178
+              date = "-16 "
179
+              date_time = month_year + date + empieza
180
+              console.log()
181
+              console.log("Starts: ", date_time)
182
+              // console.log("Duracion: ", dura)
183
+              // console.log(typeof(empieza))
184
+              courses.push({start: date_time, duration: dura , note: course.code})
185
+              console.log(dias)
186
+            }
187
+
188
+            if(dias[i] == "J"){
189
+              date = "-17 "
190
+              date_time = month_year + date + empieza
191
+              console.log()
192
+              console.log("Starts: ", date_time)
193
+              // console.log("Duracion: ", dura)
194
+              // console.log(typeof(empieza))
195
+              courses.push({start: date_time, duration: dura , note: course.code})
196
+              console.log(dias)
197
+            }
198
+
199
+            if(dias[i] == "V"){
200
+              date = "-18 "
201
+              date_time = month_year + date + empieza
202
+              console.log()
203
+              console.log("Starts: ", date_time)
204
+              // console.log("Duracion: ", dura)
205
+              // console.log(typeof(empieza))
206
+              courses.push({start: date_time, duration: dura , note: course.code})
207
+              console.log(dias)
208
+            }
209
+          }
210
+        })
211
+
212
+        setSampleEvents(courses)
213
+  }
214
+
215
+    // console.log(courses)
216
+  }
217
+
218
+  const onRefresh = React.useCallback(async ()=>{
219
+    setRefreshing(true)
220
+    setSampleEvents([])
221
+    getMyCurriculum()
222
+    setRefreshing(false)
223
+
224
+}, [refreshing])
225
+
226
+  const renderCourses = ()=>{
227
+    console.log(sampleEvents, 'sampleevents')
228
+    if(sampleEvents.length > 0){
229
+      return (
230
+       <View>
231
+          <Text>AGENDA DE LA UNI</Text>
232
+          <WeeklyCalendar events={sampleEvents} style={{ height: 400 }} />
233
+       </View>
234
+      )
235
+    }
236
+    else{
237
+      return (
238
+        <View>
239
+          <Text>No tienes agenda porque todavía no has hecho matricula</Text>
240
+          {/* <WeeklyCalendar events={sampleEvents} style={{ height: 400 }} /> */}
241
+       </View>
242
+      )
243
+    }
244
+  }
245
+
246
+  useEffect(()=>{
247
+    getMyCurriculum()
248
+  }, [])
249
+  
250
+
251
+  return (
252
+
253
+    <ScrollView
254
+          refreshControl={<RefreshControl refreshing={refreshing} onRefresh={onRefresh}/>}
255
+          >
256
+              {renderCourses()}
257
+    </ScrollView>    
258
+  );
259
+}
260
+ 
261
+const styles = StyleSheet.create({
262
+  container: {
263
+    flex: 1,
264
+    backgroundColor: '#fff',
265
+    alignItems: 'center',
266
+    justifyContent: 'center',
267
+  }
268
+});

+ 4
- 4
client/Screens/CurrentCourses.js Visa fil

@@ -29,7 +29,7 @@ const CurrentCourses = () =>{
29 29
     const [courses, setCourses] = useState(null)
30 30
     const [refreshing, setRefreshing] = useState(false)
31 31
     const [selectedId, setSelectedId] = useState(null); // course_id
32
-    const [animating, setAnimating] = useState('')
32
+    const [animating, setAnimating] = useState(false)
33 33
     const [modalVisible, setModalVisible] = useState(false)
34 34
     const [code, setCode] = useState(null)
35 35
     const [days, setDays] = useState(null)
@@ -54,7 +54,7 @@ const CurrentCourses = () =>{
54 54
         let user_id = parseInt(id)
55 55
 
56 56
         try {
57
-            let response = await axios(`http://da0406585426.ngrok.io/api/get_current_courses`, {
57
+            let response = await axios(`http://7f9219a069f7.ngrok.io/api/get_current_courses`, {
58 58
                 method: 'POST',
59 59
                 headers: {
60 60
                     'content-type': 'application/json',
@@ -64,7 +64,7 @@ const CurrentCourses = () =>{
64 64
                     user_id: user_id
65 65
                 }
66 66
             })
67
-
67
+            console.log(response.data.list)
68 68
             
69 69
             if(response.data.list){
70 70
                 setCourses(response.data.list)
@@ -86,7 +86,7 @@ const CurrentCourses = () =>{
86 86
         console.log(year)
87 87
 
88 88
         try {
89
-            let response = await axios(`http://da0406585426.ngrok.io/api/delete_course`, {
89
+            let response = await axios(`http://7f9219a069f7.ngrok.io/api/delete_course`, {
90 90
                 method: 'DELETE',
91 91
                 headers: {
92 92
                     'content-type': 'application/json',

+ 43
- 16
client/Screens/EditGrades.js Visa fil

@@ -30,10 +30,10 @@ const CurrentCourses = () =>{
30 30
     const [courses, setCourses] = useState(null)
31 31
     const [refreshing, setRefreshing] = useState(false)
32 32
     const [selectedId, setSelectedId] = useState(null); // course_id
33
-    const [animating, setAnimating] = useState('')
33
+    const [animating, setAnimating] = useState(false)
34 34
     const [modalVisible, setModalVisible] = useState(false)
35
-    const [year, setYear] = useState(null)
36
-    const [semestre, setSemestre] = useState(null)
35
+    const [year, setYear] = useState(1)
36
+    const [semester, setSemester] = useState(1)
37 37
     const [grade, setGrade] = useState('A')
38 38
 
39 39
     
@@ -43,14 +43,14 @@ const CurrentCourses = () =>{
43 43
     }
44 44
 
45 45
 
46
-    const getAllMyCourses = async()=>{
46
+    const getCoursesBySemester = async()=>{
47 47
         const token = await SecureStore.getItemAsync('token')
48 48
         let id = await SecureStore.getItemAsync('id')
49 49
         let user_id = parseInt(id)
50 50
         console.log(user_id)
51 51
 
52 52
         try {
53
-            let response = await axios(`http://da0406585426.ngrok.io/api/get_all_courses_user_has_taken?user_id=${user_id}`, {
53
+            let response = await axios(`http://7f9219a069f7.ngrok.io/api/get_all_courses_by_semester?user_id=${user_id}&year=${year}&semestre=${semester}`, {
54 54
                 method: 'GET',
55 55
                 headers: {
56 56
                     'content-type': 'application/json',
@@ -72,7 +72,7 @@ const CurrentCourses = () =>{
72 72
         let user_id = parseInt(id)
73 73
 
74 74
         try {
75
-            let response = await axios(`http://da0406585426.ngrok.io/api/delete_course`, {
75
+            let response = await axios(`http://7f9219a069f7.ngrok.io/api/delete_course`, {
76 76
                 method: 'DELETE',
77 77
                 headers: {
78 78
                     'content-type': 'application/json',
@@ -82,7 +82,7 @@ const CurrentCourses = () =>{
82 82
                     user_id: user_id,
83 83
                     course_id: selectedId,
84 84
                     year: year,
85
-                    semestre: semestre
85
+                    semestre: semester
86 86
                 }
87 87
             })
88 88
 
@@ -99,7 +99,7 @@ const CurrentCourses = () =>{
99 99
                 Alert.alert(response.data.msg)
100 100
             }, 5000) 
101 101
 
102
-            getAllMyCourses() // get current courses again
102
+            getCoursesBySemester() // get current courses again
103 103
             
104 104
             
105 105
            
@@ -113,11 +113,11 @@ const CurrentCourses = () =>{
113 113
         const token = await SecureStore.getItemAsync('token')
114 114
         let id = await SecureStore.getItemAsync('id')
115 115
         let user_id = parseInt(id)
116
-        console.log(semestre)
116
+        console.log(semester)
117 117
         console.log(year)
118 118
 
119 119
         try {
120
-            let response = await axios(`http://da0406585426.ngrok.io/api/update_grade_and_gpa`, {
120
+            let response = await axios(`http://7f9219a069f7.ngrok.io/api/update_grade_and_gpa`, {
121 121
                 method: 'PATCH',
122 122
                 headers: {
123 123
                     'content-type': 'application/json',
@@ -127,7 +127,7 @@ const CurrentCourses = () =>{
127 127
                     user_id: user_id,
128 128
                     course_id: selectedId,
129 129
                     year: year,
130
-                    semestre: semestre,
130
+                    semestre: semester,
131 131
                     grade: grade
132 132
                 }
133 133
             })
@@ -145,7 +145,7 @@ const CurrentCourses = () =>{
145 145
                 Alert.alert(response.data.msg)
146 146
             }, 5000) 
147 147
 
148
-            getAllMyCourses() // get current courses again
148
+            getCoursesBySemester() // get current courses again
149 149
             
150 150
             
151 151
            
@@ -157,7 +157,7 @@ const CurrentCourses = () =>{
157 157
 
158 158
     const onRefresh = React.useCallback(async ()=>{
159 159
         setRefreshing(true)
160
-        getAllMyCourses()
160
+        getCoursesBySemester()
161 161
         setRefreshing(false)
162 162
 
163 163
     }, [refreshing])
@@ -166,8 +166,8 @@ const CurrentCourses = () =>{
166 166
 
167 167
 
168 168
     useEffect(()=>{
169
-        getAllMyCourses()
170
-    },[])
169
+        getCoursesBySemester()
170
+    },[year, semester])
171 171
 
172 172
     const renderItem = ({ item }) => {
173 173
         const backgroundColor = item.course_id === selectedId ? "#e60505" : "#fafbfc";
@@ -178,7 +178,7 @@ const CurrentCourses = () =>{
178 178
               setModalVisible(true)
179 179
               setSelectedId(item.course_id)
180 180
               setYear(item.year)
181
-              setSemestre(item.semestre)
181
+              setSemester(item.semestre)
182 182
               setGrade(item.grade)
183 183
             }}
184 184
             style={{ backgroundColor }}
@@ -226,6 +226,33 @@ const CurrentCourses = () =>{
226 226
                 <Button title="Close" onPress={toggle}/>
227 227
             </View>
228 228
         </Modal>
229
+        <View style={{flexDirection: 'row'}}>
230
+                <View style={{margin: 8}}>
231
+                    <Text>Year</Text>
232
+                    <Picker
233
+                            selectedValue={year}
234
+                            style={{ width: 50}}
235
+                            onValueChange={(itemValue, itemIndex) => setYear(itemValue) }>
236
+                            <Picker.Item label="1" value="1" />
237
+                            <Picker.Item label="2" value="2" />
238
+                            <Picker.Item label="3" value="3" />
239
+                            <Picker.Item label="4" value="4" />
240
+                            <Picker.Item label="5" value="5" />
241
+                            <Picker.Item label="6" value="6" />
242
+                    </Picker>
243
+                </View>
244
+                <View style={{margin: 8}}>
245
+                    <Text>Semester</Text>
246
+                    <Picker
247
+                            selectedValue={semester}
248
+                            style={{ width: 50}}
249
+                            onValueChange={(itemValue, itemIndex) => setSemester(itemValue) }>
250
+                            <Picker.Item label="1" value="1" />
251
+                            <Picker.Item label="2" value="2" />
252
+                            <Picker.Item label="3" value="3" />
253
+                    </Picker>
254
+            </View>
255
+        </View>
229 256
             
230 257
 
231 258
         </View>

+ 4
- 3
client/Screens/EnrollNextSemester.js Visa fil

@@ -30,7 +30,7 @@ const EnrollNextSemester = () => {
30 30
   const [selectedId, setSelectedId] = useState(null);
31 31
   const [data, setData] = useState([])
32 32
   const [modalVisible, setModalVisible] = useState(false)
33
-  const [animating, setAnimating] = useState('')
33
+  const [animating, setAnimating] = useState(false)
34 34
   const [isSummer, setIsSummer] = useState('false')
35 35
   const [code, setCode] = useState('')
36 36
   const [creditos, setCreditos] = useState('')
@@ -55,7 +55,7 @@ const EnrollNextSemester = () => {
55 55
 
56 56
       let response = await axios({
57 57
         method: 'POST',
58
-        url: 'http://da0406585426.ngrok.io/api/matricular_prox_semestre',
58
+        url: 'http://7f9219a069f7.ngrok.io/api/matricular_prox_semestre',
59 59
         headers: {
60 60
           'content-type': 'application/json',
61 61
           Authorization: `Token ${token}`
@@ -93,7 +93,7 @@ const EnrollNextSemester = () => {
93 93
       const token = await SecureStore.getItemAsync('token')
94 94
       const response = await axios({
95 95
           method: 'GET',
96
-          url: `http://da0406585426.ngrok.io/api/select_course_prox_semestre?code=${text}`,
96
+          url: `http://7f9219a069f7.ngrok.io/api/select_course_prox_semestre?code=${text}`,
97 97
           headers: {
98 98
             'content-type': 'application/json',
99 99
             Authorization: `Token ${token}`
@@ -116,6 +116,7 @@ const EnrollNextSemester = () => {
116 116
       <Item
117 117
         item={item}
118 118
         onPress={() => {
119
+          console.log('heyyyy')
119 120
           setSelectedId(item.id)
120 121
           setCourseName(item.name)
121 122
           setCode(item.code)

+ 1
- 1
client/Screens/HomeScreen.js Visa fil

@@ -12,7 +12,7 @@ function HomeScreen({ navigation }) {
12 12
     console.log(token, id)
13 13
 
14 14
     let response = await Axios({
15
-      url: 'http://da0406585426.ngrok.io/api/hello',
15
+      url: 'http://7f9219a069f7.ngrok.io/api/hello',
16 16
       method: 'GET',
17 17
       headers: {
18 18
           Authorization: `Token ${token}`

+ 7
- 2
client/Screens/Login.js Visa fil

@@ -17,12 +17,15 @@ import Logout from './Logout'
17 17
 import CurrentCourses from './CurrentCourses'
18 18
 import EditGrades from './EditGrades'
19 19
 import UpdateSemYear from './UpdateSemYear'
20
+import Agenda from './Agenda'
20 21
 
21 22
 
22 23
 const Drawer = createDrawerNavigator()
23 24
 
24 25
 const IOS_CLIENT_ID =
25 26
   "116415331974-tf6sehooctplmmn7j0gt831mdf1oqipl.apps.googleusercontent.com";
27
+const ANDROID_CLIENT_ID =
28
+  "116415331974-72n6g689k4me386dod763gi31vpuh71a.apps.googleusercontent.com";
26 29
 
27 30
 export default function Login() {
28 31
   const [hasToken, setHasToken] = useState(false)
@@ -31,6 +34,7 @@ export default function Login() {
31 34
     try {
32 35
       const result = await Google.logInAsync({
33 36
         iosClientId: IOS_CLIENT_ID,
37
+        androidClientId: ANDROID_CLIENT_ID,
34 38
         scopes: ["profile", "email"]
35 39
       })
36 40
 
@@ -39,7 +43,7 @@ export default function Login() {
39 43
 
40 44
         try {
41 45
           // login user in backend
42
-          let response = await fetch('http://da0406585426.ngrok.io/rest-auth/google/', {
46
+          let response = await fetch('http://7f9219a069f7.ngrok.io/rest-auth/google/', {
43 47
             method: 'POST',
44 48
             headers: {
45 49
               'content-type': 'application/json'
@@ -60,7 +64,7 @@ export default function Login() {
60 64
           const token = await SecureStore.getItemAsync('token')
61 65
 
62 66
           // storing our id
63
-          let id = await fetch('http://da0406585426.ngrok.io/api/get_user_id', {
67
+          let id = await fetch('http://7f9219a069f7.ngrok.io/api/get_user_id', {
64 68
             method: 'GET',
65 69
             headers: {
66 70
               'content-type': 'application/json',
@@ -102,6 +106,7 @@ export default function Login() {
102 106
     <Drawer.Navigator initialRouteName="Home">
103 107
       <Drawer.Screen name="Home" component={HomeScreen}/>
104 108
       <Drawer.Screen name="Notifications" component={NotificationsScreen} />
109
+      <Drawer.Screen name="Agenda" component={Agenda} />
105 110
       {/* <Drawer.Screen name="Settings" component={SettingScreen} /> */}
106 111
       <Drawer.Screen name="Add Taken Courses" component={AddTakenCourse} />
107 112
       <Drawer.Screen name="My Curriculum" component={MyCurriculum} />

+ 17
- 0
client/Screens/Logout.js Visa fil

@@ -1,12 +1,29 @@
1 1
 import * as React from 'react';
2 2
 import { Button, View } from 'react-native';
3 3
 import * as SecureStore from 'expo-secure-store';
4
+import Axios from 'axios';
4 5
 
5 6
 function Logout({ navigation }) {
7
+
8
+  const backendLogout = async()=>{
9
+      const token = await SecureStore.getItemAsync('token')
10
+      
11
+      let response = await Axios({
12
+        method: 'POST',
13
+        url: 'http://7f9219a069f7.ngrok.io/api/logout',
14
+        headers: {
15
+          'content-type': 'application/json',
16
+          Authorization: `Token ${token}`
17
+        }
18
+      })
19
+      console.log(response.data)
20
+  }
21
+
6 22
   return (
7 23
     <View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
8 24
       <Button onPress={
9 25
         ()=>{
26
+          backendLogout()
10 27
           SecureStore.deleteItemAsync('token')
11 28
           SecureStore.deleteItemAsync('id')
12 29
           navigation.push('Login')

+ 2
- 2
client/Screens/MyCurriculum.js Visa fil

@@ -20,7 +20,7 @@ const MyCurriculum = () =>{
20 20
         let user_id = parseInt(id)
21 21
 
22 22
         try {
23
-            let response = await axios('http://da0406585426.ngrok.io/api/see_gpa', {
23
+            let response = await axios('http://7f9219a069f7.ngrok.io/api/see_gpa', {
24 24
                 method: 'POST',
25 25
                 headers: {
26 26
                     Authorization: `Token ${token}`
@@ -43,7 +43,7 @@ const MyCurriculum = () =>{
43 43
         let numbers = []
44 44
 
45 45
         try {
46
-            let response = await axios(`http://da0406585426.ngrok.io/api/get_all_courses_by_semester?user_id=${user_id}&year=${year}&semestre=${semester}`, {
46
+            let response = await axios(`http://7f9219a069f7.ngrok.io/api/get_all_courses_by_semester?user_id=${user_id}&year=${year}&semestre=${semester}`, {
47 47
                 method: 'GET',
48 48
                 headers: {
49 49
                     'content-type': 'application/json',

+ 2
- 2
client/Screens/UpdateSemYear.js Visa fil

@@ -21,7 +21,7 @@ const UpdateSemYear = () => {
21 21
 
22 22
         let response = await axios({
23 23
         method: 'PATCH',
24
-        url: 'http://da0406585426.ngrok.io/api/update_year_and_semester',
24
+        url: 'http://7f9219a069f7.ngrok.io/api/update_year_and_semester',
25 25
         headers: {
26 26
             'content-type': 'application/json',
27 27
             Authorization: `Token ${token}`
@@ -48,7 +48,7 @@ const UpdateSemYear = () => {
48 48
 
49 49
       let response = await axios({
50 50
         method: 'POST',
51
-        url: 'http://da0406585426.ngrok.io/api/get_year_and_semester',
51
+        url: 'http://7f9219a069f7.ngrok.io/api/get_year_and_semester',
52 52
         headers: {
53 53
           'content-type': 'application/json',
54 54
           Authorization: `Token ${token}`

+ 23
- 0
client/package-lock.json Visa fil

@@ -1674,6 +1674,14 @@
1674 1674
       "resolved": "https://registry.npmjs.org/@react-native-community/cli-types/-/cli-types-4.10.1.tgz",
1675 1675
       "integrity": "sha512-ael2f1onoPF3vF7YqHGWy7NnafzGu+yp88BbFbP0ydoCP2xGSUzmZVw0zakPTC040Id+JQ9WeFczujMkDy6jYQ=="
1676 1676
     },
1677
+    "@react-native-community/datetimepicker": {
1678
+      "version": "2.3.2",
1679
+      "resolved": "https://registry.npmjs.org/@react-native-community/datetimepicker/-/datetimepicker-2.3.2.tgz",
1680
+      "integrity": "sha512-BbDmWVIaSYoYK2x5tRRuy/UWUVS6WtZ+3D210zYZgyD47yEVcTbaLFL9zFw7VxNMb8c/6BFcEpC6k18WTYplwA==",
1681
+      "requires": {
1682
+        "invariant": "^2.2.4"
1683
+      }
1684
+    },
1677 1685
     "@react-native-community/masked-view": {
1678 1686
       "version": "0.1.10",
1679 1687
       "resolved": "https://registry.npmjs.org/@react-native-community/masked-view/-/masked-view-0.1.10.tgz",
@@ -5570,6 +5578,11 @@
5570 5578
         "minimist": "^1.2.5"
5571 5579
       }
5572 5580
     },
5581
+    "moment": {
5582
+      "version": "2.29.1",
5583
+      "resolved": "https://registry.npmjs.org/moment/-/moment-2.29.1.tgz",
5584
+      "integrity": "sha512-kHmoybcPV8Sqy59DwNDY3Jefr64lK/by/da0ViFcuA4DH0vQg5Q6Ze5VimxkfQNSC+Mls/Kx53s7TjP1RhFEDQ=="
5585
+    },
5573 5586
     "ms": {
5574 5587
       "version": "2.1.2",
5575 5588
       "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
@@ -6664,6 +6677,16 @@
6664 6677
         "react-timer-mixin": "^0.13.4"
6665 6678
       }
6666 6679
     },
6680
+    "react-native-weekly-calendar": {
6681
+      "version": "0.2.0",
6682
+      "resolved": "https://registry.npmjs.org/react-native-weekly-calendar/-/react-native-weekly-calendar-0.2.0.tgz",
6683
+      "integrity": "sha512-F8nGekXSsKln+QbSSNFr5h1Qwz+m88baP8zu85gKzo0gkvOkj4TJoDHpa2/tI87RyUL/B1FahnK15r/F0WMbBA==",
6684
+      "requires": {
6685
+        "@react-native-community/datetimepicker": "~2.3.0",
6686
+        "moment": "^2.24.0",
6687
+        "prop-types": "^15.5.7"
6688
+      }
6689
+    },
6667 6690
     "react-refresh": {
6668 6691
       "version": "0.4.3",
6669 6692
       "resolved": "https://registry.npmjs.org/react-refresh/-/react-refresh-0.4.3.tgz",

+ 2
- 1
client/package.json Visa fil

@@ -28,7 +28,8 @@
28 28
     "react-native-safe-area-context": "3.1.4",
29 29
     "react-native-screens": "~2.10.1",
30 30
     "react-native-table-component": "^1.2.1",
31
-    "react-native-web": "~0.13.12"
31
+    "react-native-web": "~0.13.12",
32
+    "react-native-weekly-calendar": "^0.2.0"
32 33
   },
33 34
   "devDependencies": {
34 35
     "@babel/core": "~7.9.0"

Binär
organizar/__pycache__/organizar.cpython-38.pyc Visa fil


+ 1
- 1
primer_sem/Ciencias_Sociales.json
Filskillnaden har hållits tillbaka eftersom den är för stor
Visa fil


+ 1
- 1
segundo_sem/Ciencias_Sociales2.json
Filskillnaden har hållits tillbaka eftersom den är för stor
Visa fil


+ 1
- 1
segundo_sem/Humanidades2.json
Filskillnaden har hållits tillbaka eftersom den är för stor
Visa fil


+ 1
- 1
segundo_sem/Humanidades_Grad2.json Visa fil

@@ -1 +1 @@
1
-{"Horario ": ["Horario SEGUNDO SEMESTRE 2018-2019"], "ESHI6019": ["\"NOVELLA Y EL DISCURSO LEG", 3], "ESHI6105": ["LINGUSITICA HISPANICA", 3], "ESHI6546": ["ENSAYO ESPANOL GENER '98", 3], "ESHI6559": ["INVESTIGACION GRADUADA", 3], "ESHI6560": ["INVESTIGACION GRADUADA", 3], "ESHI6705": ["PROBLEMAS LITER PUERTORRIQ", 3], "ESHI6895": ["TESIS DE MAESTRIA", 0], "ESHI6896": ["CONT TESIS DE MAESTRIA", 0], "ESHI6900": ["EXAMEN GENERAL DE GRADO", 0], "ESHI8019": ["POESIA LUIS PALES MATOS", 3], "ESHI8663": ["JOSE MARTI", 3], "ESHI8701": ["INVESTIGACION AVANZADA", 3], "ESHI8702": ["INVESTIGACION AVANZADA", 3], "ESHI8890": ["EXAMEN DE GRADO", 0], "ESHI8891": ["TESIS DOCTORAL", 0], "ESHI8892": ["CONT TESIS DOCTORAL", 0], "ESHI8900": ["EXAMEN DE CANDIDATURA", 0], "ESIN6995": ["SEM INSTIT INVIERN HARVARD", 3], "FILO6026": ["POLITICA Y ETICA ANTIGUA", 1], "FILO6035": ["ETICA", 3], "FILO6302": ["BUDDHISMO Y FILOSOFIA II", 3], "FILO6606": ["INVEST DIRIGIDA FILO II", 3], "FILO6747": ["PSICOLOGIA FILOSOFICA", 3], "FILO6895": ["TESIS", 0], "FILO6896": ["CONTINUACION DE TESIS", 0], "FILO6900": ["EXAMEN GENERAL DE GRADO", 0], "GECU6205": ["ADM ESTRAT ORGANI CULTURAL", 3], "GECU6405": ["ARCHIVOS EN ACCION", 3], "GECU6901": ["PROPUES GESTION CULTURAL", 3], "GECU6902": ["PROYECTO DE CONCLUSION", 3], "GECU6993": ["GESTION ARTES VISUALES", 3], "GECU6994": ["RECAUDACION DE FONDOS", 3], "GECU6994_LAB": ["EVALUACION DE PROYECTOS", 1], "GECU6995": ["MANJ DAT MASIV:MIR ECOS CU", 3], "GECU6999": ["INTERNADO GEST Y ADM CULTU", 3], "HIST6025": ["SEMINARIO DE TESIS", 3], "HIST6029": ["DIPL HISPANOAM S.XIX-SS", 3], "HIST6052": ["HISTORIOG, CRITICA HIST", 3], "HIST6895": ["TESIS", 0], "HIST6896": ["CONTINUACION DE TESIS", 0], "HIST6900": ["EXAMEN GENERAL DE GRADO", 0], "HIST8005": ["SEM INV HIST DE P.R.-I", 3], "HIST8015": ["SEM LECT AMER LAT XIX-XX", 3], "HIST8035": ["SEM LECTURA SUPERV I", 3], "HIST8039": ["SEM TEMAS HIST DE AFRICA", 3], "HIST8045": ["SEM INVEST DIRIGIDA I", 3], "HIST8125": ["SEM HIST DE LA MUJER I", 3], "HIST8891": ["TESIS DOCTORAL", 0], "HIST8892": ["CONT TESIS DOCTORAL", 0], "HIST8900": ["PROPUESTA TESIS DOCTORAL", 3], "INGL6029": ["SEM:TEMAS ESP EN LITERATUR", 3], "INGL6067": ["LITERATURA Y CINE", 1], "INGL6415": ["SEM CRITICA LITE Y TEORIA", 3], "INGL6430": ["SHAKESPEARE:TEMA ESCOGID", 3], "INGL6439": ["ESTUDIOS EN LA POESIA", 3], "INGL6475": ["DIALECT DEL ANGLO-PARLAN", 3], "INGL6499": ["SEM FONOLOGIA DEL INGLES", 3], "INGL6891": ["ENSAYO INVEST LITERATURA I", 3], "INGL6892": ["ENSAYO INVEST LITE II", 0], "INGL6893": ["ENSAYO INVEST LINGUIST I", 3], "INGL6894": ["ENSAYO INVEST LINGUIST II", 0], "INGL6895": ["TESIS", 3], "INGL6896": ["CONTINUACION DE TESIS", 0], "INGL6900": ["EXAMEN GENERAL DE GRADO", 0], "INGL8007": ["SEM:NACI Y MUERTE LENGUAJE", 3], "INGL8020": ["NARRATIVA ESCRITO CARIBE", 3], "INGL8045": ["ESTUDIO INDEPENDIENTE", 3], "INGL8080": ["CARIB TEMA GLOB TEOR ANA", 3], "INGL8099": ["INVE LITE Y LINGUI CARIB", 0], "INGL8201": ["SEMINAR TRABAJO DE CAMPO", 3], "INGL8890": ["REDAC ENSAYO CRITICO DOC", 0], "INGL8891": ["DISERTACION I", 0], "INGL8892": ["CONTINUACION DISERTACION", 0], "LING6008": ["ESPA E.U.GRAMAT CONTACTO", 3], "LING6015": ["PRODUCCION DE TEXTOS", 3], "LING6020": ["METODOS INVEST LING MODE", 3], "LING6040": ["FONOLOGIA", 3], "LING6050": ["MORFOSINTAXIS", 3], "LING6590": ["SEM EN LING HISTORICA", 3], "LING6895": ["TESIS", 0], "LING6896": ["CONTINUACION DE TESIS", 0], "LING6920": ["EXAMEN GENERAL DE GRADO", 0], "LING6995": ["LINGUISTICA INTERDISCIPLIN", 1], "LITE6019": ["NOVELLA EUROPEA Y DISC LEG", 3], "LITE6465": ["ESTUD NARRATIVA: SIG XIX", 3], "LITE6895": ["TESIS", 0], "LITE6896": ["CONTINUACION DE TESIS", 0], "LITE6900": ["EXAMEN GENERAL DE GRADO", 0], "LITE6905": ["INV DIRIG LITE COMPAR 1", 3], "LITE6991": ["CUERPO, MEMORIA, ESCRITURA", 1], "TRAD6007": ["TRAD TXT PERIOD:ING A ESPN", 3], "TRAD6108": ["TRAD COMERC ESPA-INGL", 3], "TRAD6452": ["SINTAX SUPERIOR ESPAN II", 3], "TRAD6454": ["REDACCION Y ESTILO", 3], "TRAD6455": ["SEMIOTICA", 3], "TRAD6457": ["SINTAXIS INGLESA", 3], "TRAD6505": ["TRADUCCION A VISTA", 3], "TRAD6526": ["SEM REDACCION EN INGLES", 3], "TRAD6620": ["SEM:PRACT TRAD ESPAN A ING", 3], "TRAD6640": ["TRADUC PAR MUSEO:ESP A ING", 3], "TRAD6650": ["TRADUC Y DEPORT-INGL A ESP", 3], "TRAD6700": ["TRAD TEXT PERIOD ING-ESPAN", 3], "TRAD6895": ["TESIS", 0], "TRAD6896": ["CONTINUACION DE TESIS", 0], "TRAD6920": ["EXAMEN GENERAL DE GRADO", 0], "TRAD6990": ["REDAC,EDIC,REVS TRADUC ING", 3]}
1
+{"Horario ": ["Horario SEGUNDO SEMESTRE 2018-2019"], "ESHI6019": ["\"NOVELLA Y EL DISCURSO LEG", 3], "ESHI6105": ["LINGUSITICA HISPANICA", 3], "ESHI6546": ["ENSAYO ESPANOL GENER 98", 3], "ESHI6559": ["INVESTIGACION GRADUADA", 3], "ESHI6560": ["INVESTIGACION GRADUADA", 3], "ESHI6705": ["PROBLEMAS LITER PUERTORRIQ", 3], "ESHI6895": ["TESIS DE MAESTRIA", 0], "ESHI6896": ["CONT TESIS DE MAESTRIA", 0], "ESHI6900": ["EXAMEN GENERAL DE GRADO", 0], "ESHI8019": ["POESIA LUIS PALES MATOS", 3], "ESHI8663": ["JOSE MARTI", 3], "ESHI8701": ["INVESTIGACION AVANZADA", 3], "ESHI8702": ["INVESTIGACION AVANZADA", 3], "ESHI8890": ["EXAMEN DE GRADO", 0], "ESHI8891": ["TESIS DOCTORAL", 0], "ESHI8892": ["CONT TESIS DOCTORAL", 0], "ESHI8900": ["EXAMEN DE CANDIDATURA", 0], "ESIN6995": ["SEM INSTIT INVIERN HARVARD", 3], "FILO6026": ["POLITICA Y ETICA ANTIGUA", 1], "FILO6035": ["ETICA", 3], "FILO6302": ["BUDDHISMO Y FILOSOFIA II", 3], "FILO6606": ["INVEST DIRIGIDA FILO II", 3], "FILO6747": ["PSICOLOGIA FILOSOFICA", 3], "FILO6895": ["TESIS", 0], "FILO6896": ["CONTINUACION DE TESIS", 0], "FILO6900": ["EXAMEN GENERAL DE GRADO", 0], "GECU6205": ["ADM ESTRAT ORGANI CULTURAL", 3], "GECU6405": ["ARCHIVOS EN ACCION", 3], "GECU6901": ["PROPUES GESTION CULTURAL", 3], "GECU6902": ["PROYECTO DE CONCLUSION", 3], "GECU6993": ["GESTION ARTES VISUALES", 3], "GECU6994": ["RECAUDACION DE FONDOS", 3], "GECU6994_LAB": ["EVALUACION DE PROYECTOS", 1], "GECU6995": ["MANJ DAT MASIV:MIR ECOS CU", 3], "GECU6999": ["INTERNADO GEST Y ADM CULTU", 3], "HIST6025": ["SEMINARIO DE TESIS", 3], "HIST6029": ["DIPL HISPANOAM S.XIX-SS", 3], "HIST6052": ["HISTORIOG, CRITICA HIST", 3], "HIST6895": ["TESIS", 0], "HIST6896": ["CONTINUACION DE TESIS", 0], "HIST6900": ["EXAMEN GENERAL DE GRADO", 0], "HIST8005": ["SEM INV HIST DE P.R.-I", 3], "HIST8015": ["SEM LECT AMER LAT XIX-XX", 3], "HIST8035": ["SEM LECTURA SUPERV I", 3], "HIST8039": ["SEM TEMAS HIST DE AFRICA", 3], "HIST8045": ["SEM INVEST DIRIGIDA I", 3], "HIST8125": ["SEM HIST DE LA MUJER I", 3], "HIST8891": ["TESIS DOCTORAL", 0], "HIST8892": ["CONT TESIS DOCTORAL", 0], "HIST8900": ["PROPUESTA TESIS DOCTORAL", 3], "INGL6029": ["SEM:TEMAS ESP EN LITERATUR", 3], "INGL6067": ["LITERATURA Y CINE", 1], "INGL6415": ["SEM CRITICA LITE Y TEORIA", 3], "INGL6430": ["SHAKESPEARE:TEMA ESCOGID", 3], "INGL6439": ["ESTUDIOS EN LA POESIA", 3], "INGL6475": ["DIALECT DEL ANGLO-PARLAN", 3], "INGL6499": ["SEM FONOLOGIA DEL INGLES", 3], "INGL6891": ["ENSAYO INVEST LITERATURA I", 3], "INGL6892": ["ENSAYO INVEST LITE II", 0], "INGL6893": ["ENSAYO INVEST LINGUIST I", 3], "INGL6894": ["ENSAYO INVEST LINGUIST II", 0], "INGL6895": ["TESIS", 3], "INGL6896": ["CONTINUACION DE TESIS", 0], "INGL6900": ["EXAMEN GENERAL DE GRADO", 0], "INGL8007": ["SEM:NACI Y MUERTE LENGUAJE", 3], "INGL8020": ["NARRATIVA ESCRITO CARIBE", 3], "INGL8045": ["ESTUDIO INDEPENDIENTE", 3], "INGL8080": ["CARIB TEMA GLOB TEOR ANA", 3], "INGL8099": ["INVE LITE Y LINGUI CARIB", 0], "INGL8201": ["SEMINAR TRABAJO DE CAMPO", 3], "INGL8890": ["REDAC ENSAYO CRITICO DOC", 0], "INGL8891": ["DISERTACION I", 0], "INGL8892": ["CONTINUACION DISERTACION", 0], "LING6008": ["ESPA E.U.GRAMAT CONTACTO", 3], "LING6015": ["PRODUCCION DE TEXTOS", 3], "LING6020": ["METODOS INVEST LING MODE", 3], "LING6040": ["FONOLOGIA", 3], "LING6050": ["MORFOSINTAXIS", 3], "LING6590": ["SEM EN LING HISTORICA", 3], "LING6895": ["TESIS", 0], "LING6896": ["CONTINUACION DE TESIS", 0], "LING6920": ["EXAMEN GENERAL DE GRADO", 0], "LING6995": ["LINGUISTICA INTERDISCIPLIN", 1], "LITE6019": ["NOVELLA EUROPEA Y DISC LEG", 3], "LITE6465": ["ESTUD NARRATIVA: SIG XIX", 3], "LITE6895": ["TESIS", 0], "LITE6896": ["CONTINUACION DE TESIS", 0], "LITE6900": ["EXAMEN GENERAL DE GRADO", 0], "LITE6905": ["INV DIRIG LITE COMPAR 1", 3], "LITE6991": ["CUERPO, MEMORIA, ESCRITURA", 1], "TRAD6007": ["TRAD TXT PERIOD:ING A ESPN", 3], "TRAD6108": ["TRAD COMERC ESPA-INGL", 3], "TRAD6452": ["SINTAX SUPERIOR ESPAN II", 3], "TRAD6454": ["REDACCION Y ESTILO", 3], "TRAD6455": ["SEMIOTICA", 3], "TRAD6457": ["SINTAXIS INGLESA", 3], "TRAD6505": ["TRADUCCION A VISTA", 3], "TRAD6526": ["SEM REDACCION EN INGLES", 3], "TRAD6620": ["SEM:PRACT TRAD ESPAN A ING", 3], "TRAD6640": ["TRADUC PAR MUSEO:ESP A ING", 3], "TRAD6650": ["TRADUC Y DEPORT-INGL A ESP", 3], "TRAD6700": ["TRAD TEXT PERIOD ING-ESPAN", 3], "TRAD6895": ["TESIS", 0], "TRAD6896": ["CONTINUACION DE TESIS", 0], "TRAD6920": ["EXAMEN GENERAL DE GRADO", 0], "TRAD6990": ["REDAC,EDIC,REVS TRADUC ING", 3]}

Binär
server/CompanionApp/__pycache__/urls.cpython-38.pyc Visa fil


Binär
server/CompanionApp/__pycache__/views.cpython-38.pyc Visa fil


+ 2
- 1
server/CompanionApp/urls.py Visa fil

@@ -26,7 +26,8 @@ urlpatterns = [
26 26
     url('api/update_grade_and_gpa', views.updateGradeAndGPA),
27 27
     url('api/delete_course', views.deleteCourse),
28 28
     url('api/get_year_and_semester', views.getSemesterAndYear),
29
-    url('api/update_year_and_semester', views.updateSemesterAndYear)
29
+    url('api/update_year_and_semester', views.updateSemesterAndYear),
30
+    url('api/logout', views.logout)
30 31
 
31 32
 ]
32 33
 

+ 18
- 11
server/CompanionApp/views.py Visa fil

@@ -195,7 +195,7 @@ def addTakenCourse(request):
195 195
         semester = int(request.data['semester'])
196 196
         repeating = False
197 197
         
198
-
198
+      
199 199
         # set point of grade
200 200
         points = 0
201 201
         if grade == 'A':
@@ -209,14 +209,14 @@ def addTakenCourse(request):
209 209
         elif grade == 'F':
210 210
             points = 0
211 211
         else:
212
-            return JsonResponse({'msg': 'Insert A, B, C, D or F' }, status=status.HTTP_406_NOT_ACCEPTABLE)
212
+            return JsonResponse({'msg': 'Insert A, B, C, D or F' }, status=status.HTTP_200_OK)
213 213
 
214 214
         # find course credits
215 215
         cursor = connection.cursor()
216 216
         cursor.execute(f'Select creditos from "CompanionApp_curso" where id = {course_id} ')
217 217
         course = cursor.fetchone()
218 218
         creditos = int(course[0])
219
-
219
+       
220 220
         # check if student already took that class in the same year and semester he/she is trying to post
221 221
         cursor = connection.cursor()
222 222
         cursor.execute(f'select semestre, year, grade, course_id_id from "CompanionApp_matricula" where semestre = {semester} and year = {year} and course_id_id = {course_id} and user_id_id = {user_id}')
@@ -224,12 +224,11 @@ def addTakenCourse(request):
224 224
         if check != None:
225 225
             check = list(check)
226 226
             if int(check[0]) == semester and int(check[1]) == year and check[3] == course_id:
227
-                return JsonResponse({'msg': 'You already took the course that year and semester.' }, status=status.HTTP_406_NOT_ACCEPTABLE)
227
+                return JsonResponse({'msg': 'You already took the course that year and semester.' }, status=status.HTTP_200_OK)
228 228
             elif int(check[1]) != year:
229 229
                 pass
230 230
             elif int(check[1] == year) and int(check[0]) != semester:
231 231
                 pass
232
-            
233 232
         # matricular al estudiante
234 233
         cursor = connection.cursor()
235 234
         cursor.execute(f'INSERT INTO "CompanionApp_matricula" (semestre, year, grade, user_id_id, course_id_id) VALUES ({semester}, {year}, \'{grade}\', {user_id}, {course_id})')
@@ -263,6 +262,7 @@ def addTakenCourse(request):
263 262
         gpa = float("{:.2f}".format(gpa))
264 263
         cursor = connection.cursor()
265 264
         cursor.execute(f'UPDATE "CompanionApp_user" set gpa = {gpa} where id={user_id}')
265
+        print('ya')
266 266
         
267 267
         return JsonResponse({'msg': 'Ok, you can see that course in your curriculum'}, status=status.HTTP_201_CREATED)
268 268
 
@@ -314,13 +314,13 @@ def getAllCoursesBySemester(request):
314 314
         year = int(request.query_params['year'])
315 315
         semestre = int(request.query_params['semestre'])
316 316
         cursor = connection.cursor()
317
-        cursor.execute(f'SELECT c.name, c.code, c.creditos, m.user_id_id, m.year, m.semestre, m.grade FROM "CompanionApp_curso" c INNER JOIN "CompanionApp_matricula" m ON (c.id = m.course_id_id) where m.user_id_id = {user_id} and m.year = {year} and m.semestre = {semestre} and m.grade <> \'N%\' ')
317
+        cursor.execute(f'SELECT c.name, c.code, c.creditos, m.user_id_id, m.year, m.semestre, m.grade, c.id FROM "CompanionApp_curso" c INNER JOIN "CompanionApp_matricula" m ON (c.id = m.course_id_id) where m.user_id_id = {user_id} and m.year = {year} and m.semestre = {semestre} and m.grade <> \'N%\' ')
318 318
         fetchCourses = cursor.fetchall()
319 319
         courses = []
320 320
 
321 321
         # convert courses to an array of objects
322 322
         for i in range(0, len(fetchCourses)):
323
-            dic = {'name': fetchCourses[i][0], 'code': fetchCourses[i][1], 'creditos': fetchCourses[i][2], 'year': fetchCourses[i][4], 'semestre': fetchCourses[i][5], 'grade': fetchCourses[i][6]}
323
+            dic = {'name': fetchCourses[i][0], 'code': fetchCourses[i][1], 'creditos': fetchCourses[i][2], 'year': fetchCourses[i][4], 'semestre': fetchCourses[i][5], 'grade': fetchCourses[i][6], 'course_id': fetchCourses[i][7]}
324 324
             courses.append(dic)
325 325
             
326 326
         return JsonResponse({'list': courses}, status=status.HTTP_200_OK)
@@ -411,13 +411,13 @@ def getMyCurrentCourses(request):
411 411
 
412 412
         # find current semester of student, based on the current_year
413 413
         cursor = connection.cursor()
414
-        cursor.execute(f'select max(semestre) from "CompanionApp_matricula" where year = {current_year}')
414
+        cursor.execute(f'select max(semestre) from "CompanionApp_matricula" where year = {current_year} and user_id_id = {user_id}')
415 415
         current_semester = cursor.fetchone()
416 416
         current_semester = int(current_semester[0])
417 417
 
418 418
         # find current courses based on current_semester and current_year
419 419
         cursor = connection.cursor()
420
-        cursor.execute(f'select c.id, c.name, c.code, m.year, m.semestre, m.section, m.prof, m.salones, m.horarios, m.dias from "CompanionApp_matricula" m INNER JOIN "CompanionApp_curso" c on c.id = m.course_id_id where m.year = {current_year} and m.semestre={current_semester}')
420
+        cursor.execute(f'select c.id, c.name, c.code, m.year, m.semestre, m.section, m.prof, m.salones, m.horarios, m.dias from "CompanionApp_matricula" m INNER JOIN "CompanionApp_curso" c on c.id = m.course_id_id where m.year = {current_year} and m.semestre={current_semester} and m.user_id_id={user_id}')
421 421
         fetchCourses = cursor.fetchall()
422 422
 
423 423
         # convert courses array into dictionary
@@ -591,8 +591,11 @@ def deleteCourse(request):
591 591
 
592 592
             new_credits_taken_score = credits_taken_score - (current_points * creditos)
593 593
             new_credits_taken = credits_taken - creditos
594
-            gpa = new_credits_taken_score / new_credits_taken 
595
-            gpa = float("{:.2f}".format(gpa))
594
+            if new_credits_taken == 0:
595
+                gpa = 0.00
596
+            else:
597
+                gpa = new_credits_taken_score / new_credits_taken 
598
+                gpa = float("{:.2f}".format(gpa))
596 599
             print(new_credits_taken, 'credits taken')
597 600
             print(new_credits_taken_score, 'credits taken score')
598 601
 
@@ -633,6 +636,10 @@ def getSemesterAndYear(request):
633 636
         return JsonResponse({'msg': {'year': year, 'semestre': semestre} }, status = status.HTTP_202_ACCEPTED)
634 637
         
635 638
 
639
+@api_view(['POST',])
640
+def logout(request):
641
+    request.user.auth_token.delete()
642
+    return JsonResponse({"success": "Successfully logged out."}, status=status.HTTP_200_OK)
636 643
 
637 644
 
638 645
 @api_view(['GET', 'POST'])

Binär
server/restful/__pycache__/settings.cpython-38.pyc Visa fil