caboose-cms 0.7.36 → 0.7.38

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e43b30634033a67c5d9855f32f696fb96f7e809f
4
- data.tar.gz: d804701252602f78b36dcdd91d4505521fdf9d81
3
+ metadata.gz: 95c98700fe9e21bf2a9fb5cf9547ffaebc869d5e
4
+ data.tar.gz: ae7208e3ecf4a964735463781af60da3f571f8ad
5
5
  SHA512:
6
- metadata.gz: 280a55f897ee7bafea5d2d2f2582f79ca8a8c311e868362137be0946d0d1a9675b558c439505daccce8db3590f778e870fed1eb5ee78e4b38d6f4f2f5d09cb5c
7
- data.tar.gz: 2d227c4d3e18255129b4b099bdc99c92187126848630ea20cb3ae3b8a31e9f8ba310246f2e1083a86d5103a1c4e06eb26b9ef5b996472beb48fa7b28f65e76d2
6
+ metadata.gz: a6707d9d5bec9203435e4456f019a1741c95a82de9fae6f03c3c9d40c003f7c754e1e8a1f0703d3772106d0de6e448d50898eda43c5bf910efcdc6379119ba17
7
+ data.tar.gz: c1cc6916af5c0d24738074a7cd0cac7479a778393620b3f5a7344a4a8fb37927792a5c9dc4c44752a8f7a94e7e3eb511049c901f78adf45caa298bd8178e851e
@@ -178,7 +178,17 @@ module Caboose
178
178
  @page = Page.find(params[:id])
179
179
  render :layout => 'caboose/admin'
180
180
  end
181
-
181
+
182
+ # PUT /admin/pages/:id/update-child-permissions
183
+ def admin_update_child_permissions
184
+ return unless user_is_allowed('pages', 'edit')
185
+ page = Page.find(params[:id])
186
+ if page
187
+ Page.update_child_perms(page.id)
188
+ end
189
+ render :json => { :success => true }
190
+ end
191
+
182
192
  # GET /admin/pages/:id/content
183
193
  def admin_edit_content
184
194
  return unless user_is_allowed('pages', 'edit')
@@ -126,14 +126,15 @@ class Caboose::Page < ActiveRecord::Base
126
126
  def self.update_child_perms(page_id)
127
127
  page = self.find(page_id)
128
128
 
129
- viewers_ids = Role.roles_with_page_permission(page_id, 'view').collect {|r| r.id }
130
- editors_ids = Role.roles_with_page_permission(page_id, 'edit').collect {|r| r.id }
131
- approvers_ids = Role.roles_with_page_permission(page_id, 'approve').collect {|r| r.id }
132
-
129
+ viewer_ids = Caboose::PagePermission.where(:page_id => page_id, :action => 'view' ).all.collect{ |pp| pp.role_id }
130
+ editor_ids = Caboose::PagePermission.where(:page_id => page_id, :action => 'edit' ).all.collect{ |pp| pp.role_id }
131
+ approver_ids = Caboose::PagePermission.where(:page_id => page_id, :action => 'approve').all.collect{ |pp| pp.role_id }
132
+
133
133
  self.update_child_perms_helper(page, viewer_ids, editor_ids, approver_ids)
134
134
  end
135
135
 
136
136
  def self.update_child_perms_helper(page, viewer_ids, editor_ids, approver_ids)
137
+
137
138
  self.update_authorized_for_action(page.id, 'view' , viewer_ids)
138
139
  self.update_authorized_for_action(page.id, 'edit' , editor_ids)
139
140
  self.update_authorized_for_action(page.id, 'approve' , approver_ids)
@@ -16,6 +16,9 @@
16
16
  </tr>
17
17
  <% end %>
18
18
  </table>
19
+
20
+ <div id='message'></div>
21
+ <p><input type='button' value='Copy Permissions to Child Pages' onclick='update_child_permissions(<%= @page.id %>);' /></p>
19
22
 
20
23
  <%= render :partial => 'caboose/pages/admin_footer' %>
21
24
 
@@ -42,5 +45,27 @@ function toggle_page_permission(role_id, checked, action)
42
45
  });
43
46
  }
44
47
 
48
+ function update_child_permissions(page_id, confirm)
49
+ {
50
+ if (!confirm)
51
+ {
52
+ var p = $('<p/>').addClass('note warning')
53
+ .append("Are you sure you want to copy the permissions to child pages?<br /><br />")
54
+ .append($('<input/>').attr('type', 'button').val('Yes').click(function(e) { update_child_permissions(page_id, true); })).append(' ')
55
+ .append($('<input/>').attr('type', 'button').val('No').click(function(e) { $('#message').empty(); }));
56
+ $('#message').empty().append(p);
57
+ return;
58
+ }
59
+ $('#message').empty().append("<p class='loading'>Setting child permissions...</p>");
60
+ $.ajax({
61
+ url: '/admin/pages/' + page_id + '/update-child-permissions',
62
+ type: 'put',
63
+ success: function(resp) {
64
+ if (resp.error) $('#message').html("<p class='note error'>" + resp.error + "</p>");
65
+ if (resp.success) $('#message').html("<p class='note success'>The permissions have been set successfully.</p>");
66
+ }
67
+ });
68
+ }
69
+
45
70
  </script>
46
71
  <% end %>
@@ -284,8 +284,9 @@ Caboose::Engine.routes.draw do
284
284
  put "/admin/pages/:id/layout" => "pages#admin_update_layout"
285
285
  put "/admin/pages/:id/viewers" => "pages#admin_update_viewers"
286
286
  put "/admin/pages/:id/editors" => "pages#admin_update_editors"
287
- get "/admin/pages/:id" => "pages#admin_edit_general"
288
- put "/admin/pages/:id" => "pages#admin_update"
287
+ get "/admin/pages/:id" => "pages#admin_edit_general"
288
+ put "/admin/pages/:id/update-child-permissions" => "pages#admin_update_child_permissions"
289
+ put "/admin/pages/:id" => "pages#admin_update"
289
290
  get "/admin/pages" => "pages#admin_index"
290
291
  post "/admin/pages" => "pages#admin_create"
291
292
  delete "/admin/pages/:id" => "pages#admin_delete"
@@ -1,3 +1,3 @@
1
1
  module Caboose
2
- VERSION = '0.7.36'
2
+ VERSION = '0.7.38'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: caboose-cms
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.36
4
+ version: 0.7.38
5
5
  platform: ruby
6
6
  authors:
7
7
  - William Barry