Class: Admin::SitesController

Inherits:
BaseController
  • Object
show all
Defined in:
app/controllers/admin/sites_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'app/controllers/admin/sites_controller.rb', line 21

def create
  site = Site.new params[:site]
  section = site.sections.build(params[:section])
  site.sections << section

  if site.save
    flash[:notice] = t(:'adva.sites.flash.create.success')
    redirect_to admin_site_url(site)
  else
    flash.now[:error] = t(:'adva.sites.flash.create.failure')
    render :action => :new
  end
end

#destroyObject



48
49
50
51
52
53
54
55
56
# File 'app/controllers/admin/sites_controller.rb', line 48

def destroy
  if @site.destroy
    flash[:notice] = t(:'adva.sites.flash.destroy.success')
    redirect_to return_from(:site_deleted)
  else
    flash.now[:error] = t(:'adva.sites.flash.destroy.failure')
    render :action => 'show'
  end
end

#editObject



35
36
# File 'app/controllers/admin/sites_controller.rb', line 35

def edit
end

#indexObject



8
9
10
# File 'app/controllers/admin/sites_controller.rb', line 8

def index
  @sites = Site.paginate(:page => params[:page], :per_page => params[:per_page]).order(:id)
end

#newObject



18
19
# File 'app/controllers/admin/sites_controller.rb', line 18

def new
end

#showObject



12
13
14
15
16
# File 'app/controllers/admin/sites_controller.rb', line 12

def show
  @users = @site.users_and_superusers # TODO wanna show only *recent* users here
  @contents = @site.unapproved_comments.group_by(&:commentable) if @site.respond_to?(:unapproved_comments)
  @activities = @site.grouped_activities if defined?(AdvaActivity)
end

#updateObject



38
39
40
41
42
43
44
45
46
# File 'app/controllers/admin/sites_controller.rb', line 38

def update
  if @site.update_attributes params[:site]
    flash[:notice] = t(:'adva.sites.flash.update.success')
    redirect_to edit_admin_site_url
  else
    flash.now[:error] = t(:'adva.sites.flash.update.failure')
    render :action => 'edit'
  end
end