Noosfero/noosfero

View on GitHub
app/views/account/_signup_form.html.erb

Summary

Maintainability
Test Coverage
<% @profile_data = @person %>

<%= javascript_include_tag('sign_up_password_rate') %>
<%= javascript_include_tag "signup_form" %>

<%= error_messages_for :user, :person, :header_message => _('The account could not be created') %>

<%= labelled_form_for :user, :html => { multipart: true, id: 'signup-form', class: 'form-with-captcha', honeypot: true } do |f| %>

<%= hidden_field_tag :invitation_code, @invitation_code %>

<div id='signup-form-header'>
  <div id='signup-username-section'>
    <div class='label-wrapper required-field'>
      <%= label(:user, :login, _('Username'), { class: 'formlabel' }) %>
      <%= tooltip(_('Your username identifies you inside the network, and '\
                    'will be used to generate a custom address to your pages. '\
                    'Choose wisely, you will not be able to change it.'), :large) %>
    </div>

    <p><%= _('Example of good usernames: jose-silva, maria.santos, josecosta') %></p>

    <div id='signup-username-form-line'>
      <span id="signup-domain"><%= environment.default_hostname %>/</span>
      <div id='signup-login'>
        <div id='signup-login-field' class='formfield'>
          <%= text_field(:user, :login, :id => 'user_login',
                                :onchange => 'this.value = convToValidUsername(this.value);') %>
        </div>
        <div id='url-check'><p>&nbsp;</p></div>
        <span id='checking-message' class='validated checking'>
          <%= _('Checking availability of login name...') %>
        </span>
      </div>
    </div>
  </div>

  <div id='signup-password-section'>
    <div class='label-wrapper required-field'>
      <%= label(:user, :password, _('Password'), { class: 'formlabel' }) %>
      <%= tooltip(_('You also need a password in order to access the network. '\
                    'Choose something with at least 4 characters that you will '\
                    'remember later.'), :large) %>
    </div>

    <div id='signup-password'>
      <div class='formfield'>
        <%= text_field(:user, :password, id: 'user_pw', placeholder: _('Password'), type: :password) %>
      </div>
    </div>

    <div id='signup-password-confirmation'>
      <div class='formfield'>
        <%= text_field(:user, :password_confirmation, placeholder: _('Type your password again'),
                                                      type: :password) %>
      </div>
      <p id='password-check'>
        <span class='invalid'><%= _('Passwords don\'t match') %></span>
      </p>
      <p id='password-rate'>
        <span class="invalid" id='result-blank'>
          &nbsp;
        </span>
        <span class="invalid hidden" id='result-short'>
          <%=_('Too Short') %>
        </span>
        <span class="invalid hidden" id='result-bad'>
          <%=_('Bad') %>
        </span>
        <span class="invalid hidden" id='result-good'>
          <%=_('Good') %>
        </span>
        <span class="invalid hidden" id='result-strong'>
          <%=_('Strong') %>
        </span>
      </p>
    </div>
  </div>

  <div class='separator-msg'><%= _('Just a few more things...') %></div>

  <div id='signup-name'>
    <%= required labelled_form_field(_('Full name'),
                            text_field(:profile_data, :name, placeholder: _('E.g.: Maria Silva'))) %>
  </div>

  <div id='signup-avatar'>
    <label class='formlabel'><%= _('Profile Image')%></label>
    <%= render :partial => 'shared/change_image', :locals => { :for_attr => 'profile_data[image_builder]', :type => 'profile' } %>
  </div>

  <div id='signup-email'>
    <%= required labelled_form_field(_('Email Address'),
                            text_field(:user, :email, placeholder: _('E.g.: maria.silva@mail.com'))) %>
    <div id='email-check'><p>&nbsp;</p></div>
  </div>
  <%= observe_field "user_email",
        :url      => { :action => "check_email" },
        :with     => "address",
        :update   => "email-check",
        :loading  => "jQuery('#user_email').removeClass('#{validation_classes}').addClass('checking');
                      jQuery('#email-check').html('<p><span class=\"checking\">#{checking_message(:email)}</span></p>');",
        :complete => "jQuery('#user_email').removeClass('checking')",
        :before   => "var field = jQuery('#user_email');
                      if (field.val()=='') {
                        field.parent('.formfield').removeClass('#{validation_classes}');
                        jQuery('#email-check').html('<p>&nbsp;</p>');
                        return false;
                      }
                      if (!( field.valid() )) {
                        field.parent('.formfield').removeClass('#{validation_classes}').addClass('invalid');
                        jQuery('#email-check').html('<p><span class=\"invalid\">#{_('This e-mail address is not valid')}</span></p>');
                        return false;
                      }" %>
</div>

<div id="signup-form-profile">
  <%= labelled_fields_for :profile_data, @person do |f| %>
    <%= render :partial => 'profile_editor/person_form', :locals => {:f => f} %>
  <% end %>

  <%= safe_join(@plugins.dispatch(:signup_extra_contents).collect { |content| instance_eval(&content) }, "") %>

  <%= render :partial => 'shared/custom_fields', :locals => {:f => f, :profile => @person, :signup => true} %>
  <%= template_options(:people, 'profile_data') %>

  <%= render :partial => 'shared/profile_kinds', :locals => {:form_field => 'profile_data'} %>

  <% unless @terms_of_use.blank? %>
    <div id='terms-of-use-box' class='formfieldline'>
      <%= labelled_check_box(_('I accept the %s').html_safe % link_to(_('terms of use'), {:controller => 'home', :action => 'terms'}, :target => '_blank'), 'user[terms_accepted]') %>
    </div>
  <% end %>

  <% if params[:enterprise_code] %>
    <%= hidden_field_tag :enterprise_code, params[:enterprise_code] %>
    <%= hidden_field_tag :answer, params[:answer] %>
    <%= hidden_field_tag :terms_accepted, params[:terms_accepted] %>
    <%= hidden_field_tag :new_user, true %>
  <% end %>
</div>

<%= captcha_tags(:signup, nil, environment) %>

<%= button_bar do %>
  <%= submit_button(:add_user, _('Create my account')) %>
<% end %>

<%= required_fields_message %>

<% end -%>