Class: Admin::ProjectsController

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

Constant Summary collapse

PROJECTS_PER_PAGE =
200
LANGUAGE_NOT_SET =
"LANGUAGE_NOT_SET"

Instance Method Summary collapse

Methods included from InchCI::Controller

#expose

Instance Method Details

#createObject


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

def create
  action = Action::Project::Create.new(params, :admin)
  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

#find_projectsObject


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

def find_projects
  arel = filter_collection(Project).order('created_at DESC')
  @projects_total_count = arel.count
  arel.limit(PROJECTS_PER_PAGE)
end

#indexObject


31
32
33
34
# File 'app/controllers/admin/projects_controller.rb', line 31

def index
  @projects = find_projects
  @languages = %w(Elixir JavaScript Ruby) + [LANGUAGE_NOT_SET]
end

#showObject


42
43
44
# File 'app/controllers/admin/projects_controller.rb', line 42

def show
  @project = Project.find(params[:id])
end

#updateObject


22
23
24
25
26
27
28
29
# File 'app/controllers/admin/projects_controller.rb', line 22

def update
  @project = ::Project.find(params[:id])
  attributes = params[:project]
  @project.documentation_url = attributes[:documentation_url]
  @project.language = attributes[:language]
  InchCI::Store::SaveProject.call(@project)
  redirect_to admin_project_url(@project)
end