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



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

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

#changesets_rssObject



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

def changesets_rss
  load
  send_file(@project.changesets_rss_file)
end

#deleteObject



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

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



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

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
41
# 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



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

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



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

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