diff --git a/SE_API/ProjectRoutes.py b/SE_API/ProjectRoutes.py index 998039d..c27ebc9 100644 --- a/SE_API/ProjectRoutes.py +++ b/SE_API/ProjectRoutes.py @@ -307,8 +307,9 @@ def getProjectsByUser(token): arr = [] for p in user.projects_id_list: project = Project.get_by_id(int(p)) - projDict = dict(json.loads(project.to_JSON())) - arr.append(projDict) + if project is not None: + projDict = dict(json.loads(project.to_JSON())) + arr.append(projDict) if len(arr) != 0: return Response(response=json.dumps(arr), diff --git a/templates/js/controllers/classController.js b/templates/js/controllers/classController.js index 2d9b4fb..313881d 100644 --- a/templates/js/controllers/classController.js +++ b/templates/js/controllers/classController.js @@ -17,8 +17,17 @@ angular.module('SeHub') var dayDeltaOfCourse; var courseElapseTime; $scope.isCourseOver = false; + $scope.isInProject = false; $scope.createSctionStatus = "fa fa-angle-down"; + for(var i = 0; i < $scope.user.courses_id_list.length; i++) + if($scope.user.courses_id_list[i] === classId) + $scope.isInCourse = true; + + for(var i = 0; i < $scope.user.projects_id_list.length; i++) + if($scope.user.projects_id_list[i]) + $scope.isInProject = true; + $scope.displayProjects = function() { apiService.getCourseById(token, classId) .success(function(data) { @@ -36,22 +45,21 @@ angular.module('SeHub') courseElapseTime = dayDeltaOfCourse; } $scope.courseTimePresentege = ((courseElapseTime/dayDeltaOfCourse) * 100).toString(); - console.log($scope.courseTimePresentege); apiService.getProjectsByCourse(token, classId).success(function(data) // Get all the campuses - { - $scope.loadingData = false; - $scope.projects = data; - if ($scope.projects != null && $scope.projects.length > 0) { - $scope.projectsEmpty = false; - } - init(); // Executing the function to initialize projects display - }).error(function(err) { - console.error("Error: " + err); + { + $scope.loadingData = false; + $scope.projects = data; + if ($scope.projects != null && $scope.projects.length > 0) { + $scope.projectsEmpty = false; + } + init(); // Executing the function to initialize projects display + }).error(function(err) { + console.error(err.message); }); }) .error(function(err) { - console.error("Error: " + err); + console.error(err.message); }) } $scope.joinCourse = function() { @@ -60,14 +68,11 @@ angular.module('SeHub') $mdDialog.show($mdDialog.alert().title('Joined Course').content('You have successfully joined course.') .ariaLabel('Join course alert dialog').ok('Lets Start!').targetEvent()) .then(function() { - $location.path('/class/' + classId); // TODO TODO TODO + $location.path('/class/' + classId + '/' + $scope.project.courseName); // TODO TODO TODO }); // Pop-up alert }).error(function(err) { $mdDialog.show($mdDialog.alert().title('Error Joining Course').content(err.message + '.') .ariaLabel('Join course alert dialog').ok('Try Again!').targetEvent()); // Pop-up alert - // .then(function() { - // // $location.path('/newCourse'); // TODO TODO TODO - // }); }); } @@ -87,9 +92,6 @@ angular.module('SeHub') 'courseId': intClassId, 'gitRepository': $scope.project.repoOwner + '/' + $scope.project.gitRepoName }; - console.log("Look Down"); - console.log(jsonNewProj); - if ($scope.project.logoUrl) jsonNewProj.logo_url = $scope.project.logoUrl; @@ -115,7 +117,6 @@ angular.module('SeHub') $scope.goToProject = function(projectId) { - console.log("projects only from classID: " + projectId) $location.path('/project/' + projectId); } diff --git a/templates/js/controllers/homeController.js b/templates/js/controllers/homeController.js index 44bbcc0..7b4ed92 100644 --- a/templates/js/controllers/homeController.js +++ b/templates/js/controllers/homeController.js @@ -56,10 +56,8 @@ angular.module('SeHub') apiService.createMessage(token, jsonNewMsg).success(function(data) { - console.log("create Msg!"); }).error(function(err) { - console.log("Error Below"); console.log(err.message); }); @@ -85,7 +83,6 @@ angular.module('SeHub') { apiService.getProjectsByCourse(token, task.courseId).success(function(data) { - // console.log($scope.user); for(var i = 0; i < $scope.user.projects_id_list.length; i++) for(var j = 0; j < data.length; j++) { diff --git a/templates/js/controllers/myClassesController.js b/templates/js/controllers/myClassesController.js index 9fabe73..eac417c 100644 --- a/templates/js/controllers/myClassesController.js +++ b/templates/js/controllers/myClassesController.js @@ -14,27 +14,24 @@ angular.module('SeHub') $scope.showMyClass = false; $scope.coursesEmpty = true; $scope.campusId; + $scope.isMemberInCourse = false; var campusId = $routeParams.campusId; $scope.goToClass = function(classId, className) { - console.log("Done! " + className); $location.path('/class/' + classId.toString() + '/' + className); // Will display all the projects in this course } $scope.chooseCampusClicked = function() { $scope.isCourse = true; - console.log("Choose campus Clicked!!"); apiService.getAllCampuses(token).success(function(data) { $scope.campuses = data; - console.log("Campuses: "); - console.log($scope.campuses); }).error(function(err) { - console.log("Error: " + err); + console.log(err.message); }); } @@ -55,8 +52,6 @@ angular.module('SeHub') $scope.campusId = $scope.campuses[i].id; } } - console.log("NOW: "); - console.log($scope.campusId); var jsonNewCourse = { @@ -77,11 +72,9 @@ angular.module('SeHub') apiService.createCourse(token, jsonNewCourse).success(function(data) { - console.log("createCourse API done"); $mdDialog.show($mdDialog.alert().title('Course Created').content('You have created course successfully.') .ariaLabel('Email verification alert dialog').ok('Lets Start!').targetEvent()) .then(function() { - // $location.path('/newCourse'); // TODO TODO TODO $location.path('/class/' + data.id + '/' + data.courseName); // Will display all the projects in this course }); // Pop-up alert }).error(function(err) @@ -118,15 +111,12 @@ angular.module('SeHub') $scope.holdArrays.push(tempArr); } - //$scope.courses = ["lala", "aaa", "bbb", "ccc", "rrr"]; - var displayCourses = function() { apiService.getAllCoursesByCampus(token, campusId).success(function(data) // Shows all classes from this campus { $scope.loadingData = false; $scope.courses = data; - console.log("success " + $scope.courses); init(); // Executing the function to initialize course display if($scope.courses && $scope.courses.length > 0) { @@ -134,24 +124,17 @@ angular.module('SeHub') } }).error(function(err) { - console.log("error: " + err); + console.log(err.message); }); } - if($scope.user.isLecturer) { $scope.isStudent = false; - console.log("Lecturer Mode!"); } else { $scope.isStudent = true; - console.log("Student Mode!"); } - displayCourses(); // Will display the courses that the user related to // TODO!! - - - }]); \ No newline at end of file diff --git a/templates/js/controllers/projectController.js b/templates/js/controllers/projectController.js index d2d176a..8757136 100644 --- a/templates/js/controllers/projectController.js +++ b/templates/js/controllers/projectController.js @@ -9,7 +9,9 @@ angular.module('SeHub') $scope.loadingData = true; $scope.isMaster = false; $scope.isMember = false; - + $scope.project = []; + $scope.isInProject = false; + // $scope.thisProject = {}; // $scope.thisProject.courseName = $routeParams.className; @@ -22,7 +24,6 @@ angular.module('SeHub') { console.log(err.message); }); - } $scope.joinProject = function(ev) @@ -57,6 +58,7 @@ angular.module('SeHub') { $mdDialog.show($mdDialog.alert().title('Project Removal').content('Project removed successfully.') .ariaLabel('project remove alert dialog').ok('Ok').targetEvent(ev)); + $location.path('/myProjects'); }).error(function(err) { $mdDialog.show($mdDialog.alert().title('Project Removal').content('Project removal failed - reason' + err.message) @@ -96,6 +98,19 @@ angular.module('SeHub') $scope.isMember = true; } } + + apiService.getProjectsByCourse(token, $scope.project.courseId).success(function(data) + { + if($scope.user.projects_id_list) + for(var i = 0; i < $scope.project.length; i++) + if($scope.user.projects_id_list[i].id === data[i].id.toString()) + $scope.isInProject = true; + + }).error(function(err) + { + console.log(err.message); + }); + // if($scope.user === $scope.project.info.master_id) // { // $scope.isMasterOrLecturer = true; @@ -106,9 +121,8 @@ angular.module('SeHub') // } }).error(function(err) { - console.log("Error: " + err.message); + console.log(err.message); }); } - $scope.getProjectInfo(); // Get all this project data }]); \ No newline at end of file diff --git a/templates/views/class.html b/templates/views/class.html index 7baffb0..b587525 100644 --- a/templates/views/class.html +++ b/templates/views/class.html @@ -27,7 +27,7 @@ Join Class
- + Create Project
diff --git a/templates/views/project.html b/templates/views/project.html index 6b36e7f..9bfd82f 100644 --- a/templates/views/project.html +++ b/templates/views/project.html @@ -18,7 +18,7 @@
-
+
@@ -43,7 +43,7 @@
Team Members: