Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Tweaks and fixes, mostly to events
  • Loading branch information
Jason L Perry committed Mar 14, 2009
1 parent 808b0d4 commit 8cfaa3c
Show file tree
Hide file tree
Showing 11 changed files with 64 additions and 9 deletions.
2 changes: 1 addition & 1 deletion app/controllers/registrations_controller.rb
Expand Up @@ -4,7 +4,7 @@ class RegistrationsController < ApplicationController
# GET /registrations/1
# GET /registrations/1.xml
def show
@registration = @event.registrations.find(params[:id])
@registration = @event.registrations.find(params[:id], :order => "created_at ASC")

respond_to do |format|
format.html # show.html.erb
Expand Down
10 changes: 10 additions & 0 deletions app/helpers/registrations_helper.rb
@@ -1,2 +1,12 @@
module RegistrationsHelper

def available_character_options
options = current_user.characters.map { |c| [c.name, c.id] }
if current_user.officer?
options << ["--", nil]
options += Character.all.map { |c| [c.name, c.id] }
end
options
end

end
12 changes: 9 additions & 3 deletions app/models/event.rb
Expand Up @@ -12,10 +12,16 @@ def title
end

def loot_council_url
characters = CGI::escape(registrations.accepted.map { |r| r.character.name }.join(" "))
raid_name = raid ? CGI::escape(raid.title) : ""
characters = CGI::escape(
registrations.accepted.map {
|registration| registration.character.name
}.join(" ")
)
raid_name = raid ? CGI::escape(raid.title) : ""

"http://loot-council.appspot.com/lootcouncil?characters=#{characters}&realm=The+Forgotten+Coast&region=us&site=Wowhead&raid=#{raid_name}&difficulty=Normal"
return "http://loot-council.appspot.com/lootcouncil?characters="
+ characters + "&realm=The+Forgotten+Coast&region=us&site=Wowhead&raid="
+ raid_name + "&difficulty=Normal"
end

end
6 changes: 5 additions & 1 deletion app/models/post.rb
Expand Up @@ -3,7 +3,11 @@ class Post < ActiveRecord::Observer

def after_create(post)
User.notifiable_by_email(post).each do |user|
Notification.deliver_post(post, user)
begin
Notification.deliver_post(post, user)
rescue Net::ProtocolError => e
# do nothing
end
end
end

Expand Down
1 change: 1 addition & 0 deletions app/views/events/index.html.erb
Expand Up @@ -2,6 +2,7 @@
<div class="event section index">
<div class="details">
<%= event.description %>
(<%= event.registrations.accepted.count %> of <%= event.raid.roster_size %> accepted)
<%= event.begins_at.strftime("%a, %b %d @ %I:%m %p") %>
<span class="note">(<%= distance_of_time_in_words_to_now(event.begins_at) %> <%= event.begins_at > Time.now ? "from now" : "ago" %>)</span>
</div>
Expand Down
6 changes: 5 additions & 1 deletion app/views/events/show.html.erb
Expand Up @@ -15,12 +15,16 @@
<table>
<tr>
<th>Player</th>
<th>Role</th>
<th>Status</th>
</tr>
<% unless @event.registrations.empty? %>
<% for registration in @event.registrations.all(:include => :character, :order => "status ASC, characters.name ASC") %>
<tr>
<td><%= armory_link(registration.character) %></td>
<td><%= link_to registration.character.name,
registration.character,
:class => registration.character.character_class %></td>
<td><%= registration.role %></td>
<td class="<%= registration.status %>"><%= link_to_if (current_user.officer? || registration.character.user == current_user), registration.status.titleize, edit_event_registration_path(@event, registration) %></td>
</tr>
<% end %>
Expand Down
6 changes: 5 additions & 1 deletion app/views/registrations/edit.html.erb
Expand Up @@ -10,7 +10,11 @@
</p>
<p>
<%= f.label :character_id %><br />
<%= f.select :character_id, current_user.characters.map { |c| [c.name, c.id] } %>
<%= f.select :character_id, available_character_options %>
</p>
<p>
<%= f.label :role %><br />
<%= f.select :role, ["DPS", "Tank", "Healer"] %>
</p>
<p>
<%= f.submit "Register" %> <%= link_to "Cancel", @event %>
Expand Down
6 changes: 5 additions & 1 deletion app/views/registrations/new.html.erb
Expand Up @@ -10,7 +10,11 @@
</p>
<p>
<%= f.label :character_id %><br />
<%= f.select :character_id, current_user.characters.map { |c| [c.name, c.id] } %>
<%= f.select :character_id, available_character_options, :selected => "" %>
</p>
<p>
<%= f.label :role %><br />
<%= f.select :role, ["DPS", "Tank", "Healer"] %>
</p>
<p>
<%= f.submit "Register" %> <%= link_to "Cancel", @event %>
Expand Down
12 changes: 12 additions & 0 deletions app/views/users/show.html.erb
Expand Up @@ -18,4 +18,16 @@
<% end %>
</ul>

<%- if current_user.officer? -%>

<p>
<b>Open ID:</b>
<%=h @user.identity_url %>
</p>

<p>
<%= link_to 'Destroy', @user, :confirm => 'Are you sure?', :method => :delete %>
</p>

<%- end -%>
</div>
9 changes: 9 additions & 0 deletions db/migrate/20090314174746_add_role_to_registrations.rb
@@ -0,0 +1,9 @@
class AddRoleToRegistrations < ActiveRecord::Migration
def self.up
add_column :registrations, :role, :string
end

def self.down
remove_column :registrations, :role
end
end
3 changes: 2 additions & 1 deletion db/schema.rb
Expand Up @@ -9,7 +9,7 @@
#
# It's strongly recommended to check this file into your version control system.

ActiveRecord::Schema.define(:version => 20090226081438) do
ActiveRecord::Schema.define(:version => 20090314174746) do

create_table "characters", :force => true do |t|
t.integer "user_id"
Expand Down Expand Up @@ -58,6 +58,7 @@
t.integer "event_id"
t.datetime "created_at"
t.datetime "updated_at"
t.string "role"
end

create_table "replies", :force => true do |t|
Expand Down

0 comments on commit 8cfaa3c

Please sign in to comment.