Ejemplo n.º 1
0
  def post (self):

    if UserManager.get_current_user() == None:
      self.redirect('/user-not-found')
      return

    save_message = 'ok'

    user_email = self.request.get('user-email')

    if (user_email == '' or user_email == None):
      save_message = 'No email address provided.'
    elif (UserManager.get_user_by_email_address(user_email) == None):
      save_message = 'User does not exist.'
    else:

      projects_to_reassign = Project.query().filter(Project.owner==user_email)
      to_update = []

      for project in projects_to_reassign:
        project.owner = UserManager.get_email()
        to_update.append(project)

      if len(to_update) > 0:
        ndb.put_multi(to_update)

      user = UserManager.get_user_by_email_address(user_email)
      user.key.delete()

    template = JINJA_ENVIRONMENT.get_template('templates/_endpoints/action-update.json')
    self.response.write(template.render({
      "message": save_message
    }))
Ejemplo n.º 2
0
  def post (self):

    if UserManager.get_current_user() == None:
      self.redirect('/user-not-found')
      return

    save_message = 'ok'
    user_email = self.request.get('user-email')

    if (user_email == '' or user_email == None):
      save_message = 'No email address provided.'
    elif (UserManager.get_user_by_email_address(user_email) != None):
      save_message = 'User already exists.'
    else:
      user = User(email=user_email)
      user.put()

    template = JINJA_ENVIRONMENT.get_template('templates/_endpoints/action-update.json')
    self.response.write(template.render({
      "message": save_message
    }))