Class: ProjectController

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

Defined Under Namespace

Classes: HtmlDiffVisitor

Constant Summary collapse

SCMS =

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

[
# Uncomment this to see Mooky in action in the web interface!
#    RSCM::Mooky,
  RSCM::CVS, 
  RSCM::SVN, 
  RSCM::StarTeam
]
TRACKERS =
[
  DamageControl::Tracker::Null, 
  DamageControl::Tracker::Bugzilla, 
  DamageControl::Tracker::JIRA,
  DamageControl::Tracker::RubyForge,
  DamageControl::Tracker::SourceForge,
  DamageControl::Tracker::Scarab,
  DamageControl::Tracker::Trac
]
SCM_WEBS =
[
#    SCMWeb::Null.new, 
#    SCMWeb::ViewCVS.new, 
#    SCMWeb::Fisheye.new
]

Instance Method Summary collapse

Methods inherited from ApplicationController

#breadcrumbs, #load_project

Constructor Details

#initializeProjectController

Returns a new instance of ProjectController.



36
37
38
39
# File 'app/controllers/project_controller.rb', line 36

def initialize
  super
  @navigation_name = "changesets_list"
end

Instance Method Details

#changesetsObject



105
106
107
108
109
110
# File 'app/controllers/project_controller.rb', line 105

def changesets
  load
  last_changeset_identifier = @params["changeset"]
  @changesets = @project.changesets(last_changeset_identifier.to_identifier, 1)    
  @changesets.accept(HtmlDiffVisitor.new(@project))
end

#changesets_rssObject



75
76
77
78
# File 'app/controllers/project_controller.rb', line 75

def changesets_rss
  load
  send_file(@project.changesets_rss_file)
end

#deleteObject



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

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



69
70
71
72
73
# File 'app/controllers/project_controller.rb', line 69

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

#indexObject



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

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

#newObject



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'app/controllers/project_controller.rb', line 46

def new
  @project = DamageControl::Project.new
  @scms = SCMS.collect {|o| o.new}
  first_scm = @scms[0]
  def first_scm.selected?
    true
  end
  @trackers = TRACKERS.collect {|o| o.new}
  first_tracker = @trackers[0]
  def first_tracker.selected?
    true
  end
  @edit = true
  @new_project = true
  render_action("view")
end

#saveObject



90
91
92
93
94
95
96
97
98
99
100
101
102
103
# File 'app/controllers/project_controller.rb', line 90

def save
  project         = instantiate_from_params("project")
  project.scm     = instantiate_from_params("scm")
  project.tracker = instantiate_from_params("tracker")
  
  begin
    Rscm.save_project(project)
  rescue => e
    $stderr.puts(e.backtrace.join("\n"))
    return render_text("Couldn't connect to RSCM server. Please make sure it's running.<br>" + e.message)
  end

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

#viewObject



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

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