Class: ApplicationsController
Instance Method Summary
collapse
#active_tab
#sshkey_uploaded?
#domain_is_missing, #user_default_domain
#user_capabilities
Instance Method Details
#create ⇒ Object
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
|
# File 'app/controllers/applications_controller.rb', line 106
def create
app_params = params[:application] || params
@advanced = to_boolean(params[:advanced])
type = params[:application_type] || app_params[:application_type]
domain_name = app_params[:domain_name].presence || app_params[:domain_id].presence
@application_type = (type == 'custom' || !type.is_a?(String)) ?
ApplicationType.custom(type) :
ApplicationType.find(type)
@capabilities = user_capabilities :refresh => true
@application = (@application_type >> Application.new(:as => current_user)).assign_attributes(app_params)
begin
@cartridges, @missing_cartridges = @application_type.matching_cartridges
flash.now[:error] = "No cartridges are defined for this type - all applications require at least one web cartridge" unless @cartridges.present?
rescue ApplicationType::CartridgeSpecInvalid
logger.debug $!
flash.now[:error] = "The cartridges defined for this type are not valid. The #{@application_type.source} may not be correct."
end
flash.now[:error] = "You have no free gears. You'll need to scale down or delete another application first." unless @capabilities.gears_free?
@disabled = @missing_cartridges.present? || @cartridges.blank?
@domain = Domain.find :first, :as => current_user
unless @domain
@domain = Domain.create :name => domain_name, :as => current_user
unless @domain.persisted?
logger.debug "Unable to create domain, #{@domain.errors.to_hash.inspect}"
@application.valid? @domain.errors.values.flatten.uniq.each {|e| @application.errors.add(:domain_name, e) }
return render 'application_types/show'
end
end
@application.domain = @domain
if @application.save
messages = @application.remote_results
redirect_to get_started_application_path(@application, :wizard => true), :flash => {:info_pre => messages}
else
logger.debug @application.errors.inspect
render 'application_types/show'
end
end
|
#delete ⇒ Object
94
95
96
97
98
99
100
|
# File 'app/controllers/applications_controller.rb', line 94
def delete
user_default_domain
@application = @domain.find_application params[:id]
@referer = application_path(@application)
end
|
#destroy ⇒ Object
84
85
86
87
88
89
90
91
92
|
# File 'app/controllers/applications_controller.rb', line 84
def destroy
@domain = Domain.find :one, :as => current_user
@application = @domain.find_application params[:id]
if @application.destroy
redirect_to applications_path, :flash => {:success => "The application '#{@application.name}' has been deleted"}
else
render :delete
end
end
|
#get_started ⇒ Object
170
171
172
173
174
175
176
177
|
# File 'app/controllers/applications_controller.rb', line 170
def get_started
user_default_domain
@application = @domain.find_application params[:id]
@wizard = !params[:wizard].nil?
sshkey_uploaded?
end
|
#index ⇒ Object
73
74
75
76
77
78
79
80
81
82
|
# File 'app/controllers/applications_controller.rb', line 73
def index
user_default_domain rescue nil
return redirect_to application_types_path, :notice => 'Create your first application now!' if @domain.nil? || @domain.applications.empty?
@applications_filter = ApplicationsFilter.new params[:applications_filter]
@applications = @applications_filter.apply(@domain.applications)
end
|
#new ⇒ Object
102
103
104
|
# File 'app/controllers/applications_controller.rb', line 102
def new
redirect_to application_types_path
end
|
#show ⇒ Object
160
161
162
163
164
165
166
167
168
|
# File 'app/controllers/applications_controller.rb', line 160
def show
user_default_domain
@application = @domain.find_application params[:id]
@gear_groups = @application.gear_groups_with_state
sshkey_uploaded?
end
|