1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
class ConferencesController < ApplicationController
load_resource :user
load_resource :tenant
load_and_authorize_resource :conference, :through => [:user, :tenant]
before_filter :set_and_authorize_parent
before_filter :spread_breadcrumbs
def index
end
def show
@phone_numbers = @conference.phone_numbers
end
def new
@conference = @parent.conferences.build
@conference.name = generate_a_new_name(@parent, @conference)
@conference.start = nil
@conference.end = nil
@conference.open_for_anybody = true
@conference.max_members = GsParameter.get('DEFAULT_MAX_CONFERENCE_MEMBERS')
@conference.pin = random_pin
@conference.open_for_anybody = true
@conference.announce_new_member_by_name = true
@conference.announce_left_member_by_name = true
end
def create
@conference = @parent.conferences.build(params[:conference])
if @conference.save
m = method( :"#{@parent.class.name.underscore}_conference_path" )
redirect_to m.( @parent, @conference ), :notice => t('conferences.controller.successfuly_created')
else
render :new
end
end
def edit
end
def update
if @conference.update_attributes(params[:conference])
m = method( :"#{@parent.class.name.underscore}_conference_path" )
redirect_to m.( @parent, @conference ), :notice => t('conferences.controller.successfuly_updated')
else
render :edit
end
end
def destroy
@conference.destroy
m = method( :"#{@parent.class.name.underscore}_conferences_url" )
redirect_to m.( @parent ), :notice => t('conferences.controller.successfuly_destroyed')
end
private
def set_and_authorize_parent
@parent = @tenant || @user
authorize! :read, @parent
end
def spread_breadcrumbs
if @parent && @parent.class == User
add_breadcrumb t("users.index.page_title"), tenant_users_path(@user.current_tenant)
add_breadcrumb @user, tenant_user_path(@user.current_tenant, @user)
add_breadcrumb t("conferences.index.page_title"), user_conferences_path(@user)
if @conference && !@conference.new_record?
add_breadcrumb @conference, user_conference_path(@user, @conference)
end
end
if @parent && @parent.class == Tenant
add_breadcrumb t("conferences.index.page_title"), tenant_conferences_path(@tenant)
if @conference && !@conference.new_record?
add_breadcrumb @conference, tenant_conference_path(@tenant, @conference)
end
end
end
end
|