<% cache [locale_and_user_status(@debate), @debate, @debate.author, Flag.flagged?(current_user, @debate), @debate_votes] do %>
  <section class="debate-show">
    <div id="<%= dom_id(@debate) %>" class="row">
      <div class="small-12 medium-9 column">
        <i class="icon-angle-left left"></i>&nbsp;
        <%= link_to t("debates.show.back_link"), debates_path, class: 'left back' %>

        <% if current_user && @debate.editable_by?(current_user) %>
          <%= link_to edit_debate_path(@debate), class: 'edit-debate button success tiny radius right' do %>
            <i class="icon-edit"></i>
            <%= t("debates.show.edit_debate_link") %>
          <% end %>
        <% end %>

        <h1><%= @debate.title %></h1>
        <% if @debate.conflictive? %>
          <div class="alert-box alert radius margin-top">
            <strong><%= t("debates.show.flag") %></strong>
          </div>
        <% end %>

        <div class="debate-info">
          <%= avatar_image(@debate.author, seed: @debate.author_id, size: 32, class: 'author-photo') %>

          <% if @debate.author.hidden? %>
            <i class="icon-deleted author-deleted"></i>
            <span class="author">
                <%= t("debates.show.author_deleted") %>
            </span>
          <% else %>
            <span class="author">
                <%= @debate.author.name %>
            </span>
            <% if @debate.author.official? %>
              &nbsp;&bull;&nbsp;
              <span class="label round level-<%= @debate.author.official_level %>">
                <%= @debate.author.official_position %>
              </span>
            <% end %>
          <% end %>

          <% if @debate.author.verified_organization? %>
            &nbsp;&bull;&nbsp;
            <span class="label round is-association">
              <%= t("shared.collective") %>
            </span>
          <% end %>

          <span class="bullet">&nbsp;&bull;&nbsp;</span>
          <%= l @debate.created_at.to_date %>
          <span class="bullet">&nbsp;&bull;&nbsp;</span>
          <i class="icon-comments"></i>&nbsp;
          <%= link_to t("debates.show.comments", count: @debate.comments_count), "#comments" %>
          <span class="bullet">&nbsp;&bull;&nbsp;</span>
          <span class="js-flag-actions">
            <%= render 'debates/flag_actions', debate: @debate %>
          </span>
        </div>

        <%= @debate.description %>

        <%= render 'shared/tags', debate: @debate %>

        <div class='js-moderator-debate-actions'>
          <%= render 'actions', debate: @debate %>
        </div>
      </div>

      <aside class="small-12 medium-3 column">
        <div class="sidebar-divider"></div>
        <h3><%= t("votes.supports") %></h3>
        <div class="text-center">
          <div id="<%= dom_id(@debate) %>_votes">
           <%= render 'debates/votes', debate: @debate %>
          </div>
        </div>
        <div class="sidebar-divider"></div>
        <h3><%= t("debates.show.share") %></h3>
        <%= social_share_button_tag(@debate.title) %>
      </aside>
    </div>
  </section>
<% end %>
<%= render "comments" %>
