diff options
Diffstat (limited to 'app/controllers/admin/projects_controller.rb')
-rw-r--r-- | app/controllers/admin/projects_controller.rb | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/app/controllers/admin/projects_controller.rb b/app/controllers/admin/projects_controller.rb new file mode 100644 index 00000000000..fe5ada8f1cb --- /dev/null +++ b/app/controllers/admin/projects_controller.rb @@ -0,0 +1,73 @@ +class Admin::ProjectsController < ApplicationController + before_filter :authenticate_user! + before_filter :authenticate_admin! + + def index + @admin_projects = Project.page(params[:page]) + + respond_to do |format| + format.html # index.html.erb + format.json { render json: @admin_projects } + end + end + + def show + @admin_project = Project.find_by_code(params[:id]) + + respond_to do |format| + format.html # show.html.erb + format.json { render json: @admin_project } + end + end + + def new + @admin_project = Project.new + + respond_to do |format| + format.html # new.html.erb + format.json { render json: @admin_project } + end + end + + def edit + @admin_project = Project.find_by_code(params[:id]) + end + + def create + @admin_project = Project.new(params[:project]) + + respond_to do |format| + if @admin_project.save + format.html { redirect_to [:admin, @admin_project], notice: 'Project was successfully created.' } + format.json { render json: @admin_project, status: :created, location: @admin_project } + else + format.html { render action: "new" } + format.json { render json: @admin_project.errors, status: :unprocessable_entity } + end + end + end + + def update + @admin_project = Project.find_by_code(params[:id]) + + respond_to do |format| + if @admin_project.update_attributes(params[:project]) + format.html { redirect_to [:admin, @admin_project], notice: 'Project was successfully updated.' } + format.json { head :ok } + else + format.html { render action: "edit" } + format.json { render json: @admin_project.errors, status: :unprocessable_entity } + end + end + end + + def destroy + @admin_project = Project.find_by_code(params[:id]) + @admin_project.destroy + + respond_to do |format| + format.html { redirect_to admin_projects_url } + format.json { head :ok } + end + end +end |