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
|
# File 'lib/rhoconnect/condition/source_required.rb', line 10
def include_source_required_condition
set(:source_required) do |value|
condition do
if value
catch_all do
source = nil
user = current_user
if params["cud"]
cud_source_name = JSON.parse(params["cud"])["source_name"]
params.merge!({:source_name => cud_source_name}) if cud_source_name
end
if params[:source_name] and user
source = Source.load(params[:source_name],
{:user_id => user.login,:app_id => APP_NAME})
unless source
sconfig = Rhoconnect.source_config(params[:source_name])
source = Source.create(sconfig.merge!({:name => params[:source_name]}),{:user_id => user.login, :app_id => APP_NAME})
current_app.sources << source.name
end
else
Rhoconnect.log "ERROR: Can't load source, no source_name provided.\n"
raise ArgumentError.new(UNKNOWN_SOURCE)
end
env[CURRENT_SOURCE] = source
@model = Rhoconnect::Model::Base.create(source)
end
end
end
end
end
|