osbridge/openconferenceware

View on GitHub
app/views/open_conference_ware/proposals/index.html.erb

Summary

Maintainability
Test Coverage
<%
# VARIABLES:
# * @event => Event these proposals are for
# * @proposals => Array of proposal objects
# * @kind => Symbol indicating mode, either :proposals or :sessions
%>

<% page_title "#{@event.title} #{@kind}" %>

<% include_user_favorites_javascript %>

<%
cache_key = "#{@kind}_index,event_#{@event.id},admin_#{admin?},accepting_#{@event.accepting_proposals?}"
cache_key << ",sort_#{params[:sort]}" if params[:sort]
cache_key << ",dir_#{params[:dir]}" if params[:dir]
cache_key << ",selector_#{current_user.id}" if selector?
%>

<% cache cache_key do %>
  <div>
    <% if @kind == :proposals %>
      <% if accepting_proposals? %>
        <div class="event_text open_text">
          <%= simple_format @event.open_text.try(:html_safe) %>
          <%= link_to "Edit", edit_manage_event_path(@event, :jump_to => :open_text), :class => "editable" if admin? %>
        </div>
        <div class="submit-a-proposal-wrapper">
          <%= link_to 'Submit a proposal!', new_event_proposal_path(@event), :class => "submit-a-proposal-button" %>
        </div>
      <% else %>
      <div class="event_text closed_text">
        <%= simple_format @event.closed_text.try(:html_safe) %>
        <%= link_to "Edit", edit_manage_event_path(@event, :jump_to => :closed_text), :class => "editable" if admin?%>
      </div>
      <% end %>
    <% elsif @kind == :sessions %>
      <div class="event_text session_text">
        <%= simple_format @event.session_text.try(:html_safe) %>
        <%= link_to "Edit", edit_manage_event_path(@event, :jump_to => :session_text), :class => "editable" if admin? %>
      </div>
    <% else %>
      <% raise TypeError, "Unknown kind: #{@kind.class.name.inspect}" %>
    <% end %>
  </div>

  <%= render :partial => "list", :locals => {:kind => @kind, :records => @proposals, :sorter => true} %>
<% end %>