예제 #1
0
 def add_users(cls, pid, userids):
     try:
         [db.session.add(UserBindProject(user_id=uid, project_id=pid)) for uid in userids]
         db.session.commit()
         return 0, None
     except Exception as e:
         current_app.logger.error(str(e))
         return 102, str(e)
예제 #2
0
 def bind_users(cls, pid, userids):
     try:
         [db.session.delete(item) for item in UserBindProject.query.filter_by(project_id=pid).all()]
         [db.session.add(UserBindProject(user_id=uid, project_id=pid)) for uid in userids]
         db.session.commit()
         return 0, None
     except Exception as e:
         current_app.logger.error(str(e))
         return 102, str(e)
예제 #3
0
 def project_add_users(cls, project_id, user_list):
     with db.auto_commit():
         ret = UserBindProject.query.filter(
             UserBindProject.user_id.in_(user_list),
             UserBindProject.project_id == project_id).all()
         if ret:
             for r in ret:
                 db.session.delete(r)
         for uid in user_list:
             db.session.add(
                 UserBindProject(user_id=uid, project_id=project_id))
     return 0, None