Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Jason L Perry
committed
Feb 24, 2009
1 parent
4b4c071
commit 113f397
Showing
28 changed files
with
2,248 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
class EventsController < ApplicationController | ||
# GET /events | ||
# GET /events.xml | ||
def index | ||
@events = Event.all :order => "begins_at ASC", | ||
:conditions => ["begins_at > ?", Time.now], | ||
:include => :raid | ||
respond_to do |format| | ||
format.html # index.html.erb | ||
format.xml { render :xml => @events } | ||
end | ||
end | ||
|
||
# GET /events/1 | ||
# GET /events/1.xml | ||
def show | ||
@event = Event.find(params[:id]) | ||
|
||
respond_to do |format| | ||
format.html # show.html.erb | ||
format.xml { render :xml => @event } | ||
end | ||
end | ||
|
||
# GET /events/new | ||
# GET /events/new.xml | ||
def new | ||
@event = Event.new | ||
|
||
respond_to do |format| | ||
format.html # new.html.erb | ||
format.xml { render :xml => @event } | ||
end | ||
end | ||
|
||
# GET /events/1/edit | ||
def edit | ||
@event = Event.find(params[:id]) | ||
end | ||
|
||
# POST /events | ||
# POST /events.xml | ||
def create | ||
@event = Event.new(params[:event]) | ||
|
||
respond_to do |format| | ||
if @event.save | ||
flash[:notice] = 'Event was successfully created.' | ||
format.html { redirect_to(@event) } | ||
format.xml { render :xml => @event, :status => :created, :location => @event } | ||
else | ||
format.html { render :action => "new" } | ||
format.xml { render :xml => @event.errors, :status => :unprocessable_entity } | ||
end | ||
end | ||
end | ||
|
||
# PUT /events/1 | ||
# PUT /events/1.xml | ||
def update | ||
@event = Event.find(params[:id]) | ||
|
||
respond_to do |format| | ||
if @event.update_attributes(params[:event]) | ||
flash[:notice] = 'Event was successfully updated.' | ||
format.html { redirect_to(@event) } | ||
format.xml { head :ok } | ||
else | ||
format.html { render :action => "edit" } | ||
format.xml { render :xml => @event.errors, :status => :unprocessable_entity } | ||
end | ||
end | ||
end | ||
|
||
# DELETE /events/1 | ||
# DELETE /events/1.xml | ||
def destroy | ||
@event = Event.find(params[:id]) | ||
@event.destroy | ||
|
||
respond_to do |format| | ||
format.html { redirect_to(events_url) } | ||
format.xml { head :ok } | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
module EventsHelper | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
class Event < ActiveRecord::Base | ||
belongs_to :raid | ||
|
||
def title | ||
if self[:title].blank? | ||
raid ? raid.title : "Untitled Event" | ||
else | ||
self[:title] | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
class Raid < ActiveRecord::Base | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<div class="section"> | ||
|
||
<h2>Edit Event</h2> | ||
|
||
<% form_for(@event) do |f| %> | ||
<%= f.error_messages %> | ||
|
||
<p> | ||
<%= f.label :raid_id, "Raid" %><br /> | ||
<%= f.collection_select(:raid_id, Raid.all, :id, :title, {:include_blank => true}) | ||
%> | ||
</p> | ||
|
||
<p> | ||
<%= f.label :title %> <span class="note">(Optional)</span><br /> | ||
<%= f.text_field :title %> | ||
</p> | ||
|
||
<p> | ||
<%= f.label :description %><br /> | ||
<%= f.text_area :description %> | ||
</p> | ||
|
||
<p> | ||
<%= f.label :begins_at %><br /> | ||
<%= f.datetime_select :ends_at %> | ||
</p | ||
|
||
<p> | ||
<%= f.label :begins_at %><br /> | ||
<%= f.datetime_select :ends_at %> | ||
</p | ||
|
||
<p> | ||
<%= f.submit "Update" %> <%= link_to "Cancel", event_path(@event) %> | ||
</p> | ||
<% end %> | ||
|
||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<%- for event in @events -%> | ||
<div class="event section index"> | ||
<div class="details"> | ||
<%= event.description %> | ||
<%= 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> | ||
|
||
<h2><%= link_to h(event.title), event %></h2> | ||
</div> | ||
<%- end -%> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,209 @@ | ||
<div class="section"> | ||
|
||
<h2>New Event</h2> | ||
|
||
<% form_for(@event) do |f| %> | ||
<%= f.error_messages %> | ||
|
||
<p> | ||
<%= f.label :raid_id, "Raid" %><br /> | ||
<%= f.collection_select(:raid_id, Raid.all, :id, :title, {:include_blank => true}) | ||
%> | ||
</p> | ||
|
||
<p> | ||
<%= f.label :title %> <span class="note">(Optional)</span><br /> | ||
<%= f.text_field :title %> | ||
</p> | ||
|
||
<p> | ||
<%= f.label :description %><br /> | ||
<%= f.text_area :description %> | ||
</p> | ||
|
||
<p> | ||
<%= f.label :begins_at %><br /> | ||
<select class="split-date" id="event_begins_at" name="event[begins_at(1i)]" style="display:none"> | ||
<option value=""></option> | ||
<option value="2009">2009</option> | ||
</select> | ||
<select id="event_begins_at-mm" name="event[begins_at(2i)]"> | ||
<option value=""></option> | ||
<option value="1">January</option> | ||
<option value="2">February</option> | ||
<option value="3">March</option> | ||
<option value="4">April</option> | ||
<option value="5">May</option> | ||
<option value="6">June</option> | ||
<option value="7">July</option> | ||
<option value="8">August</option> | ||
<option value="9">September</option> | ||
<option value="10">October</option> | ||
<option value="11">November</option> | ||
<option value="12">December</option> | ||
</select> | ||
<select id="event_begins_at-dd" name="event[begins_at(3i)]"> | ||
<option value=""></option> | ||
<option value="1">1</option> | ||
<option value="2">2</option> | ||
<option value="3">3</option> | ||
<option value="4">4</option> | ||
<option value="5">5</option> | ||
<option value="6">6</option> | ||
<option value="7">7</option> | ||
<option value="8">8</option> | ||
<option value="9">9</option> | ||
<option value="10">10</option> | ||
<option value="11">11</option> | ||
<option value="12">12</option> | ||
<option value="13">13</option> | ||
<option value="14">14</option> | ||
<option value="15">15</option> | ||
<option value="16">16</option> | ||
<option value="17">17</option> | ||
<option value="18">18</option> | ||
<option value="19">19</option> | ||
<option value="20">20</option> | ||
<option value="21">21</option> | ||
<option value="22">22</option> | ||
<option value="23">23</option> | ||
<option value="24">24</option> | ||
<option value="25">25</option> | ||
<option value="26">26</option> | ||
<option value="27">27</option> | ||
<option value="28">28</option> | ||
<option value="29">29</option> | ||
<option value="30">30</option> | ||
<option value="31">31</option> | ||
</select> — | ||
<select id="event_begins_at_4i" name="event[begins_at(4i)]"> | ||
<option value="00">12 AM</option> | ||
<option value="01">01 AM</option> | ||
<option value="02">02 AM</option> | ||
<option value="03">03 AM</option> | ||
<option value="04">04 AM</option> | ||
<option value="05">05 AM</option> | ||
<option value="06">06 AM</option> | ||
<option value="07">07 AM</option> | ||
<option value="08">08 AM</option> | ||
<option value="09">09 AM</option> | ||
<option value="10">10 AM</option> | ||
<option value="11">11 AM</option> | ||
<option value="12">12 PM</option> | ||
<option value="13">01 PM</option> | ||
<option value="14">02 PM</option> | ||
<option value="15">03 PM</option> | ||
<option value="16">04 PM</option> | ||
<option value="17">05 PM</option> | ||
<option value="18">06 PM</option> | ||
<option selected="selected" value="19">07 PM</option> | ||
<option value="20">08 PM</option> | ||
<option value="21">09 PM</option> | ||
<option value="22">10 PM</option> | ||
<option value="23">11 PM</option> | ||
</select> : | ||
<select id="event_begins_at_5i" name="event[begins_at(5i)]"> | ||
<option value="00">00</option> | ||
<option value="15">15</option> | ||
<option value="30">30</option> | ||
<option value="45">45</option> | ||
</select> | ||
</p> | ||
|
||
<p> | ||
<%= f.label :ends_at %><br /> | ||
<select class="split-date" id="event_ends_at" name="event[ends_at(1i)]" style="display:none"> | ||
<option value=""></option> | ||
<option value="2009">2009</option> | ||
</select> | ||
<select id="event_ends_at-mm" name="event[ends_at(2i)]"> | ||
<option value=""></option> | ||
<option value="1">January</option> | ||
<option value="2">February</option> | ||
<option value="3">March</option> | ||
<option value="4">April</option> | ||
<option value="5">May</option> | ||
<option value="6">June</option> | ||
<option value="7">July</option> | ||
<option value="8">August</option> | ||
<option value="9">September</option> | ||
<option value="10">October</option> | ||
<option value="11">November</option> | ||
<option value="12">December</option> | ||
</select> | ||
<select id="event_ends_at-dd" name="event[ends_at(3i)]"> | ||
<option value=""></option> | ||
<option value="1">1</option> | ||
<option value="2">2</option> | ||
<option value="3">3</option> | ||
<option value="4">4</option> | ||
<option value="5">5</option> | ||
<option value="6">6</option> | ||
<option value="7">7</option> | ||
<option value="8">8</option> | ||
<option value="9">9</option> | ||
<option value="10">10</option> | ||
<option value="11">11</option> | ||
<option value="12">12</option> | ||
<option value="13">13</option> | ||
<option value="14">14</option> | ||
<option value="15">15</option> | ||
<option value="16">16</option> | ||
<option value="17">17</option> | ||
<option value="18">18</option> | ||
<option value="19">19</option> | ||
<option value="20">20</option> | ||
<option value="21">21</option> | ||
<option value="22">22</option> | ||
<option value="23">23</option> | ||
<option value="24">24</option> | ||
<option value="25">25</option> | ||
<option value="26">26</option> | ||
<option value="27">27</option> | ||
<option value="28">28</option> | ||
<option value="29">29</option> | ||
<option value="30">30</option> | ||
<option value="31">31</option> | ||
</select> — | ||
<select id="event_ends_at_4i" name="event[ends_at(4i)]"> | ||
<option value=""></option> | ||
<option value="00">12 AM</option> | ||
<option value="01">01 AM</option> | ||
<option value="02">02 AM</option> | ||
<option value="03">03 AM</option> | ||
<option value="04">04 AM</option> | ||
<option value="05">05 AM</option> | ||
<option value="06">06 AM</option> | ||
<option value="07">07 AM</option> | ||
<option value="08">08 AM</option> | ||
<option value="09">09 AM</option> | ||
<option value="10">10 AM</option> | ||
<option value="11">11 AM</option> | ||
<option value="12">12 PM</option> | ||
<option value="13">01 PM</option> | ||
<option value="14">02 PM</option> | ||
<option value="15">03 PM</option> | ||
<option value="16">04 PM</option> | ||
<option value="17">05 PM</option> | ||
<option value="18">06 PM</option> | ||
<option value="19">07 PM</option> | ||
<option value="20">08 PM</option> | ||
<option value="21">09 PM</option> | ||
<option value="22">10 PM</option> | ||
<option value="23">11 PM</option> | ||
</select> : | ||
<select id="event_ends_at_5i" name="event[ends_at(5i)]"> | ||
<option value=""></option> | ||
<option value="00">00</option> | ||
<option value="15">15</option> | ||
<option value="30">30</option> | ||
<option value="45">45</option> | ||
</select> | ||
</p> | ||
|
||
<p> | ||
<%= f.submit "Create" %> <%= link_to "Cancel", events_path %> | ||
</p> | ||
<% end %> | ||
|
||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<div class="event section"> | ||
|
||
<h2><%= @event.title %></h2> | ||
|
||
<div class="time"> | ||
<%= @event.begins_at.strftime("<strong>%A</strong>, %b %d @ %I:%m %p") %> | ||
— <%= @event.ends_at ? @event.ends_at.strftime("%I:%m %p") : "?" %> | ||
</div> | ||
|
||
<div class="body"> | ||
<%= textilize auto_link(h(@event.description)) %> | ||
</div> | ||
|
||
<p class="navigation"> | ||
<%= link_to "Edit", edit_event_path(@event) if current_user.officer? %> | ||
</p> | ||
|
||
</div> |
Oops, something went wrong.