code cleaning
This commit is contained in:
parent
1beb84161c
commit
d64f23e294
5 changed files with 19 additions and 89 deletions
|
@ -4,29 +4,14 @@ class Admin::ProjectsController < ApplicationController
|
|||
|
||||
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
|
||||
|
@ -37,28 +22,20 @@ class Admin::ProjectsController < ApplicationController
|
|||
@admin_project = Project.new(params[:project])
|
||||
@admin_project.owner = current_user
|
||||
|
||||
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
|
||||
if @admin_project.save
|
||||
redirect_to [:admin, @admin_project], notice: 'Project was successfully created.'
|
||||
else
|
||||
render :action => "new"
|
||||
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
|
||||
if @admin_project.update_attributes(params[:project])
|
||||
redirect_to [:admin, @admin_project], notice: 'Project was successfully updated.'
|
||||
else
|
||||
render :action => "edit"
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -66,9 +43,6 @@ class Admin::ProjectsController < ApplicationController
|
|||
@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
|
||||
redirect_to admin_projects_url
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue