Skip to content
This repository has been archived by the owner on Nov 16, 2017. It is now read-only.

Commit

Permalink
I think I've gotten things working again now
Browse files Browse the repository at this point in the history
  • Loading branch information
sdague committed May 9, 2008
1 parent 42e4df0 commit dd13fad
Show file tree
Hide file tree
Showing 8 changed files with 73 additions and 67 deletions.
2 changes: 2 additions & 0 deletions app/controllers/events_controller.rb
Expand Up @@ -30,6 +30,7 @@ def show
# GET /events/new.xml
def new
@event = Event.new
@locations = current_user.locations

respond_to do |format|
format.html # new.html.erb
Expand All @@ -40,6 +41,7 @@ def new
# GET /events/1/edit
def edit
@event = current_user.events.find(params[:id])
@locations = current_user.locations
end

# POST /events
Expand Down
49 changes: 0 additions & 49 deletions app/helpers/invite_helper.rb
Expand Up @@ -5,55 +5,6 @@ def address(location)

end

def yes_list()
list_by_state("yes")
end

def no_list()
list_by_state("no")
end

def maybe_list()
list_by_state("maybe")
end

def na_list()
list_by_state("na")
end

def yes_number()
number_by_state("yes")
end

def no_number()
number_by_state("no")
end

def maybe_number()
number_by_state("maybe")
end

def na_number()
number_by_state("na")
end

def number_by_state(state)
rsvps = Rsvp.find(:all, :conditions => ["state = ?", state])
count = 0
rsvps.each do |r|
count += (r.num or 1)
end
return count
end

def list_by_state(state)
if state == "na"
return Rsvp.find(:all, :conditions => ["state = ?", state]).sort_by {|s| s.person.email }
else
return Rsvp.find(:all, :conditions => ["state = ?", state]).sort_by {|s| s.updated_at }
end
end

def format_invitee_admin(r)
date = ""
if r.visited_at
Expand Down
50 changes: 50 additions & 0 deletions app/models/event.rb
Expand Up @@ -2,4 +2,54 @@ class Event < ActiveRecord::Base
has_many :rsvps
belongs_to :location
belongs_to :user

def yes_list
list_by_state("yes")
end

def no_list
list_by_state("no")
end

def maybe_list
list_by_state("maybe")
end

def na_list
list_by_state("na")
end

def yes_number
number_by_state("yes")
end

def no_number
number_by_state("no")
end

def maybe_number
number_by_state("maybe")
end

def na_number
number_by_state("na")
end

def number_by_state(state)
rs = rsvps.find(:all, :conditions => ["state = ?", state])
count = 0
rs.each do |r|
count += (r.num or 1)
end
return count
end

def list_by_state(state)
if state == "na"
return rsvps.find(:all, :conditions => ["state = ?", state]).sort_by {|s| s.person.email }
else
return rsvps.find(:all, :conditions => ["state = ?", state]).sort_by {|s| s.updated_at }
end
end

end
3 changes: 2 additions & 1 deletion app/views/events/edit.html.erb
Expand Up @@ -30,7 +30,8 @@

<p>
<b>Location</b><br />
<%= f.text_field :location_id %>
<%= collection_select("event", "location_id", @locations, "id", "name") %>

</p>

<p>
Expand Down
1 change: 1 addition & 0 deletions app/views/events/index.html.erb
Expand Up @@ -28,3 +28,4 @@
<br />

<%= link_to 'New event', new_event_path %>
<%= link_to 'New location', new_location_path %>
3 changes: 2 additions & 1 deletion app/views/events/new.html.erb
Expand Up @@ -30,7 +30,8 @@

<p>
<b>Location</b><br />
<%= f.text_field :location_id %>
<%= collection_select("event", "location_id", @locations, "id", "name") %>

</p>

<p>
Expand Down
16 changes: 8 additions & 8 deletions app/views/events/show.html.erb
Expand Up @@ -28,24 +28,24 @@

<table width="100%">
<tr><th width="200">Name</th><th width="200">Last Visited</th><th width="50">Number</th><th>Message</th></tr>
<tr><td class="attend_yes" colspan=5>Will Attend - <%= yes_number %></th></tr>
<% yes_list.each do |r| %>
<tr><td class="attend_yes" colspan=5>Will Attend - <%= @event.yes_number %></th></tr>
<% @event.yes_list.each do |r| %>
<%= format_invitee_admin(r) %>
<% end %>

<tr><td class="attend_maybe" colspan=5>May Attend - <%= maybe_number %></th></tr>
<tr><td class="attend_maybe" colspan=5>May Attend - <%= @event.maybe_number %></th></tr>

<% maybe_list.each do |r| %>
<% @event.maybe_list.each do |r| %>
<%= format_invitee_admin(r) %>
<% end %>

<tr><td class="attend_no" colspan=5>Won't Attend - <%= no_number %></th></tr>
<% no_list.each do |r| %>
<tr><td class="attend_no" colspan=5>Won't Attend - <%= @event.no_number %></th></tr>
<% @event.no_list.each do |r| %>
<%= format_invitee_admin(r) %>
<% end %>

<tr><td class="attend_na" colspan=5>Haven't Responded - <%= na_number %></th></tr>
<% na_list.each do |r| %>
<tr><td class="attend_na" colspan=5>Haven't Responded - <%= @event.na_number %></th></tr>
<% @event.na_list.each do |r| %>
<%= format_invitee_admin(r) %>
<% end %>
</table>
Expand Down
16 changes: 8 additions & 8 deletions app/views/invite/show.html.erb
Expand Up @@ -45,24 +45,24 @@ Click the Map to Get Directions
<h1>Who's coming?</h1>
<table width="100%">
<tr><th width="300">Name</th><th width="100">Number</th><th>Message</th></tr>
<tr><td class="attend_yes" colspan=3>Will Attend - <%= yes_number %></th></tr>
<% yes_list.each do |r| %>
<tr><td class="attend_yes" colspan=3>Will Attend - <%= @rsvp.event.yes_number %></th></tr>
<% @rsvp.event.yes_list.each do |r| %>
<%= format_invitee(r) %>
<% end %>

<tr><td class="attend_maybe" colspan=3>May Attend - <%= maybe_number %></th></tr>
<tr><td class="attend_maybe" colspan=3>May Attend - <%= @rsvp.event.maybe_number %></th></tr>

<% maybe_list.each do |r| %>
<% @rsvp.event.maybe_list.each do |r| %>
<%= format_invitee(r) %>
<% end %>

<tr><td class="attend_no" colspan=3>Won't Attend - <%= no_number %></th></tr>
<% no_list.each do |r| %>
<tr><td class="attend_no" colspan=3>Won't Attend - <%= @rsvp.event.no_number %></th></tr>
<% @rsvp.event.no_list.each do |r| %>
<%= format_invitee(r) %>
<% end %>

<tr><td class="attend_na" colspan=3>Haven't Responded - <%= na_number %></th></tr>
<% na_list.each do |r| %>
<tr><td class="attend_na" colspan=3>Haven't Responded - <%= @rsvp.event.na_number %></th></tr>
<% @rsvp.event.na_list.each do |r| %>
<%= format_invitee(r) %>
<% end %>
</table>
Expand Down

0 comments on commit dd13fad

Please sign in to comment.