2011-10-08 21:36:38 +00:00
|
|
|
class Admin::ProjectsController < ApplicationController
|
2011-11-02 15:21:17 +00:00
|
|
|
layout "admin"
|
2011-10-08 21:36:38 +00:00
|
|
|
before_filter :authenticate_user!
|
|
|
|
before_filter :authenticate_admin!
|
|
|
|
|
|
|
|
def index
|
|
|
|
@admin_projects = Project.page(params[:page])
|
|
|
|
end
|
|
|
|
|
|
|
|
def show
|
|
|
|
@admin_project = Project.find_by_code(params[:id])
|
|
|
|
end
|
|
|
|
|
|
|
|
def new
|
|
|
|
@admin_project = Project.new
|
|
|
|
end
|
|
|
|
|
|
|
|
def edit
|
|
|
|
@admin_project = Project.find_by_code(params[:id])
|
|
|
|
end
|
|
|
|
|
|
|
|
def create
|
|
|
|
@admin_project = Project.new(params[:project])
|
2011-10-09 19:36:57 +00:00
|
|
|
@admin_project.owner = current_user
|
2011-10-08 21:36:38 +00:00
|
|
|
|
2011-10-27 13:44:29 +00:00
|
|
|
if @admin_project.save
|
|
|
|
redirect_to [:admin, @admin_project], notice: 'Project was successfully created.'
|
|
|
|
else
|
|
|
|
render :action => "new"
|
2011-10-08 21:36:38 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def update
|
|
|
|
@admin_project = Project.find_by_code(params[:id])
|
|
|
|
|
2011-10-27 13:44:29 +00:00
|
|
|
if @admin_project.update_attributes(params[:project])
|
|
|
|
redirect_to [:admin, @admin_project], notice: 'Project was successfully updated.'
|
|
|
|
else
|
|
|
|
render :action => "edit"
|
2011-10-08 21:36:38 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def destroy
|
|
|
|
@admin_project = Project.find_by_code(params[:id])
|
|
|
|
@admin_project.destroy
|
|
|
|
|
2011-10-27 13:44:29 +00:00
|
|
|
redirect_to admin_projects_url
|
2011-10-08 21:36:38 +00:00
|
|
|
end
|
|
|
|
end
|