caboose-cms 0.1.93 → 0.1.96

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.
@@ -57,7 +57,7 @@ module Caboose
57
57
  # Returns the currently logged in user
58
58
  def logged_in_user
59
59
  if (!logged_in?)
60
- return User.where('username' => 'elo').first
60
+ return User.logged_out_user
61
61
  end
62
62
  #return nil if !logged_in?
63
63
  return session["app_user"]
@@ -23,7 +23,7 @@ module Caboose
23
23
 
24
24
  user = logged_in_user
25
25
  if (!user.is_allowed(page, 'view'))
26
- if (user.id == User.LOGGED_OUT_USER_ID)
26
+ if (user.id == User.logged_out_user_id)
27
27
  redirect_to "/login?return_url=" + URI.encode(request.fullpath)
28
28
  return
29
29
  else
@@ -155,11 +155,11 @@ class Caboose::Page < ActiveRecord::Base
155
155
  end
156
156
 
157
157
  def self.is_allowed(user, page_id, action)
158
- user = User.find(User.LOGGED_OUT_USER_ID) if user.nil?
158
+ user = User.logged_out_user if user.nil?
159
159
 
160
160
  # Allow a user id to be sent instead of a user object
161
161
  user = User.find(user) if user.is_a?(Integer)
162
- user.role_ids = [User.LOGGED_OUT_ROLE_ID] if user.role_ids.nil?
162
+ user.role_ids = [Role.logged_out_role_id] if user.role_ids.nil?
163
163
 
164
164
  t = PagePermission.table
165
165
  reqs = nil
@@ -8,11 +8,31 @@ class Caboose::Role < ActiveRecord::Base
8
8
 
9
9
  attr_accessible :name, :description, :parent_id
10
10
  attr_accessor :children
11
+
12
+ def self.admin_role
13
+ return self.where('name' => 'Admin').first
14
+ end
15
+
16
+ def self.admin_role_id
17
+ return self.where('name' => 'Admin').limit(1).pluck(:id)[0]
18
+ end
19
+
20
+ def self.logged_out_role
21
+ return self.where('name' => 'Everyone Logged Out').first
22
+ end
23
+
24
+ def self.logged_out_role_id
25
+ return self.where('name' => 'Everyone Logged Out').limit(1).pluck(:id)[0]
26
+ end
27
+
28
+ def self.logged_in_role
29
+ return self.where('name' => 'Everyone Logged In').first
30
+ end
31
+
32
+ def self.logged_in_role_id
33
+ return self.where('name' => 'Everyone Logged In').limit(1).pluck(:id)[0]
34
+ end
11
35
 
12
- ADMIN_ROLE_ID = 1
13
- LOGGED_OUT_ROLE_ID = 2
14
- LOGGED_IN_ROLE_ID = 3
15
-
16
36
  def is_allowed(resource, action)
17
37
 
18
38
  # Check for the admin permission
@@ -4,7 +4,13 @@ class Caboose::User < ActiveRecord::Base
4
4
  has_and_belongs_to_many :roles
5
5
  attr_accessible :email, :first_name, :last_name, :username, :token, :password
6
6
 
7
- LOGGED_OUT_USER_ID = 2
7
+ def self.logged_out_user
8
+ return self.where('username' => 'elo').first
9
+ end
10
+
11
+ def self.logged_out_user_id
12
+ return self.where('username' => 'elo').limit(1).pluck(:id)[0]
13
+ end
8
14
 
9
15
  def is_allowed(resource, action)
10
16
  for role in roles
@@ -18,7 +18,7 @@ end
18
18
  <div id='caboose_station_wrapper' class='state_<%= initial_state %>'<%= raw style %>>
19
19
  <div id='caboose_station'>
20
20
 
21
- <% if (@user.nil? || @user.id == Caboose::User::LOGGED_OUT_USER_ID) %>
21
+ <% if (@user.nil? || @user == Caboose::User.logged_out_user) %>
22
22
  <h2>Caboose Station</h2>
23
23
  <a href='/login' class='login'>Login</a>
24
24
  <% else %>
@@ -1,6 +1,6 @@
1
1
 
2
2
  <div id='top_nav'>
3
- <% if (@user.nil? || @user.id == Caboose::User::LOGGED_OUT_USER_ID) %>
3
+ <% if (@user.nil? || @user == Caboose::User.logged_out_user) %>
4
4
  <%= link_to "Login", "/login?return_url=#{request.fullpath}", :id => 'caboose_login' %>
5
5
  <% else %>
6
6
  <%= link_to "Control Panel", '#', :id => 'caboose_conductor' %>
@@ -120,6 +120,8 @@ class CabooseHelper
120
120
  def init_assets
121
121
  puts "Adding the layout files..."
122
122
  init_file('app/views/layouts/layout_default.html.erb')
123
+ puts "Adding the layout files..."
124
+ init_file('app/assets/stylesheets/login.css')
123
125
  end
124
126
 
125
127
  def init_tinymce
@@ -1,3 +1,3 @@
1
1
  module Caboose
2
- VERSION = '0.1.93'
2
+ VERSION = '0.1.96'
3
3
  end
File without changes
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.1.93
4
+ version: 0.1.96
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-06-13 00:00:00.000000000 Z
12
+ date: 2013-06-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -228,6 +228,7 @@ files:
228
228
  - lib/caboose/version.rb
229
229
  - lib/caboose.rb
230
230
  - lib/sample_files/layout_default.html.erb
231
+ - lib/sample_files/login.css
231
232
  - lib/sample_files/tinymce.yml
232
233
  - lib/tasks/caboose.rake
233
234
  - MIT-LICENSE