added a missing parameter (master_id) that made function not usable
This commit is contained in:
parent
2ebd7392e4
commit
d428da5df0
1 changed files with 5 additions and 5 deletions
|
@ -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()
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue