osbridge/openconferenceware

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

Summary

Maintainability
Test Coverage
<%
# Variables:
# - @proposal: Proposal record
# - @comment: Comment record, may be a new_record or one with error
# - @focus_comment: Focus on comment? E.g., because it has an error
# - @display_comment_form: Display the comment?
# - @kind: :session or :proposal, optional.

@kind ||= :proposal
page_title h(@proposal.title)
include_user_favorites_javascript
run_when_dom_is_ready( 'bind_calendar_items();' )
focus :comment_message if @focus_comment
show_private_note = (can_edit?(@proposal) || selector?) && ! @proposal.note_to_organizers.blank?
%>

<% content_for :meta do %>
  <meta name="twitter:card" content="summary">
  <meta name="twitter:url" content="<%= proposal_url @proposal %>">
  <meta name="twitter:title" content="<%= h @proposal.title %>">
  <%  published_type = proposal_statuses? && (@event.proposal_status_published? && @proposal.confirmed? ? 'A session ' : 'A proposed session ')
      metadescription = "#{published_type if published_type}at #{@event.title}"
      metadescription << " by #{@proposal.users.fullnames}" if multiple_presenters? && @proposal.users.size > 1
  %>
  <meta name="twitter:description" content="<%= h truncate("#{metadescription} &mdash; #{@proposal.excerpt}", :length => 200) %>">
  <%- if OpenConferenceWare.twitter -%>
  <meta name="twitter:site" content="<%= OpenConferenceWare.twitter %>">
  <%- end -%>
  <%- if user_profiles? -%>
  <%- if multiple_presenters? && first_user_with_twitter = @proposal.users.detect{|u| !u.twitter.blank?} -%>
  <meta name="twitter:creator" content="<%= first_user_with_twitter.normalized_twitter %>">
  <%- elsif !multiple_presenters? && !@proposal.user.twitter.blank? -%>
  <meta name="twitter:creator" content="<%= @proposal.user.normalized_twitter %>">
  <% end -%>
  <% end -%>
<% end -%>

<% content_for :scripts do %>
  <script>
    audiojs.events.ready(function() {
        var as = audiojs.createAll({
          imageLocation: '<%= asset_path("audiojs/player-graphics.gif") %>',
          swfLocation: '<%= asset_path("audiojs/audiojs.swf") %>'
        });
    });
  </script>
<% end %>

<%= render partial: 'selector_voting' if @selector_vote %>

<%= user_favorite_control_for @proposal %>
<%= render :partial => "open_conference_ware/proposals/admin_controls" %>

<%= cache "#{@kind}_#{@proposal.id},edit_#{can_edit?(@proposal)},private_note_#{show_private_note}" do %>
  <div class='show-proposal'>

  <% if current_user_is_proposal_speaker? %>
    <% if proposal_statuses? && @event.show_proposal_confirmation_controls? && @proposal.accepted? %>
      <div id="proposal-accepted">
        <h3>Congratulations, your proposal was accepted!</h3>
        <p>Are you are still able and willing to deliver this talk at the conference?</p>
        <div class="record-controls">
          <%= link_to "Yes, I'll be there!", speaker_confirm_path(@proposal), :method => :post, :class => 'confirmable' %>
          <%= link_to 'No, I decline.', speaker_decline_path(@proposal), :data => { :confirm => 'Are you sure?' }, :method => :post, :class => 'deletable' %>
        </div>
      </div>
    <% end %>
  <% end %>

  <% unless @proposal.audio_url.blank? %>
    <div class="session-audio">
      <h3>Session Audio</h3>
      <div>
        <audio src="<%= @proposal.audio_url %>" preload="none" />
      </div>
      <p>
        <%= link_to "Download audio of this session", @proposal.audio_url %>
      </p>
    </div>
  <% end -%>

  <div class='proposal-meta'>
    <% if proposal_statuses? && @event.proposal_status_published? %>
      <% if @proposal.confirmed? %>
        <div class='proposal-status <%= @proposal.status %>'>
          Accepted Session
        </div>
      <% else %>
        <div class='proposal-status proposed'>
          Proposal
        </div>
      <% end %>
    <% end %>
  <% if event_tracks? %>
      <div class='track block <%= track_css_class(@proposal.track) unless @proposal.track.try(:title).blank? %>'>
        <%= link_to(h(@proposal.track.try(:title)), event_track_path(@proposal.event, @proposal.track)) || "- N/A -" %>
      </div>
  <% end %>
  <% if event_session_types? && @proposal.session_type && ! @proposal.session_type.title.blank? && @event.session_types.size > 1 %>
      <%= link_to(h(@proposal.session_type.try(:title)), event_session_type_path(@proposal.event, @proposal.session_type), :class=>'session_type') || "- N/A -" %>
  <% end %>
    <% unless @proposal.audience_level_label.blank? %>
      <div class='proposal-audience_level'>
        <%= @proposal.audience_level_label %>
      </div>
    <% end %>
    <% if schedule_visible? && @proposal.start_time %>
      <div class='proposal-scheduling'>
        <b>Scheduled:</b>
        <%= normalize_time(@proposal, :format => :html) %>
        <% if event_rooms? && @proposal.room %>
          in
          <span class='proposal-room'>
            <%= link_to h(@proposal.room.name), @proposal.room %>
          </span>
        <% end %>
      </div>
    <% end %>
    <% if @proposal.session_notes_url && @event.proposal_titles_locked? %>
      <div class='proposal-notes'>
        <%= link_to "Session notes", @proposal.session_notes_url, :class => "showable" %>
      </div>
    <% end -%>
  </div>

  <% if proposal_excerpts? %>
    <h3>Excerpt</h3>
    <%= preserve_formatting_of @proposal.excerpt %>
  <% end %>

  <h3>Description</h3>
  <%= display_textile_for @proposal.description %>

  <% unless @proposal.tags.empty? %>
    <h3>Tags</h3>
    <p><%= @proposal.tag_list %></p>
  <% end %>

  <% if proposal_speaking_experience? %>
    <h3>Speaking experience</h3>
    <%= preserve_formatting_of @proposal.speaking_experience %>
  <% end %>

  <% if show_private_note %>
    <h3>Private Note to Organizers</h3>
    <%= preserve_formatting_of @proposal.note_to_organizers %>
  <% end %>

  <% if user_profiles? %>
    <h3><%= @proposal.users.size <= 1 ? "Speaker" : "Speakers" %></h3>
    <%= render :partial => 'open_conference_ware/users/list', :locals => { :users => @proposal.users.by_name, :hide_rooms => true, :only_for_event => @event } %>
  <% else %>
      <h3><%= @proposal.presenter %></h3>
      <table>
        <% if @proposal.affiliation.present? -%>
        <tr>
          <th>Affiliation</th>
          <td><%= @proposal.affiliation %></td>
        </tr>
        <% end -%>
        <% if @proposal.website.present? -%>
        <tr>
          <th>Website</th>
          <td><%= display_link_to(@proposal.website, :nofollow => true, :class => 'url') %></td>
        </tr>
        <% end -%>
        <% if admin? || can_edit?(@proposal) %>
        <tr>
          <th>Email (private)</th>
          <td><%= display_link_to(@proposal.email, :mailto => true) %></td>
        </tr>
        <% end -%>
        <% if @proposal.biography.present? %>
        <tr>
          <th>Biography</th>
          <td><%= display_textile_for @proposal.biography %></td>
        </tr>
      </table>
      <% end %>
    <% end %>

  <div class="record-controls">
    <% if can_edit?(@proposal) %>
      <%= link_to 'Edit proposal', edit_proposal_path(@proposal), :class => "editable" %>
      <%= link_to 'Destroy proposal', @proposal, :data => { :confirm => 'Are you sure?' }, :method => :delete, :class => "deletable" %>
    <% end %>
    <%= link_to "Back to list of #{@kind.to_s.pluralize}", records_path, :class => "cancelable" %>
  </div>


<% end %>

<% if admin? or selector? %>
  <%= cache "proposal_#{@proposal.id},comments_list" do %>
  <h3>Comments</h3>
  <%= render :partial => 'open_conference_ware/comments/list', :locals => { :comments => @proposal.comments }%>
  <% end %>
<% end %>

<% if @display_comment_form %>
  <%= form_for(@comment, :url => proposal_comments_path(@proposal), :html => {:id => "comment-form", :class => "standard-form"}) do |f| %>
    <h4>Leave a private comment to organizers about this proposal</h4>
    <table class="standard-form">
      <% unless error_messages_for(:comment).blank? %>
        <tr>
          <td class="label-cell">&nbsp;</td>
          <td class="data-cell">
            <%= error_messages_for :comment %>
          </td>
        </tr>
      <% end %>
      <tr>
        <td class="label-cell">
          <%= f.label :email, "Email address" %>
        </td>
        <td class="data-cell">
          <%= f.text_field :email %>
        </td>
      </tr>
      <tr>
        <td class="label-cell">
          <%= f.label :message, "Comment" %>
        </td>
        <td class="data-cell">
          <%= f.text_area :message, :rows => 3 %>
        </td>
      </tr>
      <tr class="quagmire">
        <td class="label-cell">
          <%= label :quagmire, "Leave blank" %>
        </td>
        <td>
          <%= text_field_tag :quagmire %>
        </td>
      </tr>
      <tr>
        <td class="label-cell">&nbsp;</td>
        <td class="data-cell">
          <%= f.submit "Create comment" %>
        </td>
      </tr>
    </table>
  <% end %>
<% end %>

</div>