Skip to content

Commit

Permalink
Organizer dashboard shows number of checked in RSVPers per session.
Browse files Browse the repository at this point in the history
  • Loading branch information
tjgrathwell committed Mar 18, 2013
1 parent 0e09648 commit a1349ea
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 13 deletions.
1 change: 1 addition & 0 deletions app/assets/stylesheets/application.css.scss
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ $tableBorder: #BFBFBF;
@import "footer";

@import "events/show";
@import "events/organize";
11 changes: 11 additions & 0 deletions app/assets/stylesheets/events/_organize.css.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
.session-attendance {
display: inline-block;
margin-right: 30px;

.btn.btn-small {
font-size: 12px;
background: $orange-color;
color: $blue-color;
padding: 3px 4px;
}
}
8 changes: 8 additions & 0 deletions app/controllers/events_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,14 @@ def organize
@volunteer_assignment_counts[rsvp.volunteer_assignment_id] += 1
@volunteer_preference_counts[rsvp.volunteer_preference_id] += 1
end

@session_rsvp_counts = {}
@session_checkin_counts = {}

@event.event_sessions.each do |session|
@session_rsvp_counts[session.id] = session.rsvp_sessions.count
@session_checkin_counts[session.id] = session.rsvp_sessions.where(checked_in: true).count
end
end

protected
Expand Down
18 changes: 8 additions & 10 deletions app/views/events/organize.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,20 @@

<h2>Super Secret Organizer Mission Control Console</h2>

<% checkin_links = [] %>
<% @event.event_sessions.each do |session| %>
<% checkin_links << ["Check in for #{session.name}", event_event_session_checkins_path(@event, session)] %>
<div class='session-attendance'>
<h3><%= session.name %></h3>
<div><%= @session_checkin_counts[session.id] %>/<%= @session_rsvp_counts[session.id] %> Checked In</div>
<%= link_to "Check in for #{session.name}", event_event_session_checkins_path(@event, session), class: 'btn btn-small' %>
</div>
<% end %>
<%= render 'shared/actions', links: checkin_links, additional_class: 'mission-control-actions' %>
<%= render 'shared/actions', additional_class: 'mission-control-actions', links: [
['Manage Organizers', event_organizers_path(@event)],
['Manage Volunteers', event_volunteers_path(@event)],
['Email Volunteers', volunteer_emails_event_path(@event)]
] %>

<%= render 'shared/actions', additional_class: 'mission-control-actions', links: [
['Edit Event', edit_event_path(@event)],
['View Event', event_path(@event)],
] %>

<h2>Volunteer Teaching Preference Totals</h2>
<p>You can see individual preferences and assign teaching roles on the <%= link_to('Manage Volunteers', event_volunteers_path(@event)) %> page.</p>
<table class="table">
Expand Down Expand Up @@ -62,5 +58,7 @@
</table>

<%= render 'shared/actions', links: [
['Back', events_path],
['Event Index', events_path],
['Edit Event', edit_event_path(@event)],
['View Event', event_path(@event)],
] %>
34 changes: 34 additions & 0 deletions spec/controllers/events_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,40 @@ def make_request(params = {})
make_request
response.should be_success
end

describe "checked in user counts" do
before do
@session1 = @event.event_sessions.first
@event.event_sessions << create(:event_session)
@session2 = @event.event_sessions.last

attendee1 = create(:user)
rsvp1 = create(:rsvp, event: @event, user: attendee1, role: Role::VOLUNTEER)
create(:rsvp_session, rsvp: rsvp1, event_session: @session1, checked_in: true)
create(:rsvp_session, rsvp: rsvp1, event_session: @session2, checked_in: true)

attendee2 = create(:user)
rsvp2 = create(:rsvp, event: @event, user: attendee2, role: Role::VOLUNTEER)
create(:rsvp_session, rsvp: rsvp2, event_session: @session1, checked_in: true)
create(:rsvp_session, rsvp: rsvp2, event_session: @session2, checked_in: false)

attendee3 = create(:user)
rsvp3 = create(:rsvp, event: @event, user: attendee3, role: Role::VOLUNTEER)
create(:rsvp_session, rsvp: rsvp3, event_session: @session1, checked_in: true)
end

it "sends checked in user counts to the view" do
make_request
assigns(:session_rsvp_counts).should == {
@session1.id => 3,
@session2.id => 2
}
assigns(:session_checkin_counts).should == {
@session1.id => 3,
@session2.id => 1
}
end
end
end
end

Expand Down
4 changes: 1 addition & 3 deletions spec/factories.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@
time_zone "Hawaii"

factory :event do
event_sessions {
Array(1..4).sample.times.map { create(:event_session) }
}
event_sessions { [create(:event_session)] }
end
end

Expand Down

0 comments on commit a1349ea

Please sign in to comment.