<div class="row-fluid">
  <% unless @group.narrative.blank? %>
      <div class="span8">

        <div class="default-padding" style="padding: 24px 24px 12px 24px;">
          <% paragraphs = @group.narrative.split '\n' %>
          <% paragraphs.each do |p| %>
              <p><%= p %></p>
          <% end %>
        </div>

      </div>
  <% end %>
  <div class="span4">

    <div class="default-padding">

      <% can_join = can? :create, Membership.new(group: @group, level: Membership::LEVELS[:pending], user: current_user)
         already_member = @group.made_request? current_user %>
      <% if can_join || already_member %>
          <div class="subblock bordered">
            <div class="default-padding clearfix">
              <% if already_member %>
                  <% membership = Membership.where(group_id: @group.id, user_id: current_user.id).first %>
                  <% if @group.has_member?(current_user) && can?(:delete, membership) %>
                      <%= link_to(t('.leave_group'), group_membership_path(group_id: @group.id, id: membership.id), method: :delete, class: "btn pull-right", data: {confirm: t(:are_you_sure_leave_group, group: @group.name)}) %>
                  <% end %>
                  <p>
                    <b><%= t('.your_membership_role', level: human_membership_level_name(membership.level_name), what: (membership.level == Membership::LEVELS[:leader] ? "" : t('.member'))) %></b>
                  </p>
              <% elsif can_join %>
                  <%= link_to(t('.join_group'), group_memberships_path(group_id: @group.id, membership: {user_id: current_user.id}), method: :post, class: "btn pull-right") %>
                  <p><b><%= t('.not_in_group') %></b></p>
              <% end %>
            </div>
          </div>
      <% end %>

    </div>
  </div>
</div>

<!-- Begin Feeds -->
<div class="clearfix default-padding">
  <div class="header-with-icon">
    <h3>
      <%= t '.feed_header', count: @group.feeds.count %>
    </h3>
  </div>
</div>
<div class="row-fluid">
  <%= render partial: 'feeds', locals: { feeds: @feeds_left } %>
  <%= render partial: 'feeds', locals: { feeds: @feeds_right } %>
</div>

<!-- Begin Screens -->
<div class="clearfix default-padding">
  <div class="header-with-icon">
    <h3>
      <%= t '.screen_header', count: @group.screens.count %>
    </h3>
  </div>
  <br/>
  <%= render partial: "screens/thumbs", object: @group.screens,
             locals: {show_field_count: false, show_owner: false} %>
</div>

<!-- Begin Members -->
<% total_members = @group.memberships.regular.size + @group.memberships.leader.size %>
<div class="clearfix default-padding">
  <div class="header-with-icon">
    <h3>
      <%= t '.member_header', count: total_members %>
    </h3>
  </div>
  <br/>
  <ul class="list-grid">
    <% @group.memberships.leader.each do |leader| %>
        <li>
          <div class="cont thumb-icon">
            <%= link_to leader.user do %>
                <i class="concertocon-controller-users-leader"></i>
            <% end %>
          </div>
          <div class="cont">
            <p><b><%= link_to_if can?(:read, leader.user), leader.user.name, leader.user %></b></p>

            <p><%= t('.leader') %></p>
          </div>
        </li>
    <% end unless @group.memberships.regular.nil? %>
    <% @group.memberships.regular.each do |regular| %>
        <li>
          <div class="cont thumb-icon">
            <%= link_to regular.user do %>
                <i class="fa fa-user"></i>
            <% end %>
          </div>
          <div class="cont">
            <p><b><%= link_to_if can?(:read, regular.user), regular.user.name, regular.user %></b></p>
          </div>
        </li>
    <% end unless @group.memberships.regular.nil? %>
  </ul>
</div>
