Class: GroupsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/groups_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 /groups POST /groups.xml



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

def create
  @group = Group.new(group_params)
  auth!
  if @group.save
    process_notification(@group, {}, process_notification_options({:params => {:group_name => @group.name}}))
    flash[:notice] = t(:group_created)
  end
  respond_with(@group)
end

- (Object) destroy

DELETE /groups/1 DELETE /groups/1.xml



72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'app/controllers/groups_controller.rb', line 72

def destroy
  @group = Group.find(params[:id])
  auth!
  #we don't let groups owning screens or feeds get deleted
  unless @group.is_deletable?
    redirect_to(@group, :notice => t(:group_not_deletable)) 
    return
  end
  
  process_notification(@group, {}, process_notification_options({:params => {:group_name => @group.name}}))
  @group.destroy

  respond_with(@group) 
end

- (Object) edit

GET /groups/1/edit



41
42
43
44
# File 'app/controllers/groups_controller.rb', line 41

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

- (Object) index

GET /groups GET /groups.xml



6
7
8
9
10
11
12
# File 'app/controllers/groups_controller.rb', line 6

def index
  @groups = Group.all
  @my_groups = current_user.nil? ? [] : current_user.groups
  @users = User.all
  auth!
  respond_with(@groups)
end

- (Object) manage_members



33
34
35
36
37
38
# File 'app/controllers/groups_controller.rb', line 33

def manage_members
  @group = Group.find(params[:id])
  @denied = @group.memberships.denied
  auth! :action => :edit
  respond_with(@group)
end

- (Object) new

GET /groups/new GET /groups/new.xml



27
28
29
30
31
# File 'app/controllers/groups_controller.rb', line 27

def new
  @group = Group.new
  auth!
  respond_with(@group)
end

- (Object) show

GET /groups/1 GET /groups/1.xml



16
17
18
19
20
21
22
23
# File 'app/controllers/groups_controller.rb', line 16

def show
  @group = Group.find(params[:id])
  @feeds_separated = @group.feeds.in_groups(2)
  @feeds_left = @feeds_separated[0]
  @feeds_right = @feeds_separated[1]
  auth!
  respond_with(@group)
end

- (Object) update

PUT /groups/1 PUT /groups/1.xml



60
61
62
63
64
65
66
67
68
# File 'app/controllers/groups_controller.rb', line 60

def update
  @group = Group.find(params[:id])
  auth!
  if @group.update_attributes(group_params)  
    process_notification(@group, {}, process_notification_options({:params => {:group_name => @group.name}}))
    flash[:notice] = t(:group_updated) 
  end  
  respond_with(@group)  
end