added documentation

This commit is contained in:
Aran Zaiger 2015-06-15 18:58:03 +03:00
parent 1d9cbbfa6b
commit 7f1b912b36
3 changed files with 53 additions and 55 deletions

View file

@ -119,9 +119,7 @@ def get_campuses(token):
]<br> ]<br>
<br> <br>
403 - Invalid Token<br> 403 - Invalid Token<br>
500 - Server Error
""" """
if is_user_token_valid(token): if is_user_token_valid(token):
arr = [] arr = []
query = Campus.all() query = Campus.all()

View file

@ -31,20 +31,30 @@ auto = Autodoc()
@auto.doc() @auto.doc()
def create_course(token): def create_course(token):
""" """
This call will create a new campus in the DB <span class="card-title">This call will create a new course in the DB</span>
:param token: user seToken <br>
Payload <b>Route Parameters</b><br>
{ - seToken: 'seToken'
'courseName': self.courseName, <br>
'campusName': self.campusName, <br>
'projects': self.projects <b>Payload</b><br>
'startDate': self.startDate - JSON Object, Example: <br>
'endDate': self.endDate {<br>
'taskFlag': self.taskFlag 'courseName': 'Advance Math',<br>
} 'campusName': 'JCE',<br>
'startDate': '2015-14-3'<br>
:return: 'endDate': '2015-29-6'<br>
code 200 'taskFlag': 'False'<br>
}<br>
<br>
<br>
<b>Response</b>
<br>
201 - Created
<br>
400 - Bad Request
<br>
403 - Invalid token or not a lecturer
""" """
if not request.data: if not request.data:
return bad_request() return bad_request()
@ -64,6 +74,9 @@ def create_course(token):
start_date = datetime.date(payload['startDate']['year'],payload['startDate']['month'],payload['startDate']['day']) start_date = datetime.date(payload['startDate']['year'],payload['startDate']['month'],payload['startDate']['day'])
end_date = datetime.date(payload['endDate']['year'],payload['endDate']['month'],payload['endDate']['day']) end_date = datetime.date(payload['endDate']['year'],payload['endDate']['month'],payload['endDate']['day'])
if end_date <= 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'],
startDate=start_date, endDate=end_date) startDate=start_date, endDate=end_date)
@ -76,12 +89,6 @@ def create_course(token):
except Exception as e: except Exception as e:
print e print e
#check if and projects needs to be added
# try:
# course.projects=payload['projects']
# except Exception:
# pass
except Exception: except Exception:
return bad_request() return bad_request()
@ -99,11 +106,11 @@ def create_course(token):
@course_routes.route('/api/courses/getCourseByCampusName/<string:name>', methods=["GET"]) @course_routes.route('/api/courses/getCourseByCampusName/<string:name>', methods=["GET"])
@auto.doc() @auto.doc()
def getCourseByCampusName(name): def getCourseByCampusName(name):
''' """
<span class="card-title">This Function is will Activate a user and add tha campus to it</span> <span class="card-title">>This Call will return an array of all courses in a given campus</span>
<br> <br>
<b>Route Parameters</b><br> <b>Route Parameters</b><br>
- validation_token: 'seToken|email_suffix' - name: 'campus name'
<br> <br>
<br> <br>
<b>Payload</b><br> <b>Payload</b><br>
@ -115,21 +122,15 @@ def getCourseByCampusName(name):
200 - JSON Example:<br> 200 - JSON Example:<br>
<code> <code>
{<br> {<br>
'username' : 'github_username',<br> 'courseName': 'Advance Math',<br>
'name' : 'Bob Dylan',<br> 'campusName': 'JCE',<br>
'email' : 'email@domain.com',<br> 'startDate': '2015-14-3'<br>
'isLecturer' : true,<br> 'endDate': '2015-29-6'<br>
'seToken' : 'dds2d-sfvvsf-qqq-fdf33-sfaa',<br> 'taskFlag': 'False'<br>
'avatar_url' : 'http://location.domain.com/image.jpg',<br>
'isFirstLogin' : false,<br>
'campuses_id_list': ['22314','243512',...,'356'],<br>
'classes_id_list': ['22314','243512',...,'356']<br>
} }
</code> </code>
<br> <br>
403 - Invalid Token """
'''
arr = [] arr = []
query = Course.all() query = Course.all()
query.filter("campusName = ", name) query.filter("campusName = ", name)

View file

@ -39,9 +39,10 @@ def create_project(token):
<b>Payload</b><br> <b>Payload</b><br>
- JSON Object, Example: <br> - JSON Object, Example: <br>
{<br> {<br>
'title': 'Campus name',<br> 'projectName': 'Advance Math',<br>
'email_ending': '@campus.ac.com',<br> 'courseName': 'JCE',<br>
'avatar_url': 'http://location.domain.com/image.jpg'<br> 'logo_url': 'http://location.domain.com/image.jpg'<br>
'gitRepository': 'http://location.git.com/somthing'<br>
}<br> }<br>
<br> <br>
<br> <br>
@ -49,7 +50,9 @@ def create_project(token):
<br> <br>
201 - Created 201 - Created
<br> <br>
403 - Invalid Token/Forbidden 400 - Bad Request
<br>
403 - Invalid token or not a lecturer
""" """
if not request.data: if not request.data:
return bad_request() return bad_request()
@ -80,11 +83,11 @@ def create_project(token):
@project_routes.route('/api/projects/getProjectsByCourseName/<string:name>', methods=["GET"]) @project_routes.route('/api/projects/getProjectsByCourseName/<string:name>', methods=["GET"])
@auto.doc() @auto.doc()
def getProjectsByCourseName(name): def getProjectsByCourseName(name):
''' """
<span class="card-title">This Function is will Activate a user and add tha campus to it</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>
- validation_token: 'seToken|email_suffix' - name: 'course name'
<br> <br>
<br> <br>
<b>Payload</b><br> <b>Payload</b><br>
@ -96,20 +99,16 @@ def getProjectsByCourseName(name):
200 - JSON Example:<br> 200 - JSON Example:<br>
<code> <code>
{<br> {<br>
'username' : 'github_username',<br> 'projectName': 'Advance Math',<br>
'name' : 'Bob Dylan',<br> 'courseName': 'JCE',<br>
'email' : 'email@domain.com',<br> 'grade': 98,<br>
'isLecturer' : true,<br> 'logo_url': 'http://location.domain.com/image.jpg',<br>
'seToken' : 'dds2d-sfvvsf-qqq-fdf33-sfaa',<br> 'gitRepository': 'http://location.git.com/somthing',<br>
'avatar_url' : 'http://location.domain.com/image.jpg',<br> 'membersId': ['bob', 'dylan', 'quentin', 'terentino']<br>
'isFirstLogin' : false,<br>
'campuses_id_list': ['22314','243512',...,'356'],<br>
'classes_id_list': ['22314','243512',...,'356']<br>
} }
</code> </code>
<br> <br>
403 - Invalid Token """
'''
arr = [] arr = []
query = Project.all() query = Project.all()