fablabbcn/fablabs

View on GitHub
app/views/users/edit.html.haml

Summary

Maintainability
Test Coverage
= render "backstage/header"

.container
  =title "Edit Your Settings"
  = simple_form_for @user do |f|
    %fieldset
      = render "form_errors", resource: @user
      .row
        .col-md-6
          = f.input :first_name, placeholder: 'First Name'
        .col-md-6
          = f.input :last_name, placeholder: 'Last Name'

      = f.input :username
      = f.input :email
      = f.input :email_fallback
      = f.input :dob
      = f.input :phone
      = f.input :country_code, as: 'country', priority: ([current_country.alpha2.downcase] if current_country), label: 'Country', iso_codes: true

      - if @user.passed_spam_period?
        = f.input :bio, input_html: { rows: 5 }
        = f.input :url
      - else
        .alert.alert-warning.mt-2{:role => "alert"}
          %p Because of high amount of spam users, the biography section, will only be available after being a member for two months.

    - if @user.passed_spam_period?
      %fieldset
        = render 'form_links', f: f

    %fieldset
      .row
        .col-lg-3
          = image_tag @user.avatar_url, class: 'avatar big'
        .col-lg-9
          = f.input :avatar, as: :file, label: 'Avatar', hint: "You can upload an avatar, otherwise we'll try and use your #{link_to 'gravatar', 'http://gravatar.com'}".html_safe
          = f.hidden_field :retained_avatar

    %fieldset
      = f.input :use_metric, :collection => [[true, 'Metric - cm/m/km'], [false, 'Imperial - in/ft/mi']], item_wrapper_class: 'form-check form-group', :label_method => :last, :value_method => :first, inline_label: true, :as => :radio_buttons, :label => "Preferred units", :hint => "This doesn't update measurements on the site yet, but will do soon", input_html: { class: 'form-check-input' }

    = f.submit "Update", class: 'btn btn-primary btn-lg mt-4'