Class: ProjectController

Inherits:
ApplicationController show all
Defined in:
app/controllers/project_controller.rb

Defined Under Namespace

Classes: HtmlDiffVisitor

Instance Method Summary collapse

Methods inherited from ApplicationController

#load_project

Constructor Details

#initializeProjectController

TODO: check if the various SCMs are installed and disable them with a warning if not. Each SCM class should have an available? method



13
14
15
16
# File 'app/controllers/project_controller.rb', line 13

def initialize
  super
  @navigation_name = "changesets_list"
end

Instance Method Details

#changesetObject



80
81
82
83
84
85
# File 'app/controllers/project_controller.rb', line 80

def changeset
  load
  changeset_identifier = @params["changeset"]
  @changeset = @project.changeset(changeset_identifier.to_identifier)
  @changeset.accept(HtmlDiffVisitor.new(@project))
end

#changesets_rssObject



54
55
56
57
# File 'app/controllers/project_controller.rb', line 54

def changesets_rss
  load
  send_file(@project.changesets_rss_file)
end

#deleteObject



59
60
61
62
63
64
65
66
67
# File 'app/controllers/project_controller.rb', line 59

def delete
  load_project
  begin
    Rscm.delete_project(project)
  rescue => e
    return render_text("Couldn't connect to RSCM server. Please make sure it's running.<br>" + e.message)
  end
  index
end

#editObject



48
49
50
51
52
# File 'app/controllers/project_controller.rb', line 48

def edit
  @edit = true
  load
  render_action("view")
end

#indexObject



18
19
20
21
# File 'app/controllers/project_controller.rb', line 18

def index
  @projects = ::DamageControl::Project.find_all
  @navigation_name = "null"
end

#newObject



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'app/controllers/project_controller.rb', line 23

def new
  @project = DamageControl::Project.new

  @scms = RSCM::AbstractSCM.classes.collect {|cls| cls.new}
  first_scm = @scms[0]
  def first_scm.selected?
    true
  end
  
  @trackers = DamageControl::Tracker::Base.classes.collect {|cls| cls.new}
  first_tracker = @trackers[0]
  def first_tracker.selected?
    true
  end
  @edit = true
  @new_project = true
  render_action("view")
end

#saveObject



69
70
71
72
73
74
75
76
77
78
# File 'app/controllers/project_controller.rb', line 69

def save
  project = instantiate_from_hash(DamageControl::Project, @params[DamageControl::Project.name])
  project.scm = find_selected("scms")
  project.tracker = find_selected("trackers")
  project.publishers = instantiate_array_from_hashes(@params["publishers"])

  project.save

  redirect_to(:action => "view", :id => project.name)
end

#viewObject



42
43
44
45
46
# File 'app/controllers/project_controller.rb', line 42

def view
  return render_text("No project specified") unless @params["id"]
  @edit = false
  load
end