user_ctrl.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:mentii 作者: mentii 项目源码 文件源码
def joinClass(jsonData, dynamoDBInstance, email=None, userRole=None):
  response = ControllerResponse()
  #g will be not be available during testing
  #and email will need to be passed to the function
  if g: # pragma: no cover
    email = g.authenticatedUser['email']
    userRole = g.authenticatedUser['userRole']

  if 'code' not in jsonData.keys() or not jsonData['code']:
    response.addError('Key Missing Error', 'class code missing from data')
  elif userRole == 'teacher' or userRole == 'admin':
    if class_ctrl.isCodeInTaughtList(jsonData, dynamoDBInstance, email):
      response.addError('Role Error', 'Teachers cannot join their taught class as a student')
    else:
      classCode = jsonData['code']
      addDataToClassAndUser(classCode, email, response, dynamoDBInstance)
  else:
    classCode = jsonData['code']
    addDataToClassAndUser(classCode, email, response, dynamoDBInstance)
  return response
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号