JS-Tech/resj

View on GitHub
app/views/users/profile.html.erb

Summary

Maintainability
Test Coverage
<% content_for :id, "container-users-profile" %>

<div class="title green">
  <h2>Paramètres de compte</h2>
  <%= link_to "Editer", profile_edit_path %>
</div>

<div class="name">
  <%= @user.firstname %>
  <%= @user.lastname %>
</div>

<div class="item green">
  <h3>E-Mail</h3>
  <%= @user.email %>
</div>

<div class="item green">
  <h3>Newsletter</h3>
  <%= t("user.newsletter.#{@user.newsletter}") %>
</div>

<% unless @orator.nil? %>

<div class="title orange">
  <h2>Paramètres d'orateur</h2>
  <%= link_to "Editer", orator_edit_path %>
</div>

<div class="item orange orator-visibility">
  <h3>Visibilité sur la liste</h3>
  <% if @orator.disabled %>
  <p>Vous n'êtes pas visible en tant qu'orateur <%= link_to "Devenir visible", orator_update_visibility_path, method: :patch %></p>
  <% else %>
  <p>Vous êtes visible en tant qu'orateur <%= link_to "Se rendre invisible", orator_update_visibility_path, method: :patch %></p>
  <% end %>
</div>

<div class="item orange">
  <h3>Description</h3>
  <%= @orator.description %>
</div>

<div class="item orange">
  <h3>Adresse</h3>
  <%= @orator.street %>
  <%= @orator.location.full_name %>
</div>

<div class="item orange">
  <h3>Disponibilités</h3>
  <% @orator.disponibility %>
</div>

<% end %>

<% if @cards.any? %>
<div class="cards">
  <h2>Mes groupes</h2>
</div>

<% @cards.each do |card| %>
<div class="card title red">
  <h2><%= card.name %></h2>
  <div class="links">
    <%= link_to "Voir", card_path(card) %>
    <%= link_to "Editer", edit_users_card_path(card) %>
  </div>
</div>
<% end %>

<% end %>

<% if current_user.belongs_to?(:superadmin) || current_user.belongs_to?(:admin) || current_user.belongs_to?(:manager) %>
<div class="administration">
  <h2>Administration</h2>

  <div class="links">
    <%= link_to "Groupes", admin_cards_path %>
  </div>
</div>
<% end %>

<div class="danger">
  <h2>Zone de danger</h2>

  <div class="links">
    <%= button_to_confirmation "Supprimer mon compte", form: { url: profile_delete_path(@user), method: :delete } do %>
      <p>Êtes-vous sûr de vouloir supprimer votre compte ?</p>
    <% end %>

    <% unless @orator.nil? %>
    <%= button_to_confirmation "Supprimer mon profil orateur", form: { url: orator_delete_path(@orator), method: :delete } do %>
      <p>Êtes-vous sûr de vouloir supprimer votre profil orateur ?</p>
    <% end %>

    <% end %>
  </div>
</div>