Class: ProjectsController

Inherits:
ApplicationController show all
Includes:
InchCI::Controller
Defined in:
app/controllers/projects_controller.rb

Instance Method Summary collapse

Methods included from InchCI::Controller

#expose

Instance Method Details

#badgeObject


11
12
13
14
15
16
17
18
19
20
21
22
# File 'app/controllers/projects_controller.rb', line 11

def badge
  action = Action::Project::Badge.new(params)
  if action.success?
    response.headers['Expires'] = Time.now.to_s
    response.headers['Pragma'] = 'no-cache'
    response.headers['Cache-Control'] = 'no-cache'
    send_file action.badge_filename, :content_type => action.content_type,
                                      :disposition => 'inline'
  else
    render :text => "Project or branch not found.", :layout => false, :status => 404
  end
end

#createObject


24
25
26
27
28
29
30
31
32
33
# File 'app/controllers/projects_controller.rb', line 24

def create
  action = Action::Project::Create.new(params, :homepage)
  if action.success?
    redirect_to project_url(action.project, :pending_build => action.build_id)
  else
    expose action
    flash[:error] = t("projects.create.url_not_found")
    render :template => "page/welcome"
  end
end

#create_hookObject


35
36
37
38
39
40
41
42
# File 'app/controllers/projects_controller.rb', line 35

def create_hook
  action = Action::Project::ActivateHook.new(current_user, params)
  expose action
  if !action.success?
    flash[:error] = "Could not create hook for #{@project.name}"
  end
  redirect_to user_url(current_user, :tab => @project.language)
end

#editObject


44
45
46
# File 'app/controllers/projects_controller.rb', line 44

def edit
  process_project_action Action::Project::Show
end

#historyObject


57
58
59
# File 'app/controllers/projects_controller.rb', line 57

def history
  process_project_action Action::Project::History
end

#rebuildObject


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

def rebuild
  action = Action::Project::Rebuild.new(params)
  if action.success?
    redirect_to project_url(action.project, action.branch.name, :pending_build => action.build_id)
  else
    render :text => "Project not found.", :layout => false, :status => 404
  end
end

#rebuild_via_hookObject


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

def rebuild_via_hook
  action = Action::Project::RebuildViaHook.new(params)
  render :text => action.result
end

#remove_hookObject


75
76
77
78
79
80
81
82
# File 'app/controllers/projects_controller.rb', line 75

def remove_hook
  action = Action::Project::DeactivateHook.new(current_user, params)
  expose action
  if !action.success?
    flash[:error] = "Could not remove hook for #{@project.name}"
  end
  redirect_to user_url(current_user, :tab => @project.language)
end

#showObject


93
94
95
# File 'app/controllers/projects_controller.rb', line 93

def show
  process_project_action Action::Project::Show
end

#suggestionsObject


84
85
86
# File 'app/controllers/projects_controller.rb', line 84

def suggestions
  process_project_action Action::Project::Suggestions
end

#updateObject


48
49
50
51
52
53
54
55
# File 'app/controllers/projects_controller.rb', line 48

def update
  action = Action::Project::Update.new(current_user, params)
  if action.success?
    redirect_to project_url(action.project)
  else
    redirect_to edit_project_url(action.project)
  end
end

#update_infoObject


88
89
90
91
# File 'app/controllers/projects_controller.rb', line 88

def update_info
  action = Action::Project::UpdateInfo.new(current_user, params)
  redirect_to project_url(action.project, action.branch.name)
end