Class Hosting::ProjectsController
In: app/controllers/hosting/projects_controller.rb
Parent: ApplicationController

Methods

create   edit   index   list   new   show   sort   update  

Included Modules

Dsadmin::Contractor

Constants

SORTFIELDS = %w{id shortname name license}

Public Instance methods

[Source]

    # File app/controllers/hosting/projects_controller.rb, line 42
42:   def create
43:     @project = Project.new(params[:project])
44:     if @project.save
45:       flash[:notice] = 'Project info was successfully created.'
46: #      invalidate(params[:id])
47:       redirect_to :action => 'list'
48:     else
49:       render :action => 'new'
50:     end
51:   end

[Source]

    # File app/controllers/hosting/projects_controller.rb, line 54
54:   def edit
55:     @project = Project.find(params[:id])
56:   end

[Source]

    # File app/controllers/hosting/projects_controller.rb, line 22
22:   def index
23:     list
24:     render :action => 'list'
25:   end

[Source]

    # File app/controllers/hosting/projects_controller.rb, line 27
27:   def list
28:     @sortby = params[:sortby] || 'shortname'
29:     @projects = sort(Project.find_overview)
30:   end

[Source]

    # File app/controllers/hosting/projects_controller.rb, line 38
38:   def new
39:     @project = Project.new
40:   end

[Source]

    # File app/controllers/hosting/projects_controller.rb, line 33
33:   def show
34:     @project = Project.find(params[:id])
35:   end

[Source]

    # File app/controllers/hosting/projects_controller.rb, line 58
58:   def update
59:     @project = Project.find(params[:id])
60:     if @project.update_attributes(params[:project])
61:       flash[:notice] = 'Project info was successfully updated.'
62: #      invalidate(params[:id])
63:       redirect_to :action => 'show', :id => @project
64:     else
65:       render :action => 'edit'
66:     end
67:   end

Private Instance methods

def destroy

  project = project.find(params[:id])
  name = project.name
  project.destroy
  flash[:notice] = "Project info for \"#{name}\" has been destroyed."
   invalidate(params[:id])
  redirect_to :action => 'list'

end

[Source]

    # File app/controllers/hosting/projects_controller.rb, line 83
83:   def sort(list)
84:     assertTrue(SORTFIELDS.include?(@sortby))
85:     
86:     return list.sort_by { |item| item.send(@sortby) }
87:   end

[Validate]