app/views/events/_event_sidebar.html.erb
<div class="col-md-12 col-lg-4" id="event-sidebar">
<% cache [event.organizer_name, event.recent_attendees] do %>
<!-- Event Organizer and Attendees -->
<div class="event-info-box box box--sidebar mt-lg-0 py-3">
<div class="organizers-preview">
<h3 class="h4 mb-3">
Organizer
</h3>
<ul>
<li>
<%= link_to event.organizer_name,
event_attendee_path(event, event.organizer),
class: "mb-2rem" %>
</li>
</ul>
</div>
<div class="attendees-preview">
<h3 class="h4 mt-3 mb-3">
Attendees (<%= event.attendees_count %>)
</h3>
<% unless event.attendees.empty? %>
<ul>
<%= render partial: "events/list_attendee",
collection: event.recent_attendees, as: :attendee,
locals: { event: event } %>
</ul>
<% if event.has_more_attendees_than_recent_attendees? %>
<%= link_to "See all attendees", event_attendees_path(event) %>
<% end %>
<% else %>
<ul>
<li>
So far there are no attendees
</li>
</ul>
<% end %>
</div>
</div><!-- /.box -->
<% end %><!-- cache end -->
<!-- Sidebar Links -->
<% if user_signed_in? %>
<div class="box box--sidebar p-3">
<div class="quick-access">
<div>
<span class="mr-1"><%= location_icon %></span>
<%= link_to "See location in map", "#map",
data: { turbolinks: false } %>
</div>
<% if event.website? %>
<div class="mt-2">
<span class="mr-1"><%= link_icon %></span>
<%= link_to "Visit event website", event.website %>
</div>
<% end %>
</div>
</div><!-- /.box -->
<% end %>
<!-- Attendance Button -->
<% unless event.organizer?(current_user) %>
<div class="box box--sidebar p-3">
<div class="attendance">
<% if event.not_an_attendee?(current_user) %>
<h4 class="h5">Would you like to attend?</h4>
<%= link_to "Attend",
event_attendances_path(event),
method: :post, remote: true,
class: "btn btn-primary btn-block btn-lg mt-3" %>
<% else %>
<h4 class="h5">You are attending this event!</h4>
<%= link_to "Cancel attendance",
event_attendance_path(event, current_user),
method: :delete, remote: true,
class: "btn btn-secondary btn-block btn-lg mt-3",
data: { confirm: "Are you sure to cancel your attendance?" } %>
<% end %>
</div>
</div><!-- /.box -->
<% end %>
<!-- Edit Event Button -->
<% if event.organizer?(current_user) %>
<div class="box box--sidebar p-3">
<% if event.sample_event? %>
<%= button_tag "Edit event",
class: "btn btn-primary btn-block btn-lg disabled" %>
<% else %>
<%= link_to "Edit event", edit_group_event_path(group, event),
class: "btn btn-primary btn-block btn-lg" %>
<% end %>
</div><!-- /.box -->
<% end %>
</div>