Class: Admin::AdministratorsController

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

Instance Method Summary collapse

Instance Method Details

#activateObject



58
59
60
61
62
63
64
# File 'app/controllers/admin/administrators_controller.rb', line 58

def activate
  if @admin.active?
    @admin.disactivate
  else
    @admin.activate
  end
end

#createObject



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

def create
  @admin = Administrator.new(params[:administrator])
  if @admin.save
    flash[:notice] = t('admin.create.success').capitalize
    redirect_to [forgeos_core, :edit, :admin, @admin]
  else
    flash[:error] = t('admin.create.failed').capitalize
    render :action => "new"
  end
end

#destroyObject



44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'app/controllers/admin/administrators_controller.rb', line 44

def destroy
  if @admin.destroy
    flash[:notice] = t('admin.destroy.success').capitalize
  else
    flash[:error] = t('admin.destroy.failed').capitalize
  end
  respond_to do |wants|
    wants.html do
      redirect_to([forgeos_core, :admin, :administrators])
    end
    wants.js
  end
end

#editObject



21
22
# File 'app/controllers/admin/administrators_controller.rb', line 21

def edit
end

#indexObject



4
5
6
7
8
9
10
11
12
# File 'app/controllers/admin/administrators_controller.rb', line 4

def index
  respond_to do |format|
    format.html # index.html.erb
    format.json do
      sort
      render :layout => false
    end
  end
end

#newObject



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

def new
  @admin = Administrator.new(params[:administrator])
end

#showObject



14
15
# File 'app/controllers/admin/administrators_controller.rb', line 14

def show
end

#updateObject



35
36
37
38
39
40
41
42
# File 'app/controllers/admin/administrators_controller.rb', line 35

def update
  if @admin.update_attributes(params[:administrator])
    flash[:notice] = t('admin.update.success').capitalize
  else
    flash[:error] = t('admin.update.failed').capitalize
  end
  render :action => "edit"
end