This repository has been archived on 2021-09-15. You can view files and clone it, but cannot push or open issues or pull requests.
2017-01-26 16:16:23 +00:00
|
|
|
from flask import session
|
|
|
|
from flask_restful import Resource
|
2017-03-31 10:35:29 +00:00
|
|
|
|
2017-03-30 22:19:02 +00:00
|
|
|
from app.model import LIVRET, TUTORSHIP, and_
|
2017-03-28 15:57:51 +00:00
|
|
|
|
2017-01-26 16:16:23 +00:00
|
|
|
|
|
|
|
class UserInfoAPI(Resource):
|
|
|
|
"""
|
|
|
|
UserInfo Api Resource
|
|
|
|
"""
|
|
|
|
|
|
|
|
def get(self):
|
2017-03-28 15:57:51 +00:00
|
|
|
user = session.get("user", None)
|
2017-01-26 16:16:23 +00:00
|
|
|
return {'USER': user}, 200
|
2017-03-28 15:57:51 +00:00
|
|
|
|
|
|
|
|
|
|
|
class UserGroupsAPI(Resource):
|
|
|
|
"""
|
|
|
|
UserGroups Api Resource
|
|
|
|
"""
|
|
|
|
def get(self):
|
|
|
|
user = session.get("user", None)
|
|
|
|
if user is not None:
|
|
|
|
subquery = LIVRET.select().distinct().with_only_columns([LIVRET.c.tutorship_id])
|
|
|
|
query = TUTORSHIP.select(
|
|
|
|
and_(TUTORSHIP.c.student_id == user["id"], TUTORSHIP.c.id.notin_(subquery))).distinct()
|
|
|
|
res = query.execute()
|
|
|
|
liste = []
|
|
|
|
for r in res:
|
|
|
|
liste.append(r.group_id)
|
|
|
|
|
|
|
|
return {'GROUP_LIST': liste}, 200
|