removing specific help category, the wiki will do this just fine

git-svn-id: http://svn.barleysodas.com/barleysodas/trunk@91 0f7b21a7-9e3a-4941-bbeb-ce5c7c368fa7
master
andrew 2008-01-09 06:20:19 +00:00
parent 449c00ab55
commit a487ca60dc
10 changed files with 3 additions and 211 deletions

View File

@ -92,15 +92,9 @@ class ApplicationController < ActionController::Base
]
cond_var = {
:model_title => tfu,
:help_owner_type => 'Help'
}
# specific overrides for help, this has an owner type but it is just a Page
if obj_type == 'help'
cond_ary << 'owner_type = :help_owner_type'
obj_type = 'pages'
elsif obj_type == 'pages'
cond_ary << 'owner_type IS NULL'
end
cond_ary << 'owner_type IS NULL' if obj_type == 'pages'
# the eventual name of the instance variable, like +@page+
obj_name = obj_type.singularize

View File

@ -1,98 +0,0 @@
class HelpController < ApplicationController
append_before_filter :fetch_model,
:only => [ :show, :edit, :update, :destroy ]
# GET /help
# GET /help.xml
def index
@page = Page.find_by_title_and_owner_type 'HomePage', 'Help'
@content_title = 'BarleySodas Help'
@secondary_title = ''
@tags = Page.tags(:limit => 25, :order => 'name DESC',
:owner_type => 'Help')
end
# GET /help/1
# GET /help/1.xml
def show
@secondary_title = ''
respond_to do |format|
format.html # show.rhtml
format.xml { render :xml => @page.to_xml }
end
end
# GET /help/new
def new
@page = Page.new
@page.title = params[:new_title] if params[:new_title]
@secondary_title = 'Creating help page'
end
# GET /help/1;edit
def edit
@secondary_title = 'Updating help page'
end
# POST /help
# POST /help.xml
def create
@page = Page.new(params[:page])
@page.owner_type = 'Help'
respond_to do |format|
if @page.save
flash[:notice] = 'Help was successfully created.'
format.html {
if @page.title == 'HomePage'
redirect_to :controller => 'help', :action => 'index'
else
redirect_to help_url({ :id => @page.title_for_url })
end
}
format.xml { head :created,
:location => help_url({ :id => @page.title_for_url }) }
else
format.html {
@secondary_title = 'Creating help page'
render :action => "new"
}
format.xml { render :xml => @page.errors.to_xml }
end
end
end
# PUT /help/1
# PUT /help/1.xml
def update
@page.attributes = params[:page]
respond_to do |format|
if @page.save
flash[:notice] = 'Help was successfully updated.'
format.html {
if @page.title == 'HomePage'
redirect_to :controller => 'help', :action => 'index'
else
redirect_to help_url({ :id => @page.title_for_url })
end
}
format.xml { head :ok }
else
format.html {
@secondary_title = 'Updating help page'
render :action => "edit"
}
format.xml { render :xml => @page.errors.to_xml, :status => 400 }
end
end
end
# DELETE /help/1
# DELETE /help/1.xml
def destroy
@page.destroy
respond_to do |format|
format.html { redirect_to :controller => 'help', :action => 'index' }
format.xml { head :ok }
end
end
end

View File

@ -1,11 +0,0 @@
module HelpHelper
def show_help_link(page, better_title = 'Show')
link_to better_title, help_path({ :id => page.title_for_url }),
{ :title => page.title }
end
def edit_help_link(page)
link_to 'Edit Help Page', edit_help_path({ :id => page.title_for_url }),
{ :title => "Edit Help Page #{page.title}" }
end
end

View File

@ -1,12 +0,0 @@
<%= error_messages_for :page %>
<% form_for(:help, :url => help_path({ :id => @page.title_for_url }), :html => { :method => :put }) do |f| %>
<%= render :partial => 'pages/page_form' %>
<p>
<%= submit_tag "Update" %>
</p>
<% end %>
<% content_for :sidebar do -%>
<%= show_help_link(@page) unless @page.title == 'HomePage' -%><br />
<% end -%>

View File

@ -1,6 +0,0 @@
<%= render :partial => 'pages/page' -%>
<% content_for :sidebar do -%>
<%= edit_help_link(@page) -%><br />
<%= render :partial => 'shared/tag_cloud' %>
<% end -%>

View File

@ -1,11 +0,0 @@
<%= error_messages_for :page %>
<% form_for(:help, :url => { :controller => 'help', :action => 'index' }, :html => { :method => :post }) do |f| %>
<p>
<label for="page_title">Title</label> <%= text_field 'page', 'title' %>
</p>
<%= render :partial => 'pages/page_form' %>
<p>
<%= submit_tag "Create" %>
</p>
<% end %>

View File

@ -1,6 +0,0 @@
<%= render :partial => 'pages/page' %>
<% content_for :sidebar do -%>
<%= edit_help_link(@page) -%><br />
<%= link_to 'Destroy', help_path(@page.title_for_url), :confirm => 'Are you sure?', :method => :delete unless @page.title == 'HomePage' -%><br />
<% end -%>

View File

@ -38,7 +38,6 @@
<%= link_to_unless_current 'Browse Breweries', breweries_path -%><br />
<%= link_to_unless_current 'BarleySodas People', peoples_path -%><br />
<% if has_permission_for_action?(:index, :roles) -%><%= link_to_unless_current 'Roles', roles_path -%><br /><% end -%>
<%= link_to_unless_current 'Help With BarleySodas', :controller => 'help', :action => 'index' -%><br />
<% unless logged_in? -%><%= link_to_unless_current 'Login', new_session_path -%><% else -%><%= link_to "Logout #{session[:people_title]}", session_path(:id => session[:people_title]), :method => :delete -%><% end %>
<hr />
<%= yield :sidebar %>

View File

@ -1,6 +1,6 @@
ActionController::Routing::Routes.draw do |map|
map.resources :beers, :breweries, :pages, :discussions, :peoples, :roles,
:sessions, :help, :styles
:sessions, :styles
map.connect ':controller/:action/:id.:format'
map.connect ':controller/:action/:id'

View File

@ -1,57 +0,0 @@
require File.dirname(__FILE__) + '/../test_helper'
require 'help_controller'
# Re-raise errors caught by the controller.
class HelpController; def rescue_action(e) raise e end; end
class HelpControllerTest < Test::Unit::TestCase
fixtures :help
def setup
@controller = HelpController.new
@request = ActionController::TestRequest.new
@response = ActionController::TestResponse.new
end
def test_should_get_index
get :index
assert_response :success
assert assigns(:helps)
end
def test_should_get_new
get :new
assert_response :success
end
def test_should_create_help
old_count = Help.count
post :create, :help => { }
assert_equal old_count+1, Help.count
assert_redirected_to help_path(assigns(:help))
end
def test_should_show_help
get :show, :id => 1
assert_response :success
end
def test_should_get_edit
get :edit, :id => 1
assert_response :success
end
def test_should_update_help
put :update, :id => 1, :help => { }
assert_redirected_to help_path(assigns(:help))
end
def test_should_destroy_help
old_count = Help.count
delete :destroy, :id => 1
assert_equal old_count-1, Help.count
assert_redirected_to helps_path
end
end