Merge branch 'master' of github.com:sagidayan/SE-Hub
This commit is contained in:
commit
47bcfecb00
6 changed files with 102 additions and 26 deletions
|
@ -169,9 +169,9 @@ def joinCourse(token, courseId):
|
||||||
#----------------------------------------------------------
|
#----------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
@course_routes.route('/api/courses/getCoursesByCampus/<string:campusId>', methods=["GET"])
|
@course_routes.route('/api/courses/getAllCoursesByCampus/<string:token>/<string:campusId>', methods=["GET"])
|
||||||
@auto.doc()
|
@auto.doc()
|
||||||
def getCourseByCampus(campusId):
|
def getAllCoursesByCampus(token, campusId):
|
||||||
"""
|
"""
|
||||||
<span class="card-title">>This Call will return an array of all courses in a given campus</span>
|
<span class="card-title">>This Call will return an array of all courses in a given campus</span>
|
||||||
<br>
|
<br>
|
||||||
|
@ -199,6 +199,10 @@ def getCourseByCampus(campusId):
|
||||||
</code>
|
</code>
|
||||||
<br>
|
<br>
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
if get_user_by_token(token) is None:
|
||||||
|
return bad_request("Bad User Token")
|
||||||
|
|
||||||
arr = []
|
arr = []
|
||||||
query = Course.all()
|
query = Course.all()
|
||||||
query.filter("campusId = ", int(campusId))
|
query.filter("campusId = ", int(campusId))
|
||||||
|
@ -215,11 +219,11 @@ def getCourseByCampus(campusId):
|
||||||
status=200,
|
status=200,
|
||||||
mimetype="application/json")
|
mimetype="application/json")
|
||||||
|
|
||||||
@course_routes.route('/api/courses/getCoursesByUser/<string:token>/<string:campusId>', methods=['GET'])
|
@course_routes.route('/api/courses/getUserCoursesByCampus/<string:token>/<string:campusId>', methods=['GET'])
|
||||||
@auto.doc()
|
@auto.doc()
|
||||||
def getCampusesByUser(token, campusId):
|
def getUserCoursesByCampus(token, campusId):
|
||||||
"""
|
"""
|
||||||
<span class="card-title">This Call will return an array of all Campuses of a certain User</span>
|
<span class="card-title">This Call will return an array of all Courses of a certain User in a specific Campus</span>
|
||||||
<br>
|
<br>
|
||||||
<b>Route Parameters</b><br>
|
<b>Route Parameters</b><br>
|
||||||
- seToken: 'seToken'<br>
|
- seToken: 'seToken'<br>
|
||||||
|
@ -275,6 +279,63 @@ def getCampusesByUser(token, campusId):
|
||||||
mimetype="application/json")
|
mimetype="application/json")
|
||||||
|
|
||||||
|
|
||||||
|
@course_routes.route('/api/courses/getCoursesByUser/<string:token>/<string:userId>', methods=['GET'])
|
||||||
|
@auto.doc()
|
||||||
|
def getCoursesByUser(token, userId):
|
||||||
|
"""
|
||||||
|
<span class="card-title">This Call will return an array of all Courses of a certain User</span>
|
||||||
|
<br>
|
||||||
|
<b>Route Parameters</b><br>
|
||||||
|
- seToken: 'seToken'<br>
|
||||||
|
- userId: 1234354543<br>
|
||||||
|
<br>
|
||||||
|
<br>
|
||||||
|
<b>Payload</b><br>
|
||||||
|
- NONE <br>
|
||||||
|
<br>
|
||||||
|
<br>
|
||||||
|
<b>Response</b>
|
||||||
|
<br>
|
||||||
|
200 - JSON Array, Example:<br>
|
||||||
|
[<br>
|
||||||
|
{
|
||||||
|
'title': 'JCE',<br>
|
||||||
|
'email_ending': '@post.jce.ac.il',<br>
|
||||||
|
'master_user_id': 123453433341, (User that created the campus)<br>
|
||||||
|
'avatar_url': 'http://some.domain.com/imagefile.jpg',<br>
|
||||||
|
'id' : 1234567890<br>
|
||||||
|
},<br>
|
||||||
|
....<br>
|
||||||
|
{<br>
|
||||||
|
...<br>
|
||||||
|
}req<br>
|
||||||
|
]<br>
|
||||||
|
<br>
|
||||||
|
403 - Invalid Token<br>
|
||||||
|
"""
|
||||||
|
|
||||||
|
user = get_user_by_token(token)
|
||||||
|
if user is None:
|
||||||
|
return bad_request("Bad user Token")
|
||||||
|
|
||||||
|
otherUser = User.get_by_id(int(userId))
|
||||||
|
if otherUser is None:
|
||||||
|
return bad_request("Bad user Id")
|
||||||
|
|
||||||
|
arr = []
|
||||||
|
for i in otherUser.courses_id_list:
|
||||||
|
print i
|
||||||
|
course = Course.get_by_id(int(i))
|
||||||
|
arr.append(dict(json.loads(course.to_JSON())))
|
||||||
|
|
||||||
|
if len(arr) != 0:
|
||||||
|
return Response(response=json.dumps(arr),
|
||||||
|
status=200,
|
||||||
|
mimetype="application/json")
|
||||||
|
else:
|
||||||
|
return Response(response='[]',
|
||||||
|
status=200,
|
||||||
|
mimetype="application/json")
|
||||||
#----------------------------------------------------------
|
#----------------------------------------------------------
|
||||||
# PUT
|
# PUT
|
||||||
#----------------------------------------------------------
|
#----------------------------------------------------------
|
||||||
|
|
|
@ -140,13 +140,14 @@ def joinProject(token, projectId):
|
||||||
# GET
|
# GET
|
||||||
#----------------------------------------------------------
|
#----------------------------------------------------------
|
||||||
|
|
||||||
@project_routes.route('/api/projects/getProjectsByCourse/<string:courseId>', methods=["GET"])
|
@project_routes.route('/api/projects/getProjectsByCourse/<string:token>/<string:courseId>', methods=["GET"])
|
||||||
@auto.doc()
|
@auto.doc()
|
||||||
def getProjectsByCourse(courseId):
|
def getProjectsByCourse(token, courseId):
|
||||||
"""
|
"""
|
||||||
<span class="card-title">>This Call will return an array of all projects in a given course</span>
|
<span class="card-title">>This Call will return an array of all projects in a given course</span>
|
||||||
<br>
|
<br>
|
||||||
<b>Route Parameters</b><br>
|
<b>Route Parameters</b><br>
|
||||||
|
- seToken: token<br>
|
||||||
- courseId: 1234567890
|
- courseId: 1234567890
|
||||||
<br>
|
<br>
|
||||||
<br>
|
<br>
|
||||||
|
@ -171,6 +172,8 @@ def getProjectsByCourse(courseId):
|
||||||
<br>
|
<br>
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
if get_user_by_token(token) is None:
|
||||||
|
return bad_request("Bad User Token")
|
||||||
arr = []
|
arr = []
|
||||||
query = Project.all()
|
query = Project.all()
|
||||||
query.filter("courseId = ", int(courseId))
|
query.filter("courseId = ", int(courseId))
|
||||||
|
|
|
@ -12,6 +12,7 @@ angular.module('SeHub')
|
||||||
$scope.user.startDate = '';
|
$scope.user.startDate = '';
|
||||||
$scope.showMyClass = false;
|
$scope.showMyClass = false;
|
||||||
$scope.coursesEmpty = false;
|
$scope.coursesEmpty = false;
|
||||||
|
$scope.campusId;
|
||||||
var campusId = $routeParams.campusId;
|
var campusId = $routeParams.campusId;
|
||||||
|
|
||||||
$scope.goToClass = function(classId)
|
$scope.goToClass = function(classId)
|
||||||
|
@ -20,15 +21,16 @@ angular.module('SeHub')
|
||||||
$location.path('/projects/' + classId.toString()); // Will display all the projects in this course
|
$location.path('/projects/' + classId.toString()); // Will display all the projects in this course
|
||||||
}
|
}
|
||||||
|
|
||||||
$scope.chooseCourseClicked = function()
|
$scope.chooseCampusClicked = function()
|
||||||
{
|
{
|
||||||
$scope.isCourse = true;
|
$scope.isCourse = true;
|
||||||
console.log("choose course Clicked!!");
|
console.log("Choose campus Clicked!!");
|
||||||
|
|
||||||
apiService.getAllCampuses(token).success(function(data)
|
apiService.getAllCampuses(token).success(function(data)
|
||||||
{
|
{
|
||||||
$scope.campuses = data;
|
$scope.campuses = data;
|
||||||
console.log("Campuses: " + $scope.campuses.toString());
|
console.log("Campuses: ");
|
||||||
|
console.log($scope.campuses);
|
||||||
}).error(function(err)
|
}).error(function(err)
|
||||||
{
|
{
|
||||||
console.log("Error: " + err);
|
console.log("Error: " + err);
|
||||||
|
@ -42,12 +44,23 @@ angular.module('SeHub')
|
||||||
|
|
||||||
$scope.submitNewClassClicked = function()
|
$scope.submitNewClassClicked = function()
|
||||||
{
|
{
|
||||||
|
var i;
|
||||||
if($scope.course.courseName != null && $scope.course.endDate != null && $scope.course.startDate != null)
|
if($scope.course.courseName != null && $scope.course.endDate != null && $scope.course.startDate != null)
|
||||||
{
|
{
|
||||||
|
for(i = 0; i < $scope.campuses.length; i++)
|
||||||
|
{
|
||||||
|
if($scope.course.campusName === $scope.campuses[i].title)
|
||||||
|
{
|
||||||
|
$scope.campusId = $scope.campuses[i].id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
console.log("NOW: ");
|
||||||
|
console.log($scope.campusId);
|
||||||
|
|
||||||
var jsonNewCourse =
|
var jsonNewCourse =
|
||||||
{
|
{
|
||||||
'courseName': $scope.course.courseName,
|
'courseName': $scope.course.courseName,
|
||||||
'campusName': $scope.course.campusName,
|
'campusId': $scope.campusId,
|
||||||
'startDate': {
|
'startDate': {
|
||||||
'year' : $scope.course.startDate.getFullYear(),
|
'year' : $scope.course.startDate.getFullYear(),
|
||||||
'day' : $scope.course.startDate.getDate(),
|
'day' : $scope.course.startDate.getDate(),
|
||||||
|
@ -108,7 +121,7 @@ angular.module('SeHub')
|
||||||
|
|
||||||
var displayCourses = function()
|
var displayCourses = function()
|
||||||
{
|
{
|
||||||
apiService.getCourseByCampusName(token).success(function(data) // Shows all classes from this campus
|
apiService.getAllCoursesByCampus(token, campusId).success(function(data) // Shows all classes from this campus
|
||||||
{
|
{
|
||||||
$scope.courses = data;
|
$scope.courses = data;
|
||||||
console.log("success " + $scope.courses);
|
console.log("success " + $scope.courses);
|
||||||
|
|
|
@ -43,8 +43,8 @@ service.factory('apiService', ['$http', function($http) {
|
||||||
};
|
};
|
||||||
return $http(req);
|
return $http(req);
|
||||||
},
|
},
|
||||||
getCourseByCampusName: function(token){
|
getAllCoursesByCampus: function(token, campusId){
|
||||||
var url = (DEBUG ? "http://localhost:8080" : "http://se-hub.appspot.com") + "/api/courses/getCourseByCampusName/" + token;
|
var url = (DEBUG ? "http://localhost:8080" : "http://se-hub.appspot.com") + "/api/courses/getAllCoursesByCampus/" + token + '/' + campusId;
|
||||||
req = {
|
req = {
|
||||||
method : "GET",
|
method : "GET",
|
||||||
url : url
|
url : url
|
||||||
|
|
|
@ -3,31 +3,30 @@
|
||||||
<h1 layout-margin style="margin-left:15px"><i class="fa fa-graduation-cap"></i> My Classes</h1>
|
<h1 layout-margin style="margin-left:15px"><i class="fa fa-graduation-cap"></i> My Classes</h1>
|
||||||
</md-content>
|
</md-content>
|
||||||
<md-card class="cardAllcourses">
|
<md-card class="cardAllcourses">
|
||||||
|
|
||||||
<div flex = "99" layout = "row" ng-repeat = "t in holdArrays" value = "{{t}}" layout-padding>
|
<div flex = "99" layout = "row" ng-repeat = "t in holdArrays" value = "{{t}}" layout-padding>
|
||||||
<div flex = "32" layout = "column" ng-repeat = "course in t" value = "{{course}}" >
|
<div flex = "32" layout = "column" ng-repeat = "course in t" value = "{{course}}" >
|
||||||
<div ng-if = "scope.coursesEmpty">
|
<div ng-if = "!scope.coursesEmpty">
|
||||||
<div ng-if="t.length != 1">
|
<div ng-if="t.length != 1">
|
||||||
<md-button ng-click = "goToClass(course.id)" style="width:100%; height:32%;" layout-padding class = "md-raised" >
|
<md-button ng-click = "goToClass(course.id)" style="width:100%; height:32%;" layout-padding class = "md-raised" >
|
||||||
<md-card style="width:97%;height:97%">
|
<md-card style="width:97%;height:97%">
|
||||||
<md-card-content>
|
<md-card-content>
|
||||||
<h2 class="md-title">{{course.title}}</h2> <!-- Should Be "course.title" -->
|
<h2 class="md-title">{{course.courseName}}</h2> <!-- Should Be "course.title" -->
|
||||||
</md-card-content>
|
</md-card-content>
|
||||||
</md-2card>
|
</md-card>
|
||||||
</md-button>
|
</md-button>
|
||||||
</div>
|
</div>
|
||||||
<div ng-if="t.length == 1">
|
<div ng-if="t.length == 1">
|
||||||
<md-button ng-click = "goToClass(course.id)" style="width:32%; height:32%;" layout-padding class = "md-raised" >
|
<md-button ng-click = "goToClass(course.id)" style="width:32%; height:32%;" layout-padding class = "md-raised" >
|
||||||
<md-card style="width:97%;height:97%">
|
<md-card style="width:97%;height:97%">
|
||||||
<md-card-content>
|
<md-card-content>
|
||||||
<h2 class="md-title">{{course.title}}</h2> <!-- Should Be "course.title" -->
|
<h2 class="md-title">{{course.courseName}}</h2> <!-- Should Be "course.title" -->
|
||||||
</md-card-content>
|
</md-card-content>
|
||||||
</md-card>
|
</md-card>
|
||||||
</md-button>
|
</md-button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="spacer"></div>
|
<div class="spacer"></div>
|
||||||
<div ng-if = "!scope.coursesEmpty">
|
<div ng-if = "scope.coursesEmpty">
|
||||||
You Are Not Related To Any Course, You May Join Any Course You Wish.
|
You Are Not Related To Any Course, You May Join Any Course You Wish.
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -57,7 +56,7 @@
|
||||||
<md-card layout-padding>
|
<md-card layout-padding>
|
||||||
<div layout layout-sm="column">
|
<div layout layout-sm="column">
|
||||||
<!-- <input ng-model="course.campusName" required> -->
|
<!-- <input ng-model="course.campusName" required> -->
|
||||||
<md-select placeholder = "Campus name" ng-model="course.campusName" ng-click = "chooseCourseClicked()" required>
|
<md-select placeholder = "Campus name" ng-model="course.campusName" ng-click = "chooseCampusClicked()" required>
|
||||||
<md-option ng-repeat="c in campuses" value="{{c.title}}">
|
<md-option ng-repeat="c in campuses" value="{{c.title}}">
|
||||||
{{c.title}}
|
{{c.title}}
|
||||||
</md-option>
|
</md-option>
|
||||||
|
@ -84,11 +83,11 @@
|
||||||
</div>
|
</div>
|
||||||
</md-content>
|
</md-content>
|
||||||
</div>
|
</div>
|
||||||
<div layout-margin layout-padding ng-if="showMyClass">
|
<!-- <div layout-margin layout-padding ng-if="showMyClass">
|
||||||
<md-select placeholder="Choose Existing Course" ng-model="course" ng-click="chooseCourseClicked()" class="courseDropDown">
|
<md-select placeholder="Choose Existing Course" ng-model="course" ng-click="chooseCourseClicked()" class="courseDropDown">
|
||||||
<md-option ng-repeat="c in courses" value="{{c.course}}">{{c.course}}</md-option>
|
<md-option ng-repeat="c in courses" value="{{c.course}}">{{c.course}}</md-option>
|
||||||
</md-select>
|
</md-select>
|
||||||
</div>
|
</div> -->
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div ng-if="isStudent"> <!-- Student Mode -->
|
<div ng-if="isStudent"> <!-- Student Mode -->
|
||||||
|
|
Loading…
Reference in a new issue