TG-124 : UserGroupsAPI
This commit is contained in:
parent
1bd2369f9a
commit
7a9f64c529
@ -26,7 +26,7 @@ UserAPI (api/user)
|
|||||||
POST -> Create a user if it not already exists
|
POST -> Create a user if it not already exists
|
||||||
In:
|
In:
|
||||||
email = Email and login of the user (must be unique)
|
email = Email and login of the user (must be unique)
|
||||||
role = Role of the user (can be concatenated with -) 1=secrétaire, 2=resp_formation, 3=tuteur_univ, 4=étudiant
|
role = Role of the user (can be concatenated with -) 1=secrétaire, 2=resp_formation, 3=tuteur_univ, 4=étudiant, 5=tuteur_ent
|
||||||
Out:
|
Out:
|
||||||
200 -> UID = <USER_ID> : The user already exists with the id USER_ID
|
200 -> UID = <USER_ID> : The user already exists with the id USER_ID
|
||||||
201 -> UID = <USER_ID> : The user has been successfully created with the id USER_ID
|
201 -> UID = <USER_ID> : The user has been successfully created with the id USER_ID
|
||||||
@ -34,7 +34,7 @@ POST -> Create a user if it not already exists
|
|||||||
|
|
||||||
PUT -> Modify an existing user
|
PUT -> Modify an existing user
|
||||||
In: (Suffix = /byuid/<USER_ID>)
|
In: (Suffix = /byuid/<USER_ID>)
|
||||||
role = Role of the user (can be concatenated with -) 1=secrétaire, 2=resp_formation, 3=tuteur_univ, 4=étudiant
|
role = Role of the user (can be concatenated with -) 1=secrétaire, 2=resp_formation, 3=tuteur_univ, 4=étudiant, 5=tuteur_ent
|
||||||
phone = Phone number of the user (00.00.00.00.00)
|
phone = Phone number of the user (00.00.00.00.00)
|
||||||
email = Email of the user (must be unique)
|
email = Email of the user (must be unique)
|
||||||
Out:
|
Out:
|
||||||
|
@ -12,7 +12,7 @@ INSERT INTO `USER` VALUES (6, 'tut', '3', 'tut@univ-tlse2.fr', '01.23.45.67.89')
|
|||||||
INSERT INTO `GROUP` VALUES (1, 'M2_ICE_2016-2017_TEST', '2017', 'Master2 ICE', 'Master 2 Informatique Collaborative en Entreprise', 'Sciences du chômage proffessionnel', 5, 1, '/home/dan/PycharmProjects/OLA/backend/app/OLA_RESSOURCES/M2_ICE_2016-2017_TEST');
|
INSERT INTO `GROUP` VALUES (1, 'M2_ICE_2016-2017_TEST', '2017', 'Master2 ICE', 'Master 2 Informatique Collaborative en Entreprise', 'Sciences du chômage proffessionnel', 5, 1, '/home/dan/PycharmProjects/OLA/backend/app/OLA_RESSOURCES/M2_ICE_2016-2017_TEST');
|
||||||
INSERT INTO `GROUP` VALUES (2, 'M1_ICE_2016-2017_TEST', '2017', 'Master1 ICE', 'Master 1 Informatique Collaborative en Entreprise', 'Sciences du chômage proffessionnel', 5, 1, '/home/dan/PycharmProjects/OLA/backend/app/OLA_RESSOURCES/M1_ICE_2016-2017_TEST');
|
INSERT INTO `GROUP` VALUES (2, 'M1_ICE_2016-2017_TEST', '2017', 'Master1 ICE', 'Master 1 Informatique Collaborative en Entreprise', 'Sciences du chômage proffessionnel', 5, 1, '/home/dan/PycharmProjects/OLA/backend/app/OLA_RESSOURCES/M1_ICE_2016-2017_TEST');
|
||||||
|
|
||||||
INSERT INTO TUTORSHIP VALUES (DEFAULT, 1, 5, 2);
|
INSERT INTO TUTORSHIP VALUES (DEFAULT, 1, 2, 5);
|
||||||
INSERT INTO TUTORSHIP VALUES (DEFAULT, 2, 5, 4);
|
INSERT INTO TUTORSHIP VALUES (DEFAULT, 2, 4, 5);
|
||||||
INSERT INTO TUTORSHIP VALUES (DEFAULT, 1, 6, 3);
|
INSERT INTO TUTORSHIP VALUES (DEFAULT, 1, 3, 6);
|
||||||
|
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
from flask import session
|
from flask import session
|
||||||
from flask_restful import Resource
|
from flask_restful import Resource
|
||||||
|
|
||||||
|
from app.model import *
|
||||||
|
|
||||||
|
|
||||||
class UserInfoAPI(Resource):
|
class UserInfoAPI(Resource):
|
||||||
"""
|
"""
|
||||||
@ -8,5 +10,24 @@ class UserInfoAPI(Resource):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
def get(self):
|
def get(self):
|
||||||
user = session["user"]
|
user = session.get("user", None)
|
||||||
return {'USER': user}, 200
|
return {'USER': user}, 200
|
||||||
|
|
||||||
|
|
||||||
|
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
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
from app.api.GroupAPI import GroupAPI
|
from app.api.GroupAPI import GroupAPI
|
||||||
|
from app.api.LivretAPI import LivretAPI
|
||||||
from app.api.LoginAPI import LoginAPI
|
from app.api.LoginAPI import LoginAPI
|
||||||
from app.api.UserAPI import UserAPI
|
from app.api.UserAPI import UserAPI
|
||||||
from app.api.UserInfoAPI import UserInfoAPI
|
from app.api.UserInfoAPI import UserInfoAPI, UserGroupsAPI
|
||||||
from app.api.exampleapi import SomeApi
|
from app.api.exampleapi import SomeApi
|
||||||
from app.core import api
|
from app.core import api
|
||||||
|
|
||||||
@ -9,6 +10,8 @@ from app.core import api
|
|||||||
api.add_resource(SomeApi, '/api/someapi', '/api/someapi/<int:id>')
|
api.add_resource(SomeApi, '/api/someapi', '/api/someapi/<int:id>')
|
||||||
api.add_resource(LoginAPI, '/api/login')
|
api.add_resource(LoginAPI, '/api/login')
|
||||||
api.add_resource(UserInfoAPI, '/api/userInfo')
|
api.add_resource(UserInfoAPI, '/api/userInfo')
|
||||||
|
api.add_resource(UserGroupsAPI, '/api/userGroups')
|
||||||
api.add_resource(UserAPI, '/api/user', '/api/user/byuid/<int:uid>', '/api/user/byemail/<string:email>',
|
api.add_resource(UserAPI, '/api/user', '/api/user/byuid/<int:uid>', '/api/user/byemail/<string:email>',
|
||||||
'/api/user/byhash/<string:hashcode>')
|
'/api/user/byhash/<string:hashcode>')
|
||||||
api.add_resource(GroupAPI, '/api/group', '/api/group/bygid/<int:gid>', '/api/group/byname/<string:name>')
|
api.add_resource(GroupAPI, '/api/group', '/api/group/bygid/<int:gid>', '/api/group/byname/<string:name>')
|
||||||
|
api.add_resource(LivretAPI, '/api/livret', '/api/livret/byuid/<int:uid>')
|
||||||
|
Reference in New Issue
Block a user