caboose-cms 0.5.181 → 0.5.182

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MjEwZDBiYWFlZjVhMGI0MTk1YzQyZWE1NDdhZTVjNzdhNzU4ZDE1Yg==
4
+ MzBhZmYwZjg0NGUzOTIxY2VkM2NhZjE5MjEwOWM5YTJjNmI3MTI0Yg==
5
5
  data.tar.gz: !binary |-
6
- N2E3NWNjYTEwZjIyOWEwMmUxYzk0OWI1ZjYxM2E4OWNlMWZkODBhMw==
6
+ NDEzMWQ5N2RiZjMzNjkzZmJhN2VlOWMxNTE1ZjVhYjU0YWViNmNiZA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ZTg3MzQxNDlkZmVmYmU1M2E1NmIzMDUxZDRlZjZhZmZhMWRkNGY3YzExMDlj
10
- Y2EyZGYxYmZjZTVhNTc0OGE1Yzg0NWRjNWJkOWY3MTc1N2JiNzdkZWZmZTli
11
- MmE2NjkxODYyN2U5OTE2MGIwOWM4YThiM2JhNmMxMWQwM2E1YWY=
9
+ ZThhNTVjMDc2ODVmY2U1OWUyYjU2NzEyMmJmMzdhNTAzZTUzMzM1NGFlMzY0
10
+ ZGMwNGY3ZTExOGNlOTY2ZTNjZWE5NDE4Y2YzNWFhMDk0NTg5ZTdjNzNmYjc2
11
+ N2VhNzRhODk5M2E0MTE1NDk3OWM5MjUwZjZkYjQzNDhmNDJkZjg=
12
12
  data.tar.gz: !binary |-
13
- MjA5OTM5MmNmZDE4NDQyYzgzZGRiMGMxMDRiYjkxYzlhZDZiOTkzZGE3OGQy
14
- YjViZTBkNDU5MDNmOGZlZWE1Y2JlZjBhM2U5ODY2ZjQyZTRmNzk5NjBhMDY0
15
- ZmE0NmJjODU3YjgxNjRkOTYxZjQ5NWY3MTc2NWM0YTY5ZDM4OTY=
13
+ NDM5MmI4NjZlODc2ZjEyMzc4ZTA2Zjc3YzA1OTM5NmVlZTMxZWIwZTQ4MGNi
14
+ ZmJhZGZiOWZkNjI3ZDY1NDUzOWVhMTYxNzFkOTQ2YmYwM2RjMDE2NmU2YzY2
15
+ YmMzOGE2OWM1OWM4ZTY3YTRjMDVhOTIxY2IxMWU3MTA3YjFjOTU=
@@ -11,6 +11,10 @@ module Caboose
11
11
  # GET /admin/sites
12
12
  def admin_index
13
13
  return if !user_is_allowed('sites', 'view')
14
+ if @site.name != 'application'
15
+ @error = "You are not allowed to manage sites."
16
+ render :file => 'caboose/extras/error' and return
17
+ end
14
18
 
15
19
  @pager = PageBarGenerator.new(params, {
16
20
  'name_like' => '',
@@ -27,31 +31,62 @@ module Caboose
27
31
  # GET /admin/sites/new
28
32
  def admin_new
29
33
  return if !user_is_allowed('sites', 'add')
34
+ if @site.name != 'application'
35
+ @error = "You are not allowed to manage sites."
36
+ render :file => 'caboose/extras/error' and return
37
+ end
38
+
30
39
  @site = Site.new
31
40
  end
32
41
 
33
42
  # GET /admin/sites/:id
34
43
  def admin_edit
35
44
  return if !user_is_allowed('sites', 'edit')
45
+ if @site.name != 'application'
46
+ @error = "You are not allowed to manage sites."
47
+ render :file => 'caboose/extras/error' and return
48
+ end
49
+
36
50
  @site = Site.find(params[:id])
51
+
52
+ # Create an admin user for the account
53
+ if User.where(:username => 'admin', :site_id => @site.id).exists?
54
+ admin_user = User.create(:username => 'admin', :site_id => @site.id)
55
+ admin_role = Role.where(:name => 'Admin').first
56
+ if admin_role
57
+ RoleMembership.create(:user_id => admin_user.id, :role_id => admin_role.id)
58
+ else
59
+ Caboose.log("Error: no admin role exists.")
60
+ end
61
+ end
37
62
  end
38
63
 
39
64
  # GET /admin/sites/:id/block-types
40
65
  def admin_edit_block_types
41
66
  return if !user_is_allowed('sites', 'edit')
67
+ if @site.name != 'application'
68
+ @error = "You are not allowed to manage sites."
69
+ render :file => 'caboose/extras/error' and return
70
+ end
71
+
42
72
  @site = Site.find(params[:id])
43
73
  end
44
74
 
45
75
  # GET /admin/sites/:id/delete
46
76
  def admin_delete_form
47
77
  return if !user_is_allowed('sites', 'edit')
78
+ if @site.name != 'application'
79
+ @error = "You are not allowed to manage sites."
80
+ render :file => 'caboose/extras/error' and return
81
+ end
48
82
  @site = Site.find(params[:id])
49
83
  end
50
84
 
51
85
  # POST /admin/sites
52
86
  def admin_add
53
87
  return if !user_is_allowed('sites', 'add')
54
-
88
+ render :json => { :error => "You are not allowed to manage sites." } and return if @site.name != 'application'
89
+
55
90
  resp = StdClass.new
56
91
  site = Site.new
57
92
  site.name = params[:name].strip
@@ -65,12 +100,24 @@ module Caboose
65
100
  resp.redirect = "/admin/sites/#{site.id}"
66
101
  end
67
102
 
103
+ # Create an admin user for the account
104
+ if User.where(:username => 'admin', :site_id => site.id).exists?
105
+ admin_user = User.create(:username => 'admin', :site_id => site.id)
106
+ admin_role = Role.where(:name => 'Admin').first
107
+ if admin_role
108
+ RoleMembership.create(:user_id => admin_user.id, :role_id => admin_role.id)
109
+ else
110
+ Caboose.log("Error: no admin role exists.")
111
+ end
112
+ end
113
+
68
114
  render :json => resp
69
115
  end
70
116
 
71
117
  # PUT /admin/sites/:id
72
118
  def admin_update
73
119
  return if !user_is_allowed('sites', 'edit')
120
+ render :json => { :error => "You are not allowed to manage sites." } and return if @site.name != 'application'
74
121
 
75
122
  resp = StdClass.new
76
123
  site = Site.find(params[:id])
@@ -92,6 +139,7 @@ module Caboose
92
139
  # POST /admin/sites/:id/logo
93
140
  def admin_update_logo
94
141
  return if !user_is_allowed('sites', 'edit')
142
+ render :json => { :error => "You are not allowed to manage sites." } and return if @site.name != 'application'
95
143
 
96
144
  site = Site.find(params[:id])
97
145
  site.logo = params[:logo]
@@ -106,6 +154,8 @@ module Caboose
106
154
  # DELETE /admin/sites/:id
107
155
  def admin_delete
108
156
  return if !user_is_allowed('sites', 'delete')
157
+ render :json => { :error => "You are not allowed to manage sites." } and return if @site.name != 'application'
158
+
109
159
  site = Site.find(params[:id])
110
160
  site.destroy
111
161
 
@@ -118,6 +168,8 @@ module Caboose
118
168
  # POST /admin/sites/:id/members
119
169
  def admin_add_member
120
170
  return if !user_is_allowed('sites', 'edit')
171
+ render :json => { :error => "You are not allowed to manage sites." } and return if @site.name != 'application'
172
+
121
173
  sm = SiteMembership.where(:site_id => params[:id], :user_id => params[:user_id]).first
122
174
  sm = SiteMembership.create(:site_id => params[:id], :user_id => params[:user_id]) if sm.nil?
123
175
  sm.role = params[:role]
@@ -128,6 +180,8 @@ module Caboose
128
180
  # DELETE /admin/sites/:id/members/:user_id
129
181
  def admin_remove_member
130
182
  return if !user_is_allowed('sites', 'edit')
183
+ render :json => { :error => "You are not allowed to manage sites." } and return if @site.name != 'application'
184
+
131
185
  SiteMembership.where(:site_id => params[:id], :user_id => params[:user_id]).destroy_all
132
186
  render :json => true
133
187
  end
@@ -135,6 +189,8 @@ module Caboose
135
189
  # GET /admin/sites/options
136
190
  def options
137
191
  return if !user_is_allowed('sites', 'view')
192
+ render :json => { :error => "You are not allowed to manage sites." } and return if @site.name != 'application'
193
+
138
194
  options = Site.reorder('name').all.collect { |s| { 'value' => s.id, 'text' => s.name }}
139
195
  render :json => options
140
196
  end
@@ -23,25 +23,7 @@ module Caboose
23
23
  return if !user_is_allowed('users', 'view')
24
24
 
25
25
  @gen = PageBarGenerator.new(params, {
26
- 'first_name_like' => '',
27
- 'last_name_like' => '',
28
- 'username_like' => '',
29
- 'email_like' => '',
30
- },{
31
- 'model' => 'Caboose::User',
32
- 'sort' => 'last_name, first_name',
33
- 'desc' => false,
34
- 'base_url' => '/admin/users',
35
- 'use_url_params' => false
36
- })
37
- @users = @gen.items
38
- end
39
-
40
- # GET /admin/users
41
- def index
42
- return if !user_is_allowed('users', 'view')
43
-
44
- @gen = PageBarGenerator.new(params, {
26
+ 'site_id' => @site.id,
45
27
  'first_name_like' => '',
46
28
  'last_name_like' => '',
47
29
  'username_like' => '',
@@ -183,6 +165,7 @@ module Caboose
183
165
  save = true
184
166
  params.each do |name,value|
185
167
  case name
168
+ when 'site_id' then user.site_id = value
186
169
  when 'first_name' then user.first_name = value
187
170
  when 'last_name' then user.last_name = value
188
171
  when 'username' then user.username = value
@@ -12,7 +12,7 @@ class Caboose::CorePlugin < Caboose::CaboosePlugin
12
12
  item['children'] << { 'id' => 'redirects' , 'text' => 'Permanent Redirects' , 'href' => '/admin/redirects' , 'modal' => false } if user.is_allowed('redirects' , 'view')
13
13
  item['children'] << { 'id' => 'permissions' , 'text' => 'Permissions' , 'href' => '/admin/permissions' , 'modal' => false } if user.is_allowed('permissions' , 'view')
14
14
  item['children'] << { 'id' => 'roles' , 'text' => 'Roles' , 'href' => '/admin/roles' , 'modal' => false } if user.is_allowed('roles' , 'view')
15
- item['children'] << { 'id' => 'sites' , 'text' => 'Sites' , 'href' => '/admin/sites' , 'modal' => false } if user.is_allowed('sites' , 'view') if site.name == 'application'
15
+ item['children'] << { 'id' => 'sites' , 'text' => 'Sites' , 'href' => '/admin/sites' , 'modal' => false } if user.is_allowed('sites' , 'view') if site.name == 'application'
16
16
  item['children'] << { 'id' => 'smtp' , 'text' => 'SMTP (Mail)' , 'href' => '/admin/smtp' , 'modal' => false } if user.is_allowed('smtp' , 'view')
17
17
  item['children'] << { 'id' => 'social' , 'text' => 'Social Media' , 'href' => '/admin/social' , 'modal' => false } if user.is_allowed('social' , 'view')
18
18
  item['children'] << { 'id' => 'store' , 'text' => 'Store' , 'href' => '/admin/store' , 'modal' => false } if user.is_allowed('store' , 'view')
@@ -567,7 +567,7 @@ class Caboose::Schema < Caboose::Utilities::Schema
567
567
  [ :description , :text ],
568
568
  [ :under_construction_html , :text ],
569
569
  [ :use_store , :boolean , { :default => false }],
570
- [ :logo , :attachment ]
570
+ [ :logo , :attachment ]
571
571
  ],
572
572
  Caboose::SiteMembership => [
573
573
  [ :site_id , :integer ],
@@ -1,9 +1,9 @@
1
1
  <h1>Users</h1>
2
2
 
3
3
  <form action='/admin/users' method='get' class='search_form'>
4
- <input type='text' name='first_name_like' placeholder='First name' />
5
- <input type='text' name='last_name_like' placeholder='Last name' />
6
- <input type='text' name='email_like' placeholder='Email' />
4
+ <input type='text' name='first_name_like' value="<%= @gen.params['first_name_like'] %>" placeholder='First name' />
5
+ <input type='text' name='last_name_like' value="<%= @gen.params['last_name_like'] %>" placeholder='Last name' />
6
+ <input type='text' name='email_like' value="<%= @gen.params['email_like'] %>" placeholder='Email' />
7
7
  <input type='submit' value='Search' />
8
8
  </form>
9
9
 
@@ -1,3 +1,3 @@
1
1
  module Caboose
2
- VERSION = '0.5.181'
2
+ VERSION = '0.5.182'
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.5.181
4
+ version: 0.5.182
5
5
  platform: ruby
6
6
  authors:
7
7
  - William Barry