Merge pull request #80 from sagidayan/UI

- myClasses display -  (python work in progress)
This commit is contained in:
Sagi Dayan 2015-06-28 21:10:49 +03:00
commit 2a64f940af
8 changed files with 101 additions and 290 deletions

View file

@ -1,91 +0,0 @@
__author__ = 'etye'
import unittest
import requests
import json
from Testing.config import __CONFIG__
class CoursesTestPlan(unittest.TestCase):
@classmethod
def setUpClass(cls):
debug = __CONFIG__['DEBUG']
if debug:
url = __CONFIG__['PATHS']['DEBUG']
else:
url = __CONFIG__['PATHS']['PRODUCTION']
cls.url_ = url
request = requests.get(url+'api/qa/init')
if 200 <= request.status_code <= 299:
print 'Initialized'
def test_coursesCreate_Lecturer(self):
headers = {'content-type': 'application/json'}
url = 'http://se-hub.appspot.com/api/courses/create/_QA_TOKEN_TEST_LECTURER'
params = {'seToken': 'seToken' }
data = {
'courseName': 'QA COURSE',
'campusName': 'https://yt3.ggpht.com/--ZkWxybWGOM/AAAAAAAAAAI/AAAAAAAAAAA/_nAICC_kzzI/s88-c-k-no/photo.jpg',
'projects': '@gay.lord.ultima.multi.omega',
'startDate': {'year': 2015, 'month' : 4, 'day' : 3},
'endDate': {'year': 2016,'month' : 6,'day' : 6}
}
#r = requests.post(self.__class__.url_+'api/courses/create/'+__CONFIG__['TOKENS']['STUDENT'],data=payload)
r = requests.post(url, params=params, data=json.dumps(data), headers=headers)
'''
payload = {
'courseName': 'QA COURSE',
'campusName': 'https://yt3.ggpht.com/--ZkWxybWGOM/AAAAAAAAAAI/AAAAAAAAAAA/_nAICC_kzzI/s88-c-k-no/photo.jpg',
'projects': '@gay.lord.ultima.multi.omega',
'startDate': {'year': 2015, 'month' : 4, 'day' : 3},
'endDate': {'year': 2016,'month' : 6,'day' : 6}
}
'''
# r = requests.post(self.__class__.url_+'api/courses/create/'+__CONFIG__['TOKENS']['LECTURER'],data=payload)
#r = requests.post('http://localhost:8080/api/courses/create/_QA_TOKEN_TEST_LECTURER',data=payload)
#self.assertEquals(r.status_code, 201)
def test_coursesCreate_InvalidToken(self):
headers = {'content-type': 'application/json'}
url = self.__class__.url_+'api/courses/create/invalidToken'
data = {
'courseName': 'QA COURSE',
'campusName': 'https://yt3.ggpht.com/--ZkWxybWGOM/AAAAAAAAAAI/AAAAAAAAAAA/_nAICC_kzzI/s88-c-k-no/photo.jpg',
'projects': '@gay.lord.ultima.multi.omega',
'startDate': {'year': 2015, 'month' : 4, 'day' : 3},
'endDate': {'year': 2016,'month' : 6,'day' : 6}
}
params = {'seToken': 'seToken' }
r = requests.post(url, params=params, data=json.dumps(data), headers=headers)
self.assertEquals(r.status_code, 403)
'''
payload = {'courseName': 'Advance Math', 'campusName': 'JCE', 'startDate':'2015-14-3','endDate': '2015-29-6','taskFlag': 'False'}
payload = {
'courseName': 'QA COURSE',
'campusName': 'https://yt3.ggpht.com/--ZkWxybWGOM/AAAAAAAAAAI/AAAAAAAAAAA/_nAICC_kzzI/s88-c-k-no/photo.jpg',
'projects': '@gay.lord.ultima.multi.omega',
'startDate': {'year': 2015, 'month' : 4, 'day' : 3},
'endDate': {'year': 2016,'month' : 6,'day' : 6}
}
r = requests.post(self.__class__.url_+'api/courses/create/invalidToken',data=payload)
'''
def test_coursesCreate_Student(self):
headers = {'content-type': 'application/json'}
url = self.__class__.url_+'api/courses/create/_QA_TOKEN_TEST_STUDENT'
params = {'seToken': 'seToken' }
data = {
'courseName': 'QA COURSE',
'campusName': 'https://yt3.ggpht.com/--ZkWxybWGOM/AAAAAAAAAAI/AAAAAAAAAAA/_nAICC_kzzI/s88-c-k-no/photo.jpg',
'projects': '@gay.lord.ultima.multi.omega',
'startDate': {'year': 2015, 'month' : 4, 'day' : 3},
'endDate': {'year': 2016,'month' : 6,'day' : 6}
}
#r = requests.post(self.__class__.url_+'api/courses/create/'+__CONFIG__['TOKENS']['STUDENT'],data=payload)
r = requests.post(url, params=params, data=json.dumps(data), headers=headers)
self.assertEquals(r.status_code, 403, 'message: ' + r.json()['message'])
def test_getCourseByCampusName(self):
r = requests.get(self.__class__.url_+'api/courses/getCourseByCampusName/'+__CONFIG__['TOKENS']['CAMPUS_NAME'])
self.assertEquals(r.status_code, 200)
if __name__ == '__main__':
unittest.main()

View file

@ -1,97 +0,0 @@
__author__ = 'etye'
import unittest
import requests
import json
from Testing.config import __CONFIG__
class UserTestPlan(unittest.TestCase):
@classmethod
def setUpClass(cls):
debug = __CONFIG__['DEBUG']
if debug:
url = __CONFIG__['PATHS']['DEBUG']
else:
url = __CONFIG__['PATHS']['PRODUCTION']
cls.url_ = url
request = requests.get(url+'api/qa/init')
if 200 <= request.status_code <= 299:
print 'Initialized'
def test_courseCreate_lecturer(self):
#url = "http://localhost:8080/api/courses/create/_QA_TOKEN_TEST_LECTURER"
url=self.__class__.url_+'api/courses/create/'+__CONFIG__['TOKENS']['LECTURER']
data = {
'courseName': 'matan',
'campusName': 'https://yt3.ggpht.com/--ZkWxybWGOM/AAAAAAAAAAI/AAAAAAAAAAA/_nAICC_kzzI/s88-c-k-no/photo.jpg',
'projects': '@gay.lord.ultima.multi.omega',
'startDate': {'year': 2015, 'month' : 4, 'day' : 3},
'endDate': {'year': 2016,'month' : 6,'day' : 6}
}
headers = {'Content-type': 'application/json', 'Accept': 'text/plain'}
r = requests.post(url, data=json.dumps(data), headers=headers)
self.assertEquals(r.status_code, 201)
def test_courseCreate_lecturerExsistingCourse(self):
#url = "http://localhost:8080/api/courses/create/_QA_TOKEN_TEST_LECTURER"
url=self.__class__.url_+'api/courses/create/'+__CONFIG__['TOKENS']['LECTURER']
data = {
'courseName': 'matan',
'campusName': 'https://yt3.ggpht.com/--ZkWxybWGOM/AAAAAAAAAAI/AAAAAAAAAAA/_nAICC_kzzI/s88-c-k-no/photo.jpg',
'projects': '@gay.lord.ultima.multi.omega',
'startDate': {'year': 2015, 'month' : 4, 'day' : 3},
'endDate': {'year': 2016,'month' : 6,'day' : 6}
}
headers = {'Content-type': 'application/json', 'Accept': 'text/plain'}
r = requests.post(url, data=json.dumps(data), headers=headers)
self.assertEquals(r.status_code, 403)
def test_courseCreate_student(self):
#url = "http://localhost:8080/api/courses/create/_QA_TOKEN_TEST_LECTURER"
url=self.__class__.url_+'api/courses/create/'+__CONFIG__['TOKENS']['STUDENT']
data = {
'courseName': 'matan',
'campusName': 'https://yt3.ggpht.com/--ZkWxybWGOM/AAAAAAAAAAI/AAAAAAAAAAA/_nAICC_kzzI/s88-c-k-no/photo.jpg',
'projects': '@gay.lord.ultima.multi.omega',
'startDate': {'year': 2015, 'month' : 4, 'day' : 3},
'endDate': {'year': 2016,'month' : 6,'day' : 6}
}
headers = {'Content-type': 'application/json', 'Accept': 'text/plain'}
r = requests.post(url, data=json.dumps(data), headers=headers)
self.assertEquals(r.status_code, 403)
def test_courseCreate_invalidToken(self):
#url = "http://localhost:8080/api/courses/create/_QA_TOKEN_TEST_LECTURER"
url=self.__class__.url_+'api/courses/create/invalidToken'
data = {
'courseName': 'matan',
'campusName': 'https://yt3.ggpht.com/--ZkWxybWGOM/AAAAAAAAAAI/AAAAAAAAAAA/_nAICC_kzzI/s88-c-k-no/photo.jpg',
'projects': '@gay.lord.ultima.multi.omega',
'startDate': {'year': 2015, 'month' : 4, 'day' : 3},
'endDate': {'year': 2016,'month' : 6,'day' : 6}
}
headers = {'Content-type': 'application/json', 'Accept': 'text/plain'}
r = requests.post(url, data=json.dumps(data), headers=headers)
self.assertEquals(r.status_code, 403)
def test_courseCreate_hebrewToken(self):
#url = "http://localhost:8080/api/courses/create/_QA_TOKEN_TEST_LECTURER"
url=self.__class__.url_+'api/courses/create/????'
data = {
'courseName': 'matan',
'campusName': 'https://yt3.ggpht.com/--ZkWxybWGOM/AAAAAAAAAAI/AAAAAAAAAAA/_nAICC_kzzI/s88-c-k-no/photo.jpg',
'projects': '@gay.lord.ultima.multi.omega',
'startDate': {'year': 2015, 'month' : 4, 'day' : 3},
'endDate': {'year': 2016,'month' : 6,'day' : 6}
}
headers = {'Content-type': 'application/json', 'Accept': 'text/plain'}
r = requests.post(url, data=json.dumps(data), headers=headers)
self.assertEquals(r.status_code, 404)
#/api/courses/getCourseByCampusName/<string:name>
def test_getCourseByCampusName_EXSISTING_CAMPUS(self):
url=self.__class__.url_+'api/courses/getCourseByCampusName/'+__CONFIG__['CAMPUS_NAME']['JCE']
r = requests.get(url)
self.assertEquals(r.status_code, 200)
if __name__ == '__main__':
unittest.main()

View file

@ -1,7 +1,6 @@
angular.module('SeHub')
.controller('campusesController', ['$scope', '$cookies', '$cookieStore', '$window', '$location', '$mdToast', '$mdDialog', 'apiService', '$rootScope', function($scope, $cookies, $cookieStore, $window, $location, $mdToast, $mdDialog, apiService, $rootScope)
{
$scope.threeSizedArray =[];
$scope.campusesEmpty = false;
var token = $cookies['com.sehub.www'];
@ -23,9 +22,7 @@ angular.module('SeHub')
}
}
};
$scope.threeSizedArray.push(tempArr);
console.log($scope.threeSizedArray); // TODO REMOVE
}
$scope.goToCampus = function(campusId) // Will pass you to courses by specific campus
@ -45,7 +42,9 @@ angular.module('SeHub')
{
// TODO
});
if($scope.campuses != null)
// console.log($scope.campuses.length.toString());
if(!$scope.campuses) // If campuses is empty
{
$scope.campusesEmpty = true;
}

View file

@ -95,8 +95,6 @@ angular.module('SeHub')
console.log("choose project Clicked!!");
}
// animation
$scope.isEnterd = top.setIsEnterd;
}]);

View file

@ -14,23 +14,6 @@ angular.module('SeHub')
$scope.coursesEmpty = false;
var campusId = $routeParams.campusId;
var displayCourses = function()
{
apiService.getCoursesByUser(token, campusId).success(function(data) // Get all the courses for display
{
$scope.courses = data;
console.log("success " + $scope.courses);
init(); // Executing the function to initialize course display
}).error(function(err)
{
console.log("error: " + err);
});
if($scope.courses = null)
{
$scope.coursesEmpty = true;
}
}
$scope.goToClass = function(classId)
{
console.log("Done! " + $scope.courses);
@ -102,37 +85,42 @@ angular.module('SeHub')
var init = function()
{
var i, j, counter = 0;
var newLength = 0;
if(($scope.courses.length % 3) === 0)
{
newLength = ($scope.courses.length / 3);
$scope.holdArrays = [];
var tempArr = [];
var sizeOfSmallArrays = 3;
for (var i = 0 ; i < $scope.courses.length ; i++) {
if(i % sizeOfSmallArrays !== 0){
tempArr.push($scope.courses[i]);
}else{
if(i !== 0){
$scope.holdArrays.push(tempArr);
tempArr = [];
tempArr.push($scope.courses[i]);
}else{
tempArr.push($scope.courses[i]);
}
else
{
newLength = (Math.ceil($scope.courses.length / 3)); // Rounds number up
}
};
$scope.holdArrays.push(tempArr);
}
console.log("length: " + newLength);
$scope.holdArrays.length = newLength;
//$scope.courses = ["lala", "aaa", "bbb", "ccc", "rrr"];
for(j = 0; j < newLength; j++)
var displayCourses = function()
{
$scope.holdArrays[j] = [3]; // Creating array in size of 3 in each array cell
}
for(i = 0; i < newLength; i++)
apiService.getCourseByCampusName(token).success(function(data) // Shows all classes from this campus
{
for(j = 0; j < newLength; j++)
$scope.courses = data;
console.log("success " + $scope.courses);
init(); // Executing the function to initialize course display
if(!$scope.courses)
{
if($scope.courses[(3*i) + j] != null)
$scope.coursesEmpty = true;
}
}).error(function(err)
{
$scope.holdArrays[i][j] = $scope.courses[(3*i) + j];
}
}
}
console.log($scope.holdArrays);
console.log("error: " + err);
});
}

View file

@ -41,37 +41,23 @@ angular.module('SeHub')
var init = function()
{
var i, j, counter = 0;
var newLength = 0;
if(($scope.projects.length % 3) === 0)
{
newLength = ($scope.projects.length / 3);
}
else
{
newLength = (Math.ceil($scope.projects.length / 3)); // Rounds number up
}
console.log("length: " + newLength);
$scope.arrayHolder.length = newLength;
for(j = 0; j < newLength; j++)
{
$scope.arrayHolder[j] = [3]; // Creating array in size of 3 in each array cell
}
for(i = 0; i < newLength; i++)
{
for(j = 0; j < newLength; j++)
{
if($scope.projects[(3*i) + j] != null)
{
$scope.arrayHolder[i][j] = $scope.projects[(3*i) + j];
$scope.arrayHolder = [];
var tempArr = [];
var sizeOfSmallArrays = 3;
for (var i = 0 ; i < $scope.courses.length ; i++) {
if(i % sizeOfSmallArrays !== 0){
tempArr.push($scope.courses[i]);
}else{
if(i !== 0){
$scope.arrayHolder.push(tempArr);
tempArr = [];
tempArr.push($scope.courses[i]);
}else{
tempArr.push($scope.courses[i]);
}
}
}
console.log($scope.arrayHolder);
};
$scope.arrayHolder.push(tempArr);
}

View file

@ -4,7 +4,7 @@
</md-content>
<md-card class="cardAllCampuses">
<div ng-if = "!scope.campusesEmpty">
<div class = "allCampusesShow" flex = "99" layout = "row" ng-repeat = "t in threeSizedArray" value = "{{t}}" layout-padding>
<div flex = "99" layout = "row" ng-repeat = "t in threeSizedArray" value = "{{t}}" layout-padding>
<div flex = "32" layout = "column" ng-repeat = "campus in t" value = "{{campus}}" >
<div ng-if="t.length != 1">
<md-button ng-click = "goToCampus(campus.id)" style="width:100%; height:32%;" layout-padding class = "md-raised" >
@ -17,7 +17,6 @@
</md-card>
</md-button>
</div>
<div ng-if="t.length == 1">
<md-button ng-click = "goToCampus(campus.id)" style="width:32%; height:32%;" layout-padding class = "md-raised" >
<!-- <img src="{{campus.avatar_url}}" style = "width:14%; height:auto;"> -->
@ -33,9 +32,9 @@
</div>
</div>
</div>
<div ng-if = "scope.campusesEmpty">>
<md-card>
You Are Not Related To Any Course, You Can Join A Course By Press 'Join'.
<div ng-if = "scope.campusesEmpty">
<md-card layout-padding>
You Are Not Related To Any Campus, You May Join A Campus.
</md-card>
</div>
</md-card>

View file

@ -3,9 +3,39 @@
<h1 layout-margin style="margin-left:15px"><i class="fa fa-graduation-cap"></i> My Classes</h1>
</md-content>
<md-card class="cardAllcourses">
<div flex = "99" class = "allcoursesShow" layout = "row" ng-repeat = "t in holdArrays" value = "{{t}}">
<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 ng-if = "scope.coursesEmpty">
<div ng-if="t.length != 1">
<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-content>
<h2 class="md-title">{{course.title}}</h2> <!-- Should Be "course.title" -->
</md-card-content>
</md-2card>
</md-button>
</div>
<div ng-if="t.length == 1">
<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-content>
<h2 class="md-title">{{course.title}}</h2> <!-- Should Be "course.title" -->
</md-card-content>
</md-card>
</md-button>
</div>
</div>
<div class="spacer"></div>
<div ng-if = "!scope.coursesEmpty">
You Are Not Related To Any Course, You May Join Any Course You Wish.
</div>
</div>
</div>
<!-- <div flex = "99" class = "allcoursesShow" layout = "row" ng-repeat = "t in holdArrays" value = "{{t}}">
<div flex ="32" layout = "column" ng-repeat = "course in t" value = "{{course}}" layout-padding>
<div ng-of = "!scope.coursesEmpty">
<div ng-if = "!scope.coursesEmpty">
<md-card ng-click = "goToClass(course.id)" style="width:32%; height:32%;" layout-padding class = "campusCard">
{{course.id}}
</md-card>
@ -14,9 +44,8 @@
You Are Not Related To Any Course, You May Join Any Course You Wish.
</div>
</div>
</div>
</div> -->
</md-card>
<!-- <md-button ng-click="joinCourseClicked()" ng class="md-raised md-primary">Join Class</md-button> -->
<div ng-if="user.isLecturer"> <!-- Lecturer Mode -->
<div layout="row">
<div layout-margin layout-padding>