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

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

    if not UserManager.is_admin():
      self.redirect('/')
      return

    template = JINJA_ENVIRONMENT.get_template('templates/users/users.html')

    def is_user_admin(user):

      values = sorted(values, key=lambda r: r.value, reverse=True)
      remapped_values = itertools.groupby(values, key=lambda v: v.type)

      return remapped_values

    JINJA_ENVIRONMENT.filters['is_user_admin'] = is_user_admin

    self.response.write(template.render({
      'users': User.query(),
      'sign_out_url': UserManager.get_signout_url(),
      'gravatar_url': UserManager.get_gravatar_url(),
      'user_email': UserManager.get_email(),
      'user_is_admin': UserManager.is_admin(),
      'sections': [{
        "name": "Users"
      }]
    }))
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
    }))