Beispiel #1
0
def actor_email_update(request):
  logging.info("actor_email_update")
  
  if request.method == 'POST':
    if request.is_ajax():
      email = request.REQUEST.get('email', 'none')
      try:
        validate.email(email)
        api.activation_request_email(api.ROOT, request.user.nick, email)
        message = {'message':"success"}
      except exception.ValidationError, inst:
        message = {'message':str(inst)}
      except exception.ApiException, inst:
        message = {'message':str(inst)}
Beispiel #2
0
def install(request):
  try:
    root_user = api.actor_get(api.ROOT, settings.ROOT_NICK)
    if root_user:
      return util.RedirectFlash('/', 'Already Installed')
  except:
    root_user = None

  post_name = util.get_metadata('POST_NAME')
  default_channel = util.get_metadata('DEFAULT_CHANNEL')

  if request.POST:
    site_name = request.POST.get('site_name', None)
    tagline = request.POST.get('tagline', None)
    post_name = request.POST.get('post_name', None)

    root_mail = request.POST.get('root_mail', None)
    password = request.POST.get('password', None)
    confirm =  request.POST.get('confirm', None)
    default_channel = request.POST.get('default_channel', None)

    try:
      logging.info('saving values')
      validate.nonce(request, 'install')
      validate.email(root_mail)
      validate.password(password)
      validate.password_and_confirm(password, confirm)
      channel = clean.channel(default_channel)

      admin_helper.validate_and_save_sitesettings(site_name, tagline, post_name)
      root_user = api.user_create_root(api.ROOT, password=password)
      api.email_associate(api.ROOT, root_user.nick, root_mail)
      channel_ref = api.channel_create(api.ROOT, nick=api.ROOT.nick, channel=channel, tags=[],
                                       type='', description='Support Channel')
      util.set_metadata('DEFAULT_CHANNEL', default_channel)

      logging.info('Installed and Redirecting to front')
      return util.RedirectFlash('/', 'Installed Successfully')
    except:
      exception.handle_exception(request)

  redirect_to = '/'

  c = template.RequestContext(request, locals())
  return render_to_response('administration/templates/install.html', c)
Beispiel #3
0
def join_join(request):
  if request.user:
    raise exception.AlreadyLoggedInException()

  redirect_to = request.REQUEST.get('redirect_to', '/')

  # get the submitted vars
  nick = request.REQUEST.get('nick', '')
  first_name = request.REQUEST.get('first_name', '')
  last_name = request.REQUEST.get('last_name', '')
  email = request.REQUEST.get('email', '')
  password = request.REQUEST.get('password', '')
  confirm = request.REQUEST.get('confirm', '')
  homepage = request.REQUEST.get('homepage', '')
  hide = request.REQUEST.get('hide', '')

  if request.POST:
    try:
      # TODO validate
      params = util.query_dict_to_keywords(request.POST)

      if hide:
        params['privacy'] = 2
 
      validate.email(email)
      if not mail.is_allowed_to_send_email_to(email):
        raise exception.ValidationError("Cannot send email to that address")

      # TODO start transaction
      if api.actor_lookup_email(api.ROOT, email):
        raise exception.ValidationError(
            'That email address is already associated with a member.')
    
      actor_ref = api.user_create(api.ROOT, **params)
      actor_ref.access_level = "delete"

      api.post(actor_ref, 
               nick=actor_ref.nick, 
               message='Joined %s!' % (settings.SITE_NAME),
               icon='jaiku-new-user')

      # send off email confirmation
      api.activation_request_email(actor_ref, actor_ref.nick, email)
      
      # TODO end transaction
  
      welcome_url = util.qsa('/welcome', {'redirect_to': redirect_to})

      # NOTE: does not provide a flash message
      response = http.HttpResponseRedirect(welcome_url)
      user.set_user_cookie(response, actor_ref)
      return response
    except:
      exception.handle_exception(request)

  # for legal section
  legal_component = component.include('legal', 'dummy_legal')
  legal_html = legal_component.embed_join()

  # for sidebar
  sidebar_green_top = True

  area = "join"
  c = template.RequestContext(request, locals())

  t = loader.get_template('join/templates/join.html')
  return http.HttpResponse(t.render(c))
Beispiel #4
0
 def test_valid_emails(self):
   validate.email('*****@*****.**')
   validate.email('*****@*****.**')
   validate.email('*****@*****.**')
Beispiel #5
0
def join_join(request):
  if request.user:
    raise exception.AlreadyLoggedInException()

  redirect_to = request.REQUEST.get('redirect_to', '/')

  account_types = api.get_config_values(api.ROOT, 'account_type')

  # get the submitted vars
  nick = request.REQUEST.get('nick', '');
  first_name = request.REQUEST.get('first_name', '');
  last_name = request.REQUEST.get('last_name', '');
  email = request.REQUEST.get('email', '');
  password = request.REQUEST.get('password', '');
  confirm = request.REQUEST.get('confirm', '');
  hide = request.REQUEST.get('hide', '');
  country_tag = request.REQUEST.get('country_tag', '')

  if request.POST:
    try:
      # TODO validate
      params = util.query_dict_to_keywords(request.POST)

      if hide:
        params['privacy'] = 2

      # XXX: Check if the data come from a openid account
      # @author: [email protected]
      fromopenid = request.POST.get('fromopenid', False) and True
      if fromopenid:
        try:
          person = openidgae.get_current_person(request, http.HttpResponse())
        except:
          raise exception.ServiceError
        
        email = person.get_email()
        if email == params['email']:
          params['password'] = util.generate_password()
        else:
          raise exception.ServiceError

      # ENDXXX

      validate.email(email)
      if not mail.is_allowed_to_send_email_to(email):
        raise exception.ValidationError("Cannot send email to that address")

      # TODO start transaction
      if api.actor_lookup_email(api.ROOT, email):
        raise exception.ValidationError(
            'That email address is already associated with a member.')
      
      actor_ref = api.user_create(api.ROOT, **params)
      actor_ref.access_level = "delete"

      api.post(actor_ref, 
               nick=actor_ref.nick, 
               message='Joined %s!' % (util.get_metadata('SITE_NAME')))
      if fromopenid:
        api.email_associate(api.ROOT, actor_ref.nick, email)
      else:
        # send off email confirmation
        api.activation_request_email(actor_ref, actor_ref.nick, email)

      logging.info('setting firsttime_%s from register page' % actor_ref.nick)
      memcache.client.set('firsttime_%s' % nick, True)
      # TODO end transaction
      welcome_url = util.qsa('/', {'redirect_to': redirect_to})

      # NOTE: does not provide a flash message
      response = http.HttpResponseRedirect(welcome_url)
      user.set_user_cookie(response, actor_ref)
      return response
    except:
      exception.handle_exception(request)

  # for legal section
  legal_component = component.include('legal', 'dummy_legal')
  legal_html = legal_component.embed_join()
  
  # for sidebar
  sidebar_green_top = True

  area = "join"
  c = template.RequestContext(request, locals())

  t = loader.get_template('join/templates/join.html')
  return http.HttpResponse(t.render(c))
Beispiel #6
0
 def test_valid_emails(self):
     validate.email('*****@*****.**')
     validate.email('*****@*****.**')
     validate.email('*****@*****.**')
Beispiel #7
0
def join_join(request):
    if request.user:
        raise exception.AlreadyLoggedInException()

    redirect_to = get_clean_redirect(request)

    # get the submitted vars
    nick = request.REQUEST.get('nick', '')
    first_name = request.REQUEST.get('first_name', '')
    last_name = request.REQUEST.get('last_name', '')
    email = request.REQUEST.get('email', '')
    password = request.REQUEST.get('password', '')
    confirm = request.REQUEST.get('confirm', '')
    homepage = request.REQUEST.get('homepage', '')
    hide = request.REQUEST.get('hide', '')

    if request.POST:
        try:
            # TODO validate
            params = util.query_dict_to_keywords(request.POST)

            if hide:
                params['privacy'] = 2

            validate.email(email)
            if not mail.is_allowed_to_send_email_to(email):
                raise exception.ValidationError(
                    "Cannot send email to that address")

            # TODO start transaction
            if api.actor_lookup_email(api.ROOT, email):
                raise exception.ValidationError(
                    'That email address is already associated with a member.')

            actor_ref = api.user_create(api.ROOT, **params)
            actor_ref.access_level = "delete"

            api.post(actor_ref,
                     nick=actor_ref.nick,
                     message='Joined %s!' % (settings.SITE_NAME),
                     icon='jaiku-new-user')

            # send off email confirmation
            api.activation_request_email(actor_ref, actor_ref.nick, email)

            # TODO end transaction

            welcome_url = util.qsa('/welcome', {'redirect_to': redirect_to})

            # NOTE: does not provide a flash message
            response = http.HttpResponseRedirect(welcome_url)
            user.set_user_cookie(response, actor_ref)
            return response
        except:
            exception.handle_exception(request)

    # for legal section
    legal_component = component.include('legal', 'dummy_legal')
    legal_html = legal_component.embed_join()

    # for sidebar
    sidebar_green_top = True

    area = "join"
    c = template.RequestContext(request, locals())

    t = loader.get_template('join/templates/join.html')
    return http.HttpResponse(t.render(c))