Skip to content

Instantly share code, notes, and snippets.

@MettaAudio
Created December 22, 2010 21:23
Show Gist options
  • Save MettaAudio/752124 to your computer and use it in GitHub Desktop.
Save MettaAudio/752124 to your computer and use it in GitHub Desktop.
Form madness
<div style="float:left; width:45%; margin-right:25px">
<h1><%= object.line_item.order.user.email %></h1>
<h2><%= object.line_item.product.name %></h2>
<h2><%= object.line_item.order.id %></h2>
<% object.associated_requests.each do |request| %>
<p>Request on <%= request.created_at.to_date %> and approved on <%= request.approval_date.to_date %></p>
<table class="index">
<tr>
<th>Contest Name</th>
<th>Host name</th>
<th>City</th>
<th>State</th>
<th style="width:120px;">Date of Competition</th>
<th style="width:40px;">Add</th>
</tr>
<% request.associated_sites.each do |sites| %>
<tr>
<td><%= sites.name %></td>
<td><%= sites.host_name %></td>
<td><%= sites.city %></td>
<td><%= sites.state.abbr %></td>
<td><%= sites.competition_date ? sites.competition_date.to_date : "No Date Given" %></td>
<td>
<% form_for @approval, :url => { edit_admin_approval_path(@approval) } do |f| -%>
<%# hidden_field_tag :site_id, sites.id %>
<% f.fields_for :sites do |site| -%>
<%= site.check_box sites.id, :is_confirmed %>
<% end -%>
<%= f.submit "Confirm Site", :disable_with => 'Confirming...' %>
<% end -%>
</td>
</tr>
<% end %>
</table>
<% end %>
</div>
<div style="width:45%; float:right; margin-right:25px">
<h1>Approved Sites</h1>
<table class="index">
<tr>
<th>Contest Name</th>
<th>Host name</th>
<th>City</th>
<th>State</th>
<th style="width:120px;">Date of Competition</th>
<th style="width:40px;">Edit</th>
</tr>
<% @approved_sites.each do |site| %>
<!-- Filter only sites that contain the same show. -->
<!-- Removed because we want to see sites that don't contain that show, so we can watch for duplicate sites. -->
<!-- A more useful filter is the javascript state filter. -->
<%# next if site.line_items.select { |line_item| line_item.id == object.line_item_id }.size == 0 %>
<tr>
<td><%= site.name %></td>
<td><%= site.host_name %></td>
<td><%= site.city %></td>
<td><%= site.state.abbr %></td>
<td><%= site.competition_date ? site.competition_date.to_date : "No Date Given" %></td>
<td><%= site.is_confirmed.inspect %></td>
</tr>
<% site.line_items.each do |line_item| %>
<tr>
<td><%= line_item.order.id %></td>
<td colspan="5"><%= line_item.product.name %></td>
</tr>
<% end %>
<tr>
<td colspan="6">
<% unless site.line_items.select { |line_item| line_item.id == object.line_item_id }.size > 0 %>
<% form_for object_path, :url => { :controller => "approvals", :action => "update" }, :html => {:method => "put"} do |f| -%>
<%= hidden_field_tag :site_id, site.id %>
<%= f.submit "Add #{object.line_item.product.name} to this site", :disable_with => 'Adding...' %>
<% end -%>
<% end %>
</td>
</tr>
<% end %>
</table>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment