Class: ScreensController

Inherits:
ApplicationController show all
Defined in:
app/controllers/screens_controller.rb

Instance Method Summary (collapse)

Methods inherited from ApplicationController

#after_sign_in_path_for, #allow_cors, #allow_screen_if_unsecured, #apply_relative_root, #auth!, #check_for_initial_install, #compute_pending_moderation, #current_ability, #current_accessor, #current_screen, #extract_pagination_from_relation, #http_basic_user_name_and_password, #precompile_error_catch, #process_notification, #reapply_pagination, #restart_webserver, #screen_api, #set_locale, #set_time_zone, #set_version, #sign_in_screen, #sign_out_screen, #switch_to_main_app_ability, #switch_to_plugin_ability, #use_plugin_ability, #webserver_supports_restart?

Instance Method Details

- (Object) create

POST /screens POST /screens.xml



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'app/controllers/screens_controller.rb', line 43

def create
  @screen = Screen.new(screen_params)

  auth!
  
  if @screen.save
    process_notification(@screen, {}, process_notification_options({:params => {:screen_name => @screen.name}}))
    run_callbacks :change # Run plugin hooks
    flash[:notice] = t(:screen_created)
  else
    @screen.clear_screen_token
    @screen.auth_action = screen_params[:auth_action]
  end
  
  respond_with(@screen)
end

- (Object) destroy

DELETE /screens/1 DELETE /screens/1.xml



78
79
80
81
82
83
84
85
86
87
# File 'app/controllers/screens_controller.rb', line 78

def destroy
  @screen = Screen.find(params[:id])
  auth!
  process_notification(@screen, {}, process_notification_options({:params => {:screen_name => @screen.name}}))
  run_callbacks :destroy do
    @screen.destroy
  end 
  
  respond_with(@screen)
end

- (Object) edit

GET /screens/1/edit



36
37
38
39
# File 'app/controllers/screens_controller.rb', line 36

def edit
  @screen = Screen.find(params[:id])
  auth!
end

- (Object) index

GET /screens GET /screens.xml



11
12
13
14
15
16
# File 'app/controllers/screens_controller.rb', line 11

def index
  @screens = Screen.accessible_by(current_ability)
  @my_screens = current_user.nil? ? [] : @screens.select{|s| s.owner == current_user || current_user.groups.include?(s.owner)}
  @templates = Template.where(:is_hidden => false).sort_by{|t| t.screens.count}.reverse
  respond_with(@screens)
end

- (Object) new

GET /screens/new GET /screens/new.xml



29
30
31
32
33
# File 'app/controllers/screens_controller.rb', line 29

def new
  @screen = Screen.new(:owner => current_user)
  auth!
  respond_with(@screen)
end

- (Object) show

GET /screens/1 GET /screens/1.xml



20
21
22
23
24
25
# File 'app/controllers/screens_controller.rb', line 20

def show
  @screen = Screen.find(params[:id])
  run_callbacks :show # Run plugin hooks
  auth!
  respond_with(@screen)
end

- (Object) update

PUT /screens/1 PUT /screens/1.xml



62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'app/controllers/screens_controller.rb', line 62

def update
  @screen = Screen.find(params[:id])

  auth!
  
  if @screen.update_attributes(screen_params)
    process_notification(@screen, {}, process_notification_options({:params => {:screen_name => @screen.name}}))

    run_callbacks :change # Run plugin hooks
    flash[:notice] = t(:screen_updated)
  end
  respond_with(@screen)
end

- (Object) update_owners



89
90
91
92
93
94
95
96
# File 'app/controllers/screens_controller.rb', line 89

def update_owners
  if params[:owner] == "User"
    @owners = User.all
  elsif params[:owner] == "Group"
    @owners = Group.all
  end
  render :layout => false
end