Esempio n. 1
0
def install_rootuser(request):
  # requires an admin
  user = users.get_current_user()
  if not user:
    return http.HttpResponseRedirect(users.create_login_url('/install'))
  else:
    if not users.is_current_user_admin():
      return http.HttpResponseRedirect('/')
  
  try:
    root_user = api.actor_get(api.ROOT, settings.ROOT_NICK)
  except:
    root_user = None

  if request.POST:
    try:
      logging.warning('Making root user: %s', settings.ROOT_NICK)
      validate.nonce(request, 'create_root')
      root_user = api.user_create_root(api.ROOT)
      return util.RedirectFlash('/install', 'Root user created')
    except:
      exception.handle_exception(request)

  redirect_to = '/'

  c = template.RequestContext(request, locals())    
  t = loader.get_template('rootuser.html')
  return http.HttpResponse(t.render(c))
Esempio n. 2
0
 def test_root(self):
   api.user_create_root(api.ROOT)
   r = self.client.get('/install')
   self.assertContains(r, 'Root User [email protected] exists')