Initial Commit

This commit is contained in:
Jason Katz
2011-06-14 18:08:28 -07:00
commit 5a34ac406c
172 changed files with 18457 additions and 0 deletions

View File

@@ -0,0 +1,10 @@
# Filters added to this controller apply to all controllers in the application.
# Likewise, all the methods added will be available for all controllers.
class ApplicationController < ActionController::Base
helper :all # include all helpers, all the time
protect_from_forgery # See ActionController::RequestForgeryProtection for details
# Scrub sensitive parameters from your log
# filter_parameter_logging :password
end

View File

@@ -0,0 +1,90 @@
class AssetsController < ApplicationController
before_filter :authenticate_user!
INDEX_SORT = SortIndex::Config.new(
{'updated_at' => 'updated_at'},
{'tag' => 'tag', 'name' => 'name', 'make' => 'make', 'model' => 'model', 'serial' => 'serial', 'category' => 'category',
'warranty' => 'warranty', 'location' => 'location', 'assigned' => 'assigned', 'status' => 'status', 'updated' => 'updated'}
)
# GET /assets
# GET /assets.xml
def index
@sortable = SortIndex::Sortable.new(params, INDEX_SORT)
@assets = Asset.find(:all, :order => (params[:sort_by] || "TRIM(LOWER(tag))") + " " + (params[:sort_direction] || "asc"))
# @assets.sort! {|x,y| x.tag.to_i <=> y.tag.to_i }
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @assets }
end
end
# GET /assets/1
# GET /assets/1.xml
def show
@asset = Asset.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @asset }
end
end
# GET /assets/new
# GET /assets/new.xml
def new
@asset = Asset.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @asset }
end
end
# GET /assets/1/edit
def edit
@asset = Asset.find(params[:id])
end
# POST /assets
# POST /assets.xml
def create
@asset = Asset.new(params[:asset])
respond_to do |format|
if @asset.save
format.html { redirect_to(@asset, :notice => 'Asset was successfully created.') }
format.xml { render :xml => @asset, :status => :created, :location => @asset }
else
format.html { render :action => "new" }
format.xml { render :xml => @asset.errors, :status => :unprocessable_entity }
end
end
end
# PUT /assets/1
# PUT /assets/1.xml
def update
@asset = Asset.find(params[:id])
respond_to do |format|
if @asset.update_attributes(params[:asset])
format.html { redirect_to(@asset, :notice => 'Asset was successfully updated.') }
format.xml { head :ok }
else
format.html { render :action => "edit" }
format.xml { render :xml => @asset.errors, :status => :unprocessable_entity }
end
end
end
# DELETE /assets/1
# DELETE /assets/1.xml
def destroy
@asset = Asset.find(params[:id])
@asset.destroy
respond_to do |format|
format.html { redirect_to(assets_url) }
format.xml { head :ok }
end
end
end

View File

@@ -0,0 +1,8 @@
class CommentsController < ApplicationController
def create
@asset = Asset.find(params[:asset_id])
params[:comment][:commenter] = current_user.name
@comment = @asset.comments.create!(params[:comment])
redirect_to @asset
end
end

View File

@@ -0,0 +1,93 @@
class SoftwaresController < ApplicationController
before_filter :authenticate_user!
INDEX_SORT = SortIndex::Config.new(
{'updated_at' => 'updated_at'},
{'company' => 'company', 'version' => 'version', 'key' => 'key', 'platform' => 'platform', 'media_location' => 'media_location', 'asset_id' => 'asset_id', 'installed' => 'installed', 'installed_by' => 'installed_by', 'modified' => 'modified', 'modified_by' => 'modified_by', 'note' => 'note'}
)
# GET /softwares
# GET /softwares.xml
def index
@sortable = SortIndex::Sortable.new(params, INDEX_SORT)
@softwares = Software.find(:all, :order => (params[:sort_by] || "TRIM(LOWER(company))") + " " + (params[:sort_direction] || "asc"))
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @softwares }
end
end
# GET /softwares/1
# GET /softwares/1.xml
def show
@software = Software.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @software }
end
end
# GET /softwares/new
# GET /softwares/new.xml
def new
@assets = Asset.all
@software = Software.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @software }
end
end
# GET /softwares/1/edit
def edit
@assets = Asset.all()
@software = Software.find(params[:id])
end
# POST /softwares
# POST /softwares.xml
def create
@software = Software.new(params[:software])
@software.modified_by = current_user.name
logger.debug @software
respond_to do |format|
if @software.save
format.html { redirect_to(@software, :notice => 'Software was successfully created.') }
format.xml { render :xml => @software, :status => :created, :location => @software }
else
format.html { render :action => "new" }
format.xml { render :xml => @software.errors, :status => :unprocessable_entity }
end
end
end
# PUT /softwares/1
# PUT /softwares/1.xml
def update
@software = Software.find(params[:id])
@software.modified_by = current_user.name
respond_to do |format|
if @software.update_attributes(params[:software])
format.html { redirect_to(@software, :notice => 'Software was successfully updated.') }
format.xml { head :ok }
else
format.html { render :action => "edit" }
format.xml { render :xml => @software.errors, :status => :unprocessable_entity }
end
end
end
# DELETE /softwares/1
# DELETE /softwares/1.xml
def destroy
@software = Software.find(params[:id])
@software.destroy
respond_to do |format|
format.html { redirect_to(softwares_url) }
format.xml { head :ok }
end
end
end