fatfreecrm/fat_free_crm

View on GitHub
app/views/admin/users/_user.html.haml

Summary

Maintainability
Test Coverage
%li.highlight[user]

  - if user.awaits_approval?
    .strip.signed_up #{t :user_signed_up}
  - elsif user.suspended?
    .strip.suspended #{t :user_suspended}
  - elsif user.admin?
    .strip.admin #{t :user_admin}
  - else
    .strip.active #{t :user_active}

  = avatar_for(user, width: '30', height: '30')

  .indentfull
    .tools
      = link_to_edit(user, url: edit_admin_user_path(user)) + " | "

      - if user.suspended?
        = link_to_reactivate(user) + " | "
      - elsif user != current_user
        = link_to_suspend(user) + " | "
      - else
        %span.grayed #{t :suspend}!
        = " | "

      - if user != current_user
        = link_to_confirm(user)
      - else
        %span.grayed #{t :delete}?

    %span.black #{link_to( user.full_name, user)} (#{user.username})
    %tt
      = "- #{user.title}" unless user.title.blank?
      = " " + t(:at) + " " + user.company unless user.company.blank?

      %span.black= "|"
      - if user.last_sign_in_at && user.sign_in_count > 0
        = t('pluralize.login', user.sign_in_count)
        %span.black= "|"

      - if user.awaits_approval?
        %b.cool= t(:user_awaits_approval)
      - elsif user.last_sign_in_at
        %span.cool= t(:last_logged_in, timeago(user.current_sign_in_at)).html_safe
      - else
        %span.warn= t(:user_never_logged_in)
    %dt{ style: "padding: 2px 0px 0px 0px" }
      = link_to_email(user.email.to_s) + " | "
      - if user.phone?
        = t(:phone_small) + ":"
        = content_tag(:b, user.phone) + " | "
      - if user.mobile?
        = t(:mobile_small) + ":"
        = content_tag(:b, user.mobile) + " | "

      - if !user.suspended?
        %span #{t(:user_since, l(user.created_at.to_date, format: :mmddyy))}
      - elsif user.awaits_approval?
        %b.cool #{t(:user_signed_up_on, l(user.created_at, format: :mmddhhss))}
      - else
        %span.warn #{t(:user_suspended_on, l(user.created_at.to_date, format: :mmddyy))}
    - groups = user.groups
    - unless groups.count.zero?
      %dt{ style: "padding: 2px 0px 0px 0px" }
        = t(:groups) + ":"
        = groups.map(&:name).join(', ')