-
Notifications
You must be signed in to change notification settings - Fork 0
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
Showing
14 changed files
with
157 additions
and
4 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,3 @@ | ||
# Place all the behaviors and hooks related to the matching controller here. | ||
# All this logic will automatically be available in application.js. | ||
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/ |
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,3 @@ | ||
// Place all the styles related to the admin/events controller here. | ||
// They will automatically be included in application.css. | ||
// You can use Sass (SCSS) here: http://sass-lang.com/ |
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,41 @@ | ||
class Admin::EventsController < ApplicationController | ||
|
||
before_filter :load_event, :except => [:index, :new, :create] | ||
respond_to :html | ||
|
||
def index | ||
@events = Event.all | ||
end | ||
|
||
def edit | ||
|
||
end | ||
|
||
def new | ||
@event = Event.new | ||
end | ||
|
||
def update | ||
if @event.update_attributes(params[:event]) | ||
redirect_to admin_events_path, :flash => { :info => "Event saved" } | ||
else | ||
render :action => :edit | ||
end | ||
end | ||
|
||
def create | ||
@event = Event.new(params[:event]) | ||
if @event.save | ||
redirect_to admin_events_path, :flash => { :info => "Event created" } | ||
else | ||
render :action => :edit | ||
end | ||
end | ||
|
||
protected | ||
|
||
def load_event | ||
@event = Event.find params[:id] | ||
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 @@ | ||
module Admin::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,15 @@ | ||
<%= semantic_form_for [:admin, @event] do |f| %> | ||
<%= f.inputs do %> | ||
<%= f.input :title %> | ||
<%= f.input :content %> | ||
<%= f.input :status %> | ||
<%= f.input :scheduled_at %> | ||
<% end %> | ||
<%= f.buttons do %> | ||
<%= f.commit_button 'Save' %> | ||
<% 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,5 @@ | ||
<h1>Edit event</h1> | ||
|
||
<%= render :partial => "form" %> | ||
|
||
|
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,24 @@ | ||
<h1>Events</h1> | ||
|
||
<%= link_to "Add new event", new_admin_event_path %> | ||
<% if @events.size > 0 %> | ||
<table> | ||
<thead> | ||
<th>Title</th> | ||
<th>Status</th> | ||
<th>Scheduled at</th> | ||
<th>Resolved?</th> | ||
</thead> | ||
<tbody> | ||
<% @events.each do |event| %> | ||
<tr> | ||
<td><%= link_to event.title, edit_admin_event_path(event) %></td> | ||
<td><%= event.status.try(:name) %></td> | ||
<td><%= event.scheduled_at %></td> | ||
<td><%= event.resolved? ? "Y" : "N" %></td> | ||
</tr> | ||
<% end %> | ||
</tbody> | ||
</table> | ||
<% 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,5 @@ | ||
<h1>New event</h1> | ||
|
||
<%= render :partial => "form" %> | ||
|
||
|
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
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,30 @@ | ||
Given /^there are events within the system$/ do | ||
#@events = Event.all | ||
@status = a_saved Status, :name => "test_status", :colour => "ff0000" | ||
@event = a_saved Event, :title => "test_event", :content => "test content", :status => @status | ||
end | ||
|
||
When /^I add an event$/ do | ||
visit '/admin/events' | ||
click_link 'Add new event' | ||
fill_in 'event_title', :with => "My title" | ||
fill_in 'event_content', :with => "My content" | ||
select('test_status', :from => 'event_status_id') | ||
click_button("Save") | ||
end | ||
|
||
|
||
Then /^I should see the message "([^"]*)"$/ do |arg1| | ||
page.should have_content(arg1) | ||
#pending # express the regexp above with the code you wish you had | ||
end | ||
|
||
When /^I save the event$/ do | ||
visit '/admin/events' | ||
click_link 'test_event' | ||
fill_in 'event_title', :with => "My new title" | ||
fill_in 'event_content', :with => "My new content" | ||
#select('test_status', :from => 'event_status_id') | ||
click_button("Save") | ||
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,5 @@ | ||
require 'spec_helper' | ||
|
||
describe Admin::EventsController do | ||
|
||
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,15 @@ | ||
require 'spec_helper' | ||
|
||
# Specs in this file have access to a helper object that includes | ||
# the Admin::EventsHelper. For example: | ||
# | ||
# describe Admin::EventsHelper do | ||
# describe "string concat" do | ||
# it "concats two strings with spaces" do | ||
# helper.concat_strings("this","that").should == "this that" | ||
# end | ||
# end | ||
# end | ||
describe Admin::EventsHelper do | ||
pending "add some examples to (or delete) #{__FILE__}" | ||
end |