adds officer-polls relation and spec

This commit is contained in:
Juanjo Bazán
2016-12-06 14:51:53 +01:00
parent 0f72596c27
commit ad2dd7d267
6 changed files with 20 additions and 25 deletions

View File

@@ -1,7 +1,7 @@
class Poll < ActiveRecord::Base
has_many :booth_assignments, class_name: "Poll::BoothAssignment"
has_many :booths, through: :booth_assignments
has_many :officer_assignments, class_name: "Poll::OfficerAssignment"
has_many :officer_assignments, through: :booth_assignments
has_many :officers, through: :officer_assignments
has_many :voters, through: :booths, class_name: "Poll::Voter"

View File

@@ -11,28 +11,18 @@
<table>
<thead>
<th><%= t("admin.polls.show.name") %></th>
<th><%= t("admin.polls.show.location") %></th>
<th><%= t("admin.polls.show.officers") %></th>
<th>&nbsp;</th>
<th><%= t("admin.polls.show.email") %></th>
</thead>
<tbody>
<% @poll.officers.each do |officer| %>
<tr id="officer_<%= officer.id %>" class="officer">
<td>
<strong>
<%= link_to officer.name, admin_poll_officer_path(@poll, booth) %>
<%= officer.name %>
</strong>
</td>
<td>
<%= officer.name %>
</td>
<td>
N <%= t("admin.booths.index.officers") %>
</td>
<td class="text-right">
<%= link_to t("admin.actions.edit"),
edit_admin_poll_officer_path(@poll, officer),
class: "button hollow" %>
<%= officer.email %>
</td>
</tr>
<% end %>