Show More
Commit Description:
merge
Commit Description:
merge
References:
File last commit:
Show/Diff file:
Action:
app/controllers/sites_controller.rb
| 97 lines
| 2.1 KiB
| text/x-ruby
| RubyLexer
|
|
r85 | class SitesController < ApplicationController | ||
|
r119 | |||
r745 | before_action :admin_authorization | |||
|
r119 | |||
|
r85 | # GET /sites | ||
# GET /sites.xml | ||||
def index | ||||
r619 | @sites = Site.order(:country_id) | |||
|
r85 | |||
respond_to do |format| | ||||
format.html # index.html.erb | ||||
format.xml { render :xml => @sites } | ||||
end | ||||
end | ||||
# GET /sites/1 | ||||
# GET /sites/1.xml | ||||
def show | ||||
@site = Site.find(params[:id]) | ||||
respond_to do |format| | ||||
format.html # show.html.erb | ||||
format.xml { render :xml => @site } | ||||
end | ||||
end | ||||
# GET /sites/new | ||||
# GET /sites/new.xml | ||||
def new | ||||
@site = Site.new | ||||
respond_to do |format| | ||||
format.html # new.html.erb | ||||
format.xml { render :xml => @site } | ||||
end | ||||
end | ||||
# GET /sites/1/edit | ||||
def edit | ||||
@site = Site.find(params[:id]) | ||||
end | ||||
# POST /sites | ||||
# POST /sites.xml | ||||
def create | ||||
@site = Site.new(params[:site]) | ||||
@site.clear_start_time_if_not_started | ||||
respond_to do |format| | ||||
if @site.save | ||||
flash[:notice] = 'Site was successfully created.' | ||||
format.html { redirect_to(@site) } | ||||
format.xml { render :xml => @site, :status => :created, :location => @site } | ||||
else | ||||
format.html { render :action => "new" } | ||||
format.xml { render :xml => @site.errors, :status => :unprocessable_entity } | ||||
end | ||||
end | ||||
end | ||||
# PUT /sites/1 | ||||
# PUT /sites/1.xml | ||||
def update | ||||
@site = Site.find(params[:id]) | ||||
@site.clear_start_time_if_not_started | ||||
respond_to do |format| | ||||
r617 | if @site.update_attributes(site_params) | |||
|
r85 | flash[:notice] = 'Site was successfully updated.' | ||
format.html { redirect_to(@site) } | ||||
format.xml { head :ok } | ||||
else | ||||
format.html { render :action => "edit" } | ||||
format.xml { render :xml => @site.errors, :status => :unprocessable_entity } | ||||
end | ||||
end | ||||
end | ||||
# DELETE /sites/1 | ||||
# DELETE /sites/1.xml | ||||
def destroy | ||||
@site = Site.find(params[:id]) | ||||
@site.destroy | ||||
respond_to do |format| | ||||
format.html { redirect_to(sites_url) } | ||||
format.xml { head :ok } | ||||
end | ||||
end | ||||
|
r123 | |||
r617 | private | |||
def site_params | ||||
params.require(:site).permit(:name,:started,:start_time,:country_id,:password) | ||||
end | ||||
|
r85 | end | ||