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>
403 - Invalid Token<br>
500 - Server Error
"""
if is_user_token_valid(token):
arr = []
query = Campus.all()

View file

@ -31,20 +31,30 @@ auto = Autodoc()
@auto.doc()
def create_course(token):
"""
This call will create a new campus in the DB
:param token: user seToken
Payload
{
'courseName': self.courseName,
'campusName': self.campusName,
'projects': self.projects
'startDate': self.startDate
'endDate': self.endDate
'taskFlag': self.taskFlag
}
:return:
code 200
<span class="card-title">This call will create a new course in the DB</span>
<br>
<b>Route Parameters</b><br>
- seToken: 'seToken'
<br>
<br>
<b>Payload</b><br>
- JSON Object, Example: <br>
{<br>
'courseName': 'Advance Math',<br>
'campusName': 'JCE',<br>
'startDate': '2015-14-3'<br>
'endDate': '2015-29-6'<br>
'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:
return bad_request()
@ -64,6 +74,9 @@ def create_course(token):
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'])
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'],
startDate=start_date, endDate=end_date)
@ -76,12 +89,6 @@ def create_course(token):
except Exception as e:
print e
#check if and projects needs to be added
# try:
# course.projects=payload['projects']
# except Exception:
# pass
except Exception:
return bad_request()
@ -99,11 +106,11 @@ def create_course(token):
@course_routes.route('/api/courses/getCourseByCampusName/<string:name>', methods=["GET"])
@auto.doc()
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>
<b>Route Parameters</b><br>
- validation_token: 'seToken|email_suffix'
- name: 'campus name'
<br>
<br>
<b>Payload</b><br>
@ -115,21 +122,15 @@ def getCourseByCampusName(name):
200 - JSON Example:<br>
<code>
{<br>
'username' : 'github_username',<br>
'name' : 'Bob Dylan',<br>
'email' : 'email@domain.com',<br>
'isLecturer' : true,<br>
'seToken' : 'dds2d-sfvvsf-qqq-fdf33-sfaa',<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>
'courseName': 'Advance Math',<br>
'campusName': 'JCE',<br>
'startDate': '2015-14-3'<br>
'endDate': '2015-29-6'<br>
'taskFlag': 'False'<br>
}
</code>
<br>
403 - Invalid Token
'''
"""
arr = []
query = Course.all()
query.filter("campusName = ", name)

View file

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