Merge branch 'master' of https://github.com/sagidayan/SE-Hub into UI

This commit is contained in:
Matan Bar Yosef 2015-06-16 23:32:31 +03:00
commit 434572fce7
6 changed files with 59 additions and 40 deletions

View file

@ -57,7 +57,7 @@ def create_course(token):
403 - Invalid token or not a lecturer 403 - Invalid token or not a lecturer
""" """
if not request.data: if not request.data:
return bad_request() return bad_request("no data")
if not is_lecturer(token): #todo: change to lecturer id if not is_lecturer(token): #todo: change to lecturer id
return forbidden("Invalid token or not a lecturer!") return forbidden("Invalid token or not a lecturer!")
@ -77,20 +77,20 @@ def create_course(token):
if end_date <= start_date: if end_date <= start_date:
return bad_request("end date cant be before (or same day) start date") return bad_request("end date cant be before (or same day) start date")
course = Course(courseName=payload['courseName'], campusName=payload['campusName'], course = Course(courseName=payload['courseName'], campusName=payload['campusName'], master_id=user.key().id(),
startDate=start_date, endDate=end_date) startDate=start_date, endDate=end_date)
#check if name already exists #check if name already exists
try: try:
query = Course.all() query = Course.all()
query.filter("courseName = ", payload['courseName']) query.filter("courseName = ", payload['courseName'])
for c in query.run(limit=1): for c in query.run(limit=1):
return forbidden("Campus with same name already exists") return forbidden("Course with same name already exists")
except Exception as e: except Exception as e:
print e print e
except Exception: except Exception as e:
print e
return bad_request() return bad_request()

View file

@ -60,14 +60,14 @@ def getUserByToken(token):
403 - No User Found 403 - No User Found
""" """
query = User.all() query = User.all()
query.filter("seToken = ", token) query.filter("seToken =", token)
for u in query.run(limit=5): for u in query.run(limit=5):
return Response(response=u.to_JSON(), return Response(response=u.to_JSON(),
status=200, status=200,
mimetype="application/json") # Real response! mimetype="application/json") # Real response!
return bad_request("No User Found") return no_content("No User Found")
@user_routes.route('/api/users/updateUser/<string:token>', methods=["POST"]) @user_routes.route('/api/users/updateUser/<string:token>', methods=["POST"])
@ -83,8 +83,9 @@ def updateUser(token):
<b>Payload</b><br> <b>Payload</b><br>
- JSON Object, Example: <br> - JSON Object, Example: <br>
{<br> {<br>
'name': 'Campus name',<br> 'name': 'new name',<br>
'isLecturer': '@campus.ac.com',<br> 'isLecturer': true,<br>
'campusName': 'JCE'<br>
}<br> }<br>
<br> <br>
<b>Response</b> <b>Response</b>
@ -100,23 +101,29 @@ def updateUser(token):
try: try:
payload = json.loads(request.data) payload = json.loads(request.data)
except Exception as e: except Exception as e:
return bad_request(e) return bad_request()
user = get_user_by_token(token) user = get_user_by_token(token)
if user is None: if user is None:
return bad_request("Not a user!") return bad_request("Not a user!")
try: try:
user.name = payload['user'] user.name = payload['name']
except Exception:
pass
try:
user.campusName = payload['campusName']
except Exception: except Exception:
pass pass
try: try:
user.isLecturer = payload['isLecturer'] user.isLecturer = payload['isLecturer']
except Exception: except Exception as e:
pass print e
db.put(user)
db.save
return ok("User updated") return ok("User updated")

View file

@ -12,6 +12,7 @@ class User(db.Model):
seToken = db.StringProperty(required=True) seToken = db.StringProperty(required=True)
avatar_url = db.StringProperty(required=True) avatar_url = db.StringProperty(required=True)
isFirstLogin = db.BooleanProperty(default=True) isFirstLogin = db.BooleanProperty(default=True)
campusName = db.StringProperty(required=True, default=" ")
campuses_id_list = db.StringListProperty(default=[]) campuses_id_list = db.StringListProperty(default=[])
classes_id_list = db.StringListProperty(default=[]) classes_id_list = db.StringListProperty(default=[])

View file

@ -214,8 +214,17 @@ body.noscroll
background-color: #E2E2E2; background-color: #E2E2E2;
font-weight: bold; font-weight: bold;
} }
.se-menu li .selected{
.se-menu li:active{
background-color: #B2B2B2;
text-shadow:#e0e0e0 1px 1px 0;
font-weight: bold;
}
.se-menu .selected{
background-color: #E2E2E2; background-color: #E2E2E2;
text-shadow:#e0e0e0 1px 1px 0;
font-weight: bold;
} }
.user-box{ .user-box{

View file

@ -40,37 +40,37 @@ angular.module('SeHub')
"title": "Home", "title": "Home",
"icon": "fa fa-home", "icon": "fa fa-home",
"style": "selected", "style": "selected",
"route": "/home" "route": "#/home"
}, { }, {
"title": "My Campuses", "title": "My Campuses",
"icon": "fa fa-university", "icon": "fa fa-university",
"style": "selected", "style": "",
"route": "/campuses" "route": "/campuses"
}, { }, {
"title": "My Classes", "title": "My Classes",
"icon": "fa fa-graduation-cap", "icon": "fa fa-graduation-cap",
"style": "selected", "style": "",
"route": "/campuses" "route": "/campuses"
}, { }, {
"title": "My Projects", "title": "My Projects",
"icon": "fa fa-cube", "icon": "fa fa-cube",
"style": "selected", "style": "",
"route": "/campuses" "route": "/campuses"
}, { }, {
"title": "Tasks", "title": "Tasks",
"icon": "fa fa-clipboard", "icon": "fa fa-clipboard",
"style": "selected", "style": "",
"route": "/campuses" "route": "/campuses"
}, { }, {
"title": "Settings", "title": "Settings",
"icon": "fa fa-cogs", "icon": "fa fa-cogs",
"style": "selected", "style": "",
"route": "/campuses" "route": "#/Settings"
}, { }, {
"title": "Log Out", "title": "Log Out",
"icon": "fa fa-power-off", "icon": "fa fa-power-off",
"style": "selected", "style": "",
"route": "/campuses" "route": "#/logout"
}]; }];
}]); }]);

View file

@ -25,26 +25,28 @@
<img ng-src="{{user.avatar_url}}" alt=""> <img ng-src="{{user.avatar_url}}" alt="">
</div> --> </div> -->
<md-content class="se-menu"> <md-content class="se-menu">
<div class="user-box" layout="row" layout-padding> <div ng-if="!isInRegisterMode">
<div flex="30"> <!-- Avatar --> <div class="user-box" layout="row" layout-padding>
<img ng-src="{{user.avatar_url}}" alt=""> <div flex="30"> <!-- Avatar -->
</div> <img ng-src="{{user.avatar_url}}" alt="">
<div class="user-data" layout="column" flex>
<div>
{{user.name}}
</div> </div>
<div> <div class="user-data" layout="column" flex>
{{user.email}} <div>
{{user.name}}
</div>
<div>
{{user.email}}
</div>
</div> </div>
</div> </div>
</div>
<ul> <ul>
<a ng-repeat="item in menuItems" href="#"> <a ng-repeat="item in menuItems" ng-href="{{item.route}}">
<li><i ng-class="item.icon"></i> {{item.title}}</li> <li ng-class="[item.style]"><i ng-class="item.icon"></i> {{item.title}}</li>
<md-divider ng-if="!$last"></md-divider> <md-divider ng-if="!$last"></md-divider>
</a> </a>
</ul> </ul>
</div>
<div ng-if="loadingData"> <div ng-if="loadingData">
<md-progress-circular></md-progress-circular> <md-progress-circular></md-progress-circular>
</div> </div>