knitkit 2.0.5 → 2.0.6
Sign up to get free protection for your applications and to get access to all the features.
- data/app/controllers/knitkit/erp_app/desktop/app_controller.rb +5 -8
- data/app/controllers/knitkit/erp_app/desktop/articles_controller.rb +11 -8
- data/app/controllers/knitkit/erp_app/desktop/content_controller.rb +26 -4
- data/app/controllers/knitkit/erp_app/desktop/file_assets_controller.rb +49 -35
- data/app/controllers/knitkit/erp_app/desktop/image_assets_controller.rb +30 -21
- data/app/controllers/knitkit/erp_app/desktop/theme_controller.rb +41 -32
- data/app/controllers/knitkit/erp_app/desktop/website_controller.rb +0 -6
- data/app/controllers/knitkit/erp_app/desktop/website_section_controller.rb +42 -6
- data/app/{models → mailers}/website_inquiry_mailer.rb +0 -0
- data/app/models/article.rb +4 -0
- data/app/models/content.rb +0 -4
- data/app/models/theme.rb +3 -3
- data/app/models/website.rb +44 -17
- data/app/views/knitkit/website_sections/index.html.erb +1 -1
- data/app/views/layouts/knitkit/base.html.erb +6 -0
- data/app/views/shared/knitkit/_footer.html.erb +2 -2
- data/app/widgets/signup/base.rb +0 -2
- data/db/data_migrations/20120809020508_update_website_and_configuration.rb +77 -0
- data/lib/knitkit/engine.rb +4 -0
- data/lib/knitkit/extensions.rb +4 -1
- data/lib/knitkit/extensions/action_controller/theme_support/acts_as_themed_controller.rb +36 -33
- data/lib/knitkit/extensions/action_mailer/theme_support/acts_as_themed_mailer.rb +60 -0
- data/lib/knitkit/extensions/active_record/acts_as_commentable.rb +9 -4
- data/lib/knitkit/extensions/active_record/acts_as_document.rb +1 -1
- data/lib/knitkit/extensions/compass_ae/widgets/base.rb +21 -1
- data/lib/knitkit/extensions/compass_ae/widgets/widget_proxy_controller.rb +26 -0
- data/lib/knitkit/extensions/railties/action_view/base.rb +11 -0
- data/lib/knitkit/extensions/railties/action_view/helpers/blog_helper.rb +62 -0
- data/lib/knitkit/extensions/railties/action_view/helpers/content_helper.rb +83 -0
- data/lib/knitkit/extensions/railties/action_view/helpers/knitkit_helper.rb +67 -0
- data/lib/knitkit/extensions/railties/action_view/helpers/menu_helper.rb +71 -0
- data/lib/knitkit/version.rb +1 -1
- data/public/images/knitkit/close.png +0 -0
- data/public/javascripts/erp_app/desktop/applications/knitkit/articles_grid_panel.js +150 -400
- data/public/javascripts/erp_app/desktop/applications/knitkit/center_region.js +687 -593
- data/public/javascripts/erp_app/desktop/applications/knitkit/east_region.js +1 -2
- data/public/javascripts/erp_app/desktop/applications/knitkit/file_assets_panel.js +39 -15
- data/public/javascripts/erp_app/desktop/applications/knitkit/image_assets_data_view.js +1 -1
- data/public/javascripts/erp_app/desktop/applications/knitkit/image_assets_panel.js +65 -126
- data/public/javascripts/erp_app/desktop/applications/knitkit/module.js +65 -1
- data/public/javascripts/erp_app/desktop/applications/knitkit/section_articles_grid_panel.js +265 -183
- data/public/javascripts/erp_app/desktop/applications/knitkit/themes_tree_panel.js +24 -9
- data/public/javascripts/erp_app/desktop/applications/knitkit/versions_grid_panel.js +631 -595
- data/public/javascripts/erp_app/desktop/applications/knitkit/west_region/helpers/document.js +265 -0
- data/public/javascripts/erp_app/desktop/applications/knitkit/west_region/helpers/host.js +133 -0
- data/public/javascripts/erp_app/desktop/applications/knitkit/west_region/helpers/menu.js +174 -0
- data/public/javascripts/erp_app/desktop/applications/knitkit/west_region/helpers/section.js +399 -0
- data/public/javascripts/erp_app/desktop/applications/knitkit/west_region/helpers/website.js +165 -0
- data/public/javascripts/erp_app/desktop/applications/knitkit/west_region/helpers/website_nav_items.js +266 -0
- data/public/javascripts/erp_app/desktop/applications/knitkit/west_region/west_region.js +1224 -0
- data/public/javascripts/knitkit/inline_editing.js +136 -0
- data/public/stylesheets/extjs/resources/css/knitkit_extjs_4.css +1 -2
- data/public/stylesheets/knitkit/inline_editing.css +88 -0
- data/public/stylesheets/knitkit/style.css +1 -1
- metadata +47 -31
- data/lib/knitkit/extensions/railties/action_view.rb +0 -199
- data/public/javascripts/erp_app/desktop/applications/knitkit/west_region.js +0 -2725
@@ -8,23 +8,21 @@ module Knitkit
|
|
8
8
|
websites = Website.order('name ASC').all
|
9
9
|
|
10
10
|
tree = []
|
11
|
-
|
12
11
|
websites.each do |website|
|
12
|
+
@website_primary_host = website.config_value('primary_host')
|
13
|
+
|
13
14
|
website_hash = {
|
14
15
|
:text => website.name,
|
15
16
|
:configurationId => website.configurations.first.id,
|
16
17
|
:iconCls => 'icon-globe_disconnected',
|
17
18
|
:id => "website_#{website.id}",
|
18
19
|
:leaf => false,
|
19
|
-
:url => "http://#{
|
20
|
+
:url => "http://#{@website_primary_host}",
|
20
21
|
:name => website.name,
|
21
22
|
:title => website.title,
|
22
23
|
:subtitle => website.subtitle,
|
23
24
|
:isWebsite => true,
|
24
|
-
:email => website.email,
|
25
25
|
:siteName => website.name,
|
26
|
-
:emailInquiries => website.email_inquiries?,
|
27
|
-
:autoActivatePublication => website.auto_activate_publication?,
|
28
26
|
:children => []
|
29
27
|
}
|
30
28
|
|
@@ -44,7 +42,6 @@ module Knitkit
|
|
44
42
|
|
45
43
|
website_hash[:children] << sections_hash
|
46
44
|
|
47
|
-
|
48
45
|
#handle menus
|
49
46
|
menus_hash = {:text => 'Menus', :iconCls => 'icon-content', :isMenuRoot => true, :websiteId => website.id, :leaf => false, :children => []}
|
50
47
|
website.website_navs.each do |website_nav|
|
@@ -80,7 +77,7 @@ module Knitkit
|
|
80
77
|
unless item.linked_to_item.nil?
|
81
78
|
linked_to_item_id = item.linked_to_item_id
|
82
79
|
link_to_type = item.linked_to_item.class.to_s.underscore
|
83
|
-
url = "http://#{
|
80
|
+
url = "http://#{@website_primary_host}" + item.linked_to_item.path
|
84
81
|
end
|
85
82
|
|
86
83
|
menu_item_hash = {
|
@@ -116,7 +113,7 @@ module Knitkit
|
|
116
113
|
:renderWithBaseLayout => website_section.render_base_layout?,
|
117
114
|
:hasLayout => !website_section.layout.blank?,
|
118
115
|
:id => "section_#{website_section.id}",
|
119
|
-
:url => "http://#{
|
116
|
+
:url => "http://#{@website_primary_host}#{website_section.path}",
|
120
117
|
:internal_identifier => website_section.internal_identifier
|
121
118
|
}
|
122
119
|
if (website_section.is_a?(OnlineDocumentSection) || website_section.type == 'OnlineDocumentSection')
|
@@ -61,14 +61,14 @@ module Knitkit
|
|
61
61
|
else
|
62
62
|
result[:success] = false
|
63
63
|
end
|
64
|
-
|
64
|
+
|
65
65
|
render :json => result
|
66
66
|
end
|
67
67
|
rescue ErpTechSvcs::Utils::CompassAccessNegotiator::Errors::UserDoesNotHaveCapability=>ex
|
68
68
|
render :json => {:success => false, :message => ex.message}
|
69
69
|
end
|
70
70
|
end
|
71
|
-
|
71
|
+
|
72
72
|
def delete
|
73
73
|
model = DesktopApplication.find_by_internal_identifier('knitkit')
|
74
74
|
begin
|
@@ -103,12 +103,12 @@ module Knitkit
|
|
103
103
|
section = WebsiteSection.find(website_section_id)
|
104
104
|
|
105
105
|
if section.type == 'Blog'
|
106
|
-
sort_default = 'created_at'
|
106
|
+
sort_default = 'contents.created_at'
|
107
107
|
dir_default = 'DESC'
|
108
108
|
else
|
109
109
|
sort_default = 'title'
|
110
110
|
dir_default = 'ASC'
|
111
|
-
end
|
111
|
+
end
|
112
112
|
|
113
113
|
sort_hash = params[:sort].blank? ? {} : Hash.symbolize_keys(JSON.parse(params[:sort]).first)
|
114
114
|
sort = sort_hash[:property] || sort_default
|
@@ -146,7 +146,7 @@ module Knitkit
|
|
146
146
|
|
147
147
|
render :inline => "{total:#{total_count},data:#{articles_array.to_json}}"
|
148
148
|
end
|
149
|
-
|
149
|
+
|
150
150
|
def all
|
151
151
|
Article.include_root_in_json = false
|
152
152
|
sort_hash = params[:sort].blank? ? {} : Hash.symbolize_keys(JSON.parse(params[:sort]).first)
|
@@ -157,7 +157,10 @@ module Knitkit
|
|
157
157
|
|
158
158
|
articles = Article.includes(:website_section_contents)
|
159
159
|
articles = articles.where( :website_section_contents => { :content_id => nil } ) if params[:show_orphaned] == 'true'
|
160
|
-
articles = articles.where(
|
160
|
+
articles = articles.where("UPPER(contents.internal_identifier) LIKE UPPER('%#{params[:iid]}%')") unless params[:iid].blank?
|
161
|
+
articles = articles.where("UPPER(contents.title) LIKE UPPER('%#{params[:title]}%')") unless params[:title].blank?
|
162
|
+
articles = articles.where("UPPER(contents.body_html) LIKE UPPER('%#{params[:content]}%')
|
163
|
+
OR UPPER(contents.excerpt_html) LIKE UPPER('%#{params[:content]}%')") unless params[:content].blank?
|
161
164
|
articles = articles.order("contents.#{sort} #{dir}")
|
162
165
|
total_count = articles.count
|
163
166
|
articles = articles.limit(limit).offset(start)
|
@@ -195,7 +198,7 @@ module Knitkit
|
|
195
198
|
article = Article.find(params[:article_id])
|
196
199
|
attributes = article.attribute_values
|
197
200
|
attributes = attributes.slice(start.to_i, limit.to_i)
|
198
|
-
|
201
|
+
|
199
202
|
if dir == "DESC"
|
200
203
|
if sort == "data_type" or sort == "description"
|
201
204
|
attributes = attributes.sort {|x,y| x.attribute_type.send(sort) <=> y.attribute_type.send(sort)}
|
@@ -277,7 +280,7 @@ module Knitkit
|
|
277
280
|
|
278
281
|
render :json => result
|
279
282
|
end
|
280
|
-
|
283
|
+
|
281
284
|
end#ArticlesController
|
282
285
|
end#Desktop
|
283
286
|
end#ErpApp
|
@@ -4,6 +4,7 @@ module Knitkit
|
|
4
4
|
|
5
5
|
class ContentController < Knitkit::ErpApp::Desktop::AppController
|
6
6
|
def update
|
7
|
+
result = {:success => true}
|
7
8
|
model = DesktopApplication.find_by_internal_identifier('knitkit')
|
8
9
|
begin
|
9
10
|
current_user.with_capability(model, 'edit_html', 'Article') do
|
@@ -11,8 +12,19 @@ module Knitkit
|
|
11
12
|
html = params[:html]
|
12
13
|
content = Content.find(id)
|
13
14
|
content.body_html = html
|
14
|
-
|
15
|
-
|
15
|
+
|
16
|
+
if content.save
|
17
|
+
if params[:site_id]
|
18
|
+
website = Website.find(params[:site_id])
|
19
|
+
content.publish(website, 'Auto Publish', content.version, current_user) if website.publish_on_save?
|
20
|
+
end
|
21
|
+
#added for inline editing
|
22
|
+
result[:last_update] = content.updated_at.strftime("%m/%d/%Y %I:%M%p")
|
23
|
+
else
|
24
|
+
result = {:success => false}
|
25
|
+
end
|
26
|
+
|
27
|
+
render :json => result
|
16
28
|
end
|
17
29
|
rescue ErpTechSvcs::Utils::CompassAccessNegotiator::Errors::UserDoesNotHaveCapability=>ex
|
18
30
|
render :json => {:success => false, :message => ex.message}
|
@@ -20,6 +32,7 @@ module Knitkit
|
|
20
32
|
end
|
21
33
|
|
22
34
|
def save_excerpt
|
35
|
+
result = {:success => true}
|
23
36
|
model = DesktopApplication.find_by_internal_identifier('knitkit')
|
24
37
|
begin
|
25
38
|
current_user.with_capability(model, 'edit_excerpt', 'Article') do
|
@@ -27,8 +40,17 @@ module Knitkit
|
|
27
40
|
html = params[:html]
|
28
41
|
content = Content.find(id)
|
29
42
|
content.excerpt_html = html
|
30
|
-
|
31
|
-
|
43
|
+
|
44
|
+
if content.save
|
45
|
+
if params[:site_id]
|
46
|
+
website = Website.find(params[:site_id])
|
47
|
+
content.publish(website, 'Auto Publish', content.version, current_user) if website.publish_on_save?
|
48
|
+
end
|
49
|
+
else
|
50
|
+
result = {:success => false}
|
51
|
+
end
|
52
|
+
|
53
|
+
render :json => result
|
32
54
|
end
|
33
55
|
rescue ErpTechSvcs::Utils::CompassAccessNegotiator::Errors::UserDoesNotHaveCapability=>ex
|
34
56
|
render :json => {:success => false, :message => ex.message}
|
@@ -59,12 +59,12 @@ module Knitkit
|
|
59
59
|
begin
|
60
60
|
current_user.with_capability(model, capability_type, capability_resource) do
|
61
61
|
result = {}
|
62
|
-
upload_path =
|
63
|
-
name =
|
64
|
-
data = request.
|
62
|
+
upload_path = params[:directory]
|
63
|
+
name = params[:name]
|
64
|
+
data = request.raw_post
|
65
65
|
|
66
66
|
begin
|
67
|
-
upload_path == 'root_node' ? @assets_model.add_file(data, File.join(
|
67
|
+
upload_path == 'root_node' ? @assets_model.add_file(data, File.join(base_path,name)) : @assets_model.add_file(data, File.join(@file_support.root,upload_path,name))
|
68
68
|
result = {:success => true}
|
69
69
|
rescue Exception=>ex
|
70
70
|
logger.error ex.message
|
@@ -81,24 +81,32 @@ module Knitkit
|
|
81
81
|
end
|
82
82
|
|
83
83
|
def save_move
|
84
|
-
|
85
|
-
|
84
|
+
messages = []
|
85
|
+
result = {}
|
86
|
+
path = params[:node]
|
86
87
|
new_parent_path = params[:parent_node]
|
87
88
|
new_parent_path = @root_node if new_parent_path == ROOT_NODE
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
89
|
+
|
90
|
+
nodes_to_move = (params[:selected_nodes] ? JSON(params[:selected_nodes]) : [params[:node]])
|
91
|
+
begin
|
92
|
+
nodes_to_move.each do |path|
|
93
|
+
if ErpTechSvcs::Config.file_storage == :filesystem and !File.exists?(File.join(@file_support.root, path))
|
94
|
+
result = {:success => false, :msg => 'File does not exist.'}
|
95
|
+
else
|
96
|
+
file = @assets_model.files.find(:first, :conditions => ['name = ? and directory = ?', ::File.basename(path), ::File.dirname(path)])
|
97
|
+
result, message = file.move(new_parent_path)
|
98
|
+
end
|
99
|
+
messages << message
|
100
|
+
end
|
101
|
+
render :json => {:success => true, :msg => messages.join(',')}
|
102
|
+
rescue Exception => e
|
103
|
+
render :json => {:success => false, :msg => e.message}
|
96
104
|
end
|
97
|
-
|
98
|
-
render :json => result
|
99
105
|
end
|
100
106
|
|
101
107
|
def delete_file
|
108
|
+
messages = []
|
109
|
+
|
102
110
|
if @context == Website
|
103
111
|
capability_type = "view"
|
104
112
|
capability_resource = "SiteFileAsset"
|
@@ -107,26 +115,33 @@ module Knitkit
|
|
107
115
|
capability_resource = "GlobalFileAsset"
|
108
116
|
end
|
109
117
|
|
118
|
+
nodes_to_delete = (params[:selected_nodes] ? JSON(params[:selected_nodes]) : [params[:node]])
|
119
|
+
|
110
120
|
model = DesktopApplication.find_by_internal_identifier('knitkit')
|
111
121
|
begin
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
+
result = false
|
123
|
+
nodes_to_delete.each do |path|
|
124
|
+
current_user.with_capability(model, capability_type, capability_resource) do
|
125
|
+
path = "#{path}/" if params[:leaf] == 'false' and path.match(/\/$/).nil?
|
126
|
+
begin
|
127
|
+
name = File.basename(path)
|
128
|
+
result, message, is_folder = @file_support.delete_file(File.join(@file_support.root,path))
|
129
|
+
if result and !is_folder
|
130
|
+
file = @assets_model.files.find(:first, :conditions => ['name = ? and directory = ?', ::File.basename(path), ::File.dirname(path)])
|
131
|
+
file.destroy
|
132
|
+
end
|
133
|
+
messages << message
|
134
|
+
rescue Exception=>ex
|
135
|
+
Rails.logger.error ex.message
|
136
|
+
Rails.logger.error ex.backtrace.join("\n")
|
137
|
+
render :json => {:success => false, :error => "Error deleting #{name}"} and return
|
122
138
|
end
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
render :json => result
|
139
|
+
end # end current_user.with_capability
|
140
|
+
end # end nodes_to_delete.each
|
141
|
+
if result
|
142
|
+
render :json => {:success => true, :message => messages.join(',')}
|
143
|
+
else
|
144
|
+
render :json => {:success => false, :error => messages.join(',')}
|
130
145
|
end
|
131
146
|
rescue ErpTechSvcs::Utils::CompassAccessNegotiator::Errors::UserDoesNotHaveCapability=>ex
|
132
147
|
render :json => {:success => false, :message => ex.message}
|
@@ -209,8 +224,7 @@ module Knitkit
|
|
209
224
|
@context = params[:context].to_sym
|
210
225
|
|
211
226
|
if @context == :website
|
212
|
-
|
213
|
-
website_id = request.env['HTTP_X_WEBSITEID'].blank? ? params[:website_id] : request.env['HTTP_X_WEBSITEID']
|
227
|
+
website_id = params[:website_id]
|
214
228
|
(@assets_model = website_id.blank? ? nil : Website.find(website_id))
|
215
229
|
|
216
230
|
render :inline => {:success => false, :error => "No Website Selected"}.to_json if (@assets_model.nil? && params[:action] != "base_path")
|
@@ -23,12 +23,12 @@ module Knitkit
|
|
23
23
|
begin
|
24
24
|
current_user.with_capability(model, capability_type, capability_resource) do
|
25
25
|
result = {}
|
26
|
-
upload_path =
|
27
|
-
name =
|
28
|
-
data = request.
|
26
|
+
upload_path = params[:directory]
|
27
|
+
name = params[:name]
|
28
|
+
data = request.raw_post
|
29
29
|
|
30
30
|
begin
|
31
|
-
upload_path == 'root_node' ? @assets_model.add_file(data, File.join(
|
31
|
+
upload_path == 'root_node' ? @assets_model.add_file(data, File.join(base_path,name)) : @assets_model.add_file(data, File.join(@file_support.root,upload_path,name))
|
32
32
|
result = {:success => true}
|
33
33
|
rescue Exception=>ex
|
34
34
|
logger.error ex.message
|
@@ -45,6 +45,8 @@ module Knitkit
|
|
45
45
|
end
|
46
46
|
|
47
47
|
def delete_file
|
48
|
+
messages = []
|
49
|
+
|
48
50
|
if @context == Website
|
49
51
|
capability_type = "view"
|
50
52
|
capability_resource = "SiteImageAsset"
|
@@ -53,26 +55,33 @@ module Knitkit
|
|
53
55
|
capability_resource = "GlobalImageAsset"
|
54
56
|
end
|
55
57
|
|
58
|
+
nodes_to_delete = (params[:selected_nodes] ? JSON(params[:selected_nodes]) : [params[:node]])
|
59
|
+
|
56
60
|
model = DesktopApplication.find_by_internal_identifier('knitkit')
|
57
61
|
begin
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
62
|
+
result = false
|
63
|
+
nodes_to_delete.each do |path|
|
64
|
+
current_user.with_capability(model, capability_type, capability_resource) do
|
65
|
+
path = "#{path}/" if params[:leaf] == 'false' and path.match(/\/$/).nil?
|
66
|
+
begin
|
67
|
+
name = File.basename(path)
|
68
|
+
result, message, is_folder = @file_support.delete_file(File.join(@file_support.root,path))
|
69
|
+
if result and !is_folder
|
70
|
+
file = @assets_model.files.find(:first, :conditions => ['name = ? and directory = ?', ::File.basename(path), ::File.dirname(path)])
|
71
|
+
file.destroy
|
72
|
+
end
|
73
|
+
messages << message
|
74
|
+
rescue Exception=>ex
|
75
|
+
Rails.logger.error ex.message
|
76
|
+
Rails.logger.error ex.backtrace.join("\n")
|
77
|
+
render :json => {:success => false, :error => "Error deleting #{name}"} and return
|
68
78
|
end
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
render :json => result
|
79
|
+
end # end current_user.with_capability
|
80
|
+
end # end nodes_to_delete.each
|
81
|
+
if result
|
82
|
+
render :json => {:success => true, :message => messages.join(',')}
|
83
|
+
else
|
84
|
+
render :json => {:success => false, :error => messages.join(',')}
|
76
85
|
end
|
77
86
|
rescue ErpTechSvcs::Utils::CompassAccessNegotiator::Errors::UserDoesNotHaveCapability=>ex
|
78
87
|
render :json => {:success => false, :message => ex.message}
|
@@ -155,23 +155,25 @@ module Knitkit
|
|
155
155
|
end
|
156
156
|
|
157
157
|
def save_move
|
158
|
+
result = {}
|
159
|
+
nodes_to_move = (params[:selected_nodes] ? JSON(params[:selected_nodes]) : [params[:node]])
|
158
160
|
model = DesktopApplication.find_by_internal_identifier('knitkit')
|
159
161
|
begin
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
162
|
+
nodes_to_move.each do |node|
|
163
|
+
current_user.with_capability(model, 'view', 'Theme') do
|
164
|
+
path = File.join(@file_support.root, node)
|
165
|
+
new_parent_path = File.join(@file_support.root, params[:parent_node])
|
166
|
+
|
167
|
+
unless @file_support.exists? path
|
168
|
+
result = {:success => false, :msg => 'File does not exist.'}
|
169
|
+
else
|
170
|
+
theme_file = get_theme_file(path)
|
171
|
+
theme_file.move(params[:parent_node])
|
172
|
+
result = {:success => true, :msg => "#{File.basename(path)} was moved to #{new_parent_path} successfully"}
|
173
|
+
end
|
171
174
|
end
|
172
|
-
|
173
|
-
render :json => result
|
174
175
|
end
|
176
|
+
render :json => result
|
175
177
|
rescue ErpTechSvcs::Utils::CompassAccessNegotiator::Errors::UserDoesNotHaveCapability=>ex
|
176
178
|
render :json => {:success => false, :message => ex.message}
|
177
179
|
end
|
@@ -207,9 +209,9 @@ module Knitkit
|
|
207
209
|
begin
|
208
210
|
current_user.with_capability(model, 'view', 'Theme') do
|
209
211
|
result = {}
|
210
|
-
upload_path =
|
211
|
-
name =
|
212
|
-
data = request.
|
212
|
+
upload_path = params[:directory]
|
213
|
+
name = params[:name]
|
214
|
+
data = request.raw_post
|
213
215
|
|
214
216
|
theme = get_theme(upload_path)
|
215
217
|
name = File.join(@file_support.root, upload_path, name)
|
@@ -231,25 +233,32 @@ module Knitkit
|
|
231
233
|
end
|
232
234
|
|
233
235
|
def delete_file
|
236
|
+
messages = []
|
237
|
+
nodes_to_delete = (params[:selected_nodes] ? JSON(params[:selected_nodes]) : [params[:node]])
|
234
238
|
model = DesktopApplication.find_by_internal_identifier('knitkit')
|
235
239
|
begin
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
240
|
+
result = false
|
241
|
+
nodes_to_delete.each do |path|
|
242
|
+
current_user.with_capability(model, 'view', 'Theme') do
|
243
|
+
begin
|
244
|
+
name = File.basename(path)
|
245
|
+
result, message, is_folder = @file_support.delete_file(File.join(@file_support.root,path))
|
246
|
+
if result && !is_folder
|
247
|
+
theme_file = get_theme_file(path)
|
248
|
+
theme_file.destroy
|
249
|
+
end
|
250
|
+
messages << message
|
251
|
+
rescue Exception=>ex
|
252
|
+
Rails.logger.error ex.message
|
253
|
+
Rails.logger.error ex.backtrace.join("\n")
|
254
|
+
render :json => {:success => false, :error => "Error deleting #{name}"} and return
|
245
255
|
end
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
render :json => result
|
256
|
+
end # end current_user.with_capability
|
257
|
+
end # end nodes_to_delete.each
|
258
|
+
if result
|
259
|
+
render :json => {:success => true, :message => messages.join(',')}
|
260
|
+
else
|
261
|
+
render :json => {:success => false, :error => messages.join(',')}
|
253
262
|
end
|
254
263
|
rescue ErpTechSvcs::Utils::CompassAccessNegotiator::Errors::UserDoesNotHaveCapability=>ex
|
255
264
|
render :json => {:success => false, :message => ex.message}
|