getProjectsByCourseName function fix
This commit is contained in:
parent
991d6a73bc
commit
1d9cbbfa6b
1 changed files with 40 additions and 47 deletions
|
@ -26,9 +26,9 @@ from SE_API.Respones_Utils import *
|
||||||
project_routes = Blueprint("project_routes", __name__)
|
project_routes = Blueprint("project_routes", __name__)
|
||||||
auto = Autodoc()
|
auto = Autodoc()
|
||||||
|
|
||||||
@project_routes.route('/api/projects/Create/<string:token>/<string:id>', methods=['POST'])
|
@project_routes.route('/api/projects/create/<string:token>', methods=['POST'])
|
||||||
@auto.doc()
|
@auto.doc()
|
||||||
def create_project(token,id):
|
def create_project(token):
|
||||||
"""
|
"""
|
||||||
<span class="card-title">This call will create a new project in the DB</span>
|
<span class="card-title">This call will create a new project in the DB</span>
|
||||||
<br>
|
<br>
|
||||||
|
@ -62,7 +62,7 @@ def create_project(token,id):
|
||||||
#todo: check legality
|
#todo: check legality
|
||||||
|
|
||||||
try:
|
try:
|
||||||
project = Project(projectName=payload['projectName'], masterId=user.key().id(), gitRepository=payload['gitRepository'], membersId=[token])
|
project = Project(projectName=payload['projectName'], courseName=payload['courseName'], masterId=user.key().id(), gitRepository=payload['gitRepository'], membersId=[token])
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print e
|
print e
|
||||||
return bad_request()
|
return bad_request()
|
||||||
|
@ -77,62 +77,55 @@ def create_project(token,id):
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@project_routes.route('/api/projects/getAll/<string:token>', methods=['GET'])
|
@project_routes.route('/api/projects/getProjectsByCourseName/<string:name>', methods=["GET"])
|
||||||
@auto.doc()
|
@auto.doc()
|
||||||
def get_projects(token):
|
def getProjectsByCourseName(name):
|
||||||
"""
|
'''
|
||||||
<span class="card-title">This Call will return an array of all projects available</span>
|
<span class="card-title">This Function is will Activate a user and add tha campus to it</span>
|
||||||
<br>
|
<br>
|
||||||
<b>Route Parameters</b><br>
|
<b>Route Parameters</b><br>
|
||||||
- seToken: 'seToken'
|
- validation_token: 'seToken|email_suffix'
|
||||||
<br>
|
<br>
|
||||||
<br>
|
<br>
|
||||||
<b>Payload</b><br>
|
<b>Payload</b><br>
|
||||||
- NONE <br>
|
- NONE
|
||||||
<br>
|
<br>
|
||||||
<br>
|
<br>
|
||||||
<b>Response</b>
|
<b>Response</b>
|
||||||
<br>
|
<br>
|
||||||
200 - JSON Array, Example:<br>
|
200 - JSON Example:<br>
|
||||||
[<br>
|
<code>
|
||||||
{
|
{<br>
|
||||||
'title': 'JCE',<br>
|
'username' : 'github_username',<br>
|
||||||
'email_ending': '@post.jce.ac.il',<br>
|
'name' : 'Bob Dylan',<br>
|
||||||
'master_user_id': 123453433341, (User that created the campus)<br>
|
'email' : 'email@domain.com',<br>
|
||||||
'avatar_url': 'http://some.domain.com/imagefile.jpg'<br>
|
'isLecturer' : true,<br>
|
||||||
},<br>
|
'seToken' : 'dds2d-sfvvsf-qqq-fdf33-sfaa',<br>
|
||||||
....<br>
|
'avatar_url' : 'http://location.domain.com/image.jpg',<br>
|
||||||
{<br>
|
'isFirstLogin' : false,<br>
|
||||||
...<br>
|
'campuses_id_list': ['22314','243512',...,'356'],<br>
|
||||||
}req<br>
|
'classes_id_list': ['22314','243512',...,'356']<br>
|
||||||
]<br>
|
}
|
||||||
|
</code>
|
||||||
<br>
|
<br>
|
||||||
403 - Invalid Token<br>
|
403 - Invalid Token
|
||||||
500 - Server Error
|
'''
|
||||||
"""
|
|
||||||
if is_user_token_valid(token):
|
arr = []
|
||||||
arr = []
|
query = Project.all()
|
||||||
query = Campus.all()
|
query.filter("courseName = ", name)
|
||||||
for c in query.run():
|
|
||||||
arr.append(dict(json.loads(c.to_JSON())))
|
for p in query.run():
|
||||||
print arr
|
arr.append(dict(json.loads(p.to_JSON())))
|
||||||
if len(arr) != 0:
|
print arr
|
||||||
return Response(response=json.dumps(arr),
|
if len(arr) != 0:
|
||||||
status=200,
|
return Response(response=json.dumps(arr),
|
||||||
mimetype="application/json")
|
status=200,
|
||||||
else:
|
mimetype="application/json")
|
||||||
return Response(response=[],
|
|
||||||
status=200,
|
|
||||||
mimetype="application/json")
|
|
||||||
else:
|
else:
|
||||||
return forbidden("Invalid Token")
|
return Response(response=[],
|
||||||
|
status=200,
|
||||||
|
mimetype="application/json")
|
||||||
|
|
||||||
@project_routes.route('/api/Projects/<string:token>', methods=['GET'])
|
|
||||||
@auto.doc()
|
|
||||||
def get_campuses(token):
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue