cms-fortress 1.0.6 → 1.0.7

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.6
1
+ 1.0.7
@@ -26,6 +26,21 @@ class Cms::Fortress::RolesController < Admin::Cms::BaseController
26
26
  end
27
27
  end
28
28
 
29
+ def refresh
30
+ @cms_fortress_role = Cms::Fortress::Role.find(params[:id])
31
+ @cms_fortress_role.load_defaults
32
+
33
+ respond_to do |format|
34
+ if @cms_fortress_role.save
35
+ format.html { redirect_to @cms_fortress_role }
36
+ format.json { render json: @cms_fotress_role }
37
+ else
38
+ format.html { render action: "show" }
39
+ format.json { render json: @cms_fortress_role.errors, status: :unprocessable_entity }
40
+ end
41
+ end
42
+ end
43
+
29
44
  # GET /cms/fortress/roles/new
30
45
  # GET /cms/fortress/roles/new.json
31
46
  def new
@@ -94,6 +94,6 @@ class Cms::Fortress::UsersController < Admin::Cms::BaseController
94
94
  private
95
95
 
96
96
  def user_params
97
- params.require(:cms_fortress_user).permit(:email, :role_id, :password, :password_confirmation)
97
+ params.require(:cms_fortress_user).permit(:last_name, :first_name, :email, :role_id, :password, :password_confirmation)
98
98
  end
99
99
  end
@@ -3,6 +3,16 @@ module Cms
3
3
 
4
4
  module ApplicationHelper
5
5
 
6
+ def topnav_item(title, path, is_current = false)
7
+ css_class = is_current ? "active" : ""
8
+ content_tag(:li, link_to(title, path), class: css_class)
9
+ end
10
+
11
+ def leftnav_item(title, path, options = {})
12
+ content_tag(:li, active_link_to(title, path, options))
13
+ end
14
+
15
+
6
16
  def admin_page?
7
17
  controller_name.eql?('admin') && %w{settings roles users}.include?(action_name) ||
8
18
  controller_name.eql?('sites') && %w{index}.include?(action_name) ||
@@ -7,13 +7,41 @@ class Cms::Fortress::Role < ActiveRecord::Base
7
7
  accepts_nested_attributes_for :role_details, allow_destroy: true
8
8
 
9
9
  def load_defaults
10
+ # load user custom roles
11
+ if File.exist?(file = File.join(Rails.root, "config", "roles.yml"))
12
+ load_from_file(file)
13
+ end
14
+ puts file
15
+
10
16
  file = File.expand_path(File.join(File.dirname(__FILE__), "../../../../", "config", "roles.yml"))
11
- data = YAML.load_file(file)
17
+ load_from_file(file)
18
+ end
19
+
20
+ private
12
21
 
22
+ def load_from_file(file)
23
+ data = YAML.load_file(file)
13
24
  data.each do |k,v|
14
- role_details.build(:name => k.humanize, :command => k, :can_create => false, :can_update => false, :can_delete => false, :can_view => true)
15
- v.each {|m| role_details.build(:name => m.humanize, :command => "#{k}.#{m}", :can_create => true, :can_update => true, :can_delete => true, :can_view => true) }
25
+ role_details.build(
26
+ :name => k.humanize,
27
+ :command => k,
28
+ :can_create => false,
29
+ :can_update => false,
30
+ :can_delete => false,
31
+ :can_view => true
32
+ ) unless role_details.map(&:command).include?(k)
33
+
34
+ v.each do |m|
35
+ role_details.build(
36
+ :name => m.humanize,
37
+ :command => "#{k}.#{m}",
38
+ :can_create => true,
39
+ :can_update => true,
40
+ :can_delete => true,
41
+ :can_view => true
42
+ ) unless role_details.map(&:command).include?("#{k}.#{m}")
43
+ end
16
44
  end
17
- end
18
45
 
46
+ end
19
47
  end
@@ -1,7 +1,12 @@
1
1
  class Cms::Fortress::RoleDetail < ActiveRecord::Base
2
- # set_table_name :cms_fortress_role_details
3
2
  self.table_name = "cms_fortress_role_details"
4
- # attr_accessible :command, :can_create, :can_delete, :name, :can_update, :can_view
3
+
5
4
  belongs_to :role
6
5
 
6
+ default_scope { order(:command) }
7
+
8
+ def can_manage?
9
+ can_create?
10
+ end
11
+
7
12
  end
@@ -6,9 +6,9 @@ class CmsAbility
6
6
  if user && user.role && user.role.role_details
7
7
  user.role.role_details.each do |role|
8
8
  can :view, role.command if role.can_view?
9
- can :manage, role.command if role.can_create?
9
+ can :manage, role.command if role.can_manage?
10
10
 
11
- if role.can_create?
11
+ if role.can_manage?
12
12
  if role.command.eql?("settings.roles")
13
13
  can :manage, Cms::Fortress::Role
14
14
  elsif role.command.eql?("settings.sites")
@@ -23,36 +23,19 @@ class CmsAbility
23
23
  can :manage, Cms::Layout
24
24
  elsif role.command.eql?("designs.snippets")
25
25
  can :manage, Cms::Snippet
26
+ else
27
+ setup_role(role)
26
28
  end
27
29
  end
28
30
  end
29
31
  end
30
32
 
31
- # Define abilities for the passed in user here. For example:
32
- #
33
- # user ||= User.new # guest user (not logged in)
34
- # if user.admin?
35
- # can :manage, :all
36
- # else
37
- # can :read, :all
38
- # end
39
- #
40
- # The first argument to `can` is the action you are giving the user
41
- # permission to do.
42
- # If you pass :manage it will apply to every action. Other common actions
43
- # here are :read, :create, :update and :destroy.
44
- #
45
- # The second argument is the resource the user can perform the action on.
46
- # If you pass :all it will apply to every resource. Otherwise pass a Ruby
47
- # class of the resource.
48
- #
49
- # The third argument is an optional hash of conditions to further filter the
50
- # objects.
51
- # For example, here the user can only update published articles.
52
- #
53
- # can :update, Article, :published => true
54
- #
55
- # See the wiki for details:
56
- # https://github.com/ryanb/cancan/wiki/Defining-Abilities
57
33
  end
34
+
35
+ # override this if you have custom role assignment
36
+ def setup_role(role)
37
+
38
+ end
39
+
40
+
58
41
  end
File without changes
@@ -1,6 +1,7 @@
1
1
  .page-header
2
2
  .btn-group.pull-right
3
- = link_to t('.edit'), edit_cms_fortress_role_path(@cms_fortress_role), :class => 'btn'
3
+ =# link_to t('.edit'), edit_cms_fortress_role_path(@cms_fortress_role), :class => 'btn'
4
+ = link_to t('cms.fortress.roles.load'), refresh_cms_fortress_role_path(@cms_fortress_role), :class => 'btn', :method => :post
4
5
  = link_to t('cms.fortress.roles.back'), cms_fortress_roles_path, :class => 'btn'
5
6
  %h2= "Role: #{ @cms_fortress_role.name }"
6
7
  %p= @cms_fortress_role.description
@@ -10,15 +10,15 @@
10
10
  %ul.nav
11
11
  - if @site && !@site.new_record?
12
12
  - if can? :view, 'contents'
13
- %li{:class => content_page? ? 'active' : ''}
14
- = link_to t("cms.fortress.contents"), cms_fortress_contents_path # admin_cms_site_pages_path(@site)
13
+ = topnav_item t("cms.fortress.contents"), cms_fortress_contents_path, content_page?
15
14
 
16
15
  - if can? :view, 'designs'
17
- %li{:class => design_page? ? 'active' : ''}
18
- = link_to t("cms.fortress.design"), cms_fortress_design_path #(:site_id => @site)
16
+ = topnav_item t("cms.fortress.design"), cms_fortress_design_path, design_page?
17
+
19
18
  - if can? :view, 'settings'
20
- %li{:class => admin_page? ? 'active' : ''}
21
- = link_to t("cms.fortress.settings"), cms_fortress_settings_path
19
+ = topnav_item t("cms.fortress.settings"), cms_fortress_settings_path, admin_page?
20
+
21
+ = render 'cms/fortress/admin/topnav'
22
22
  %ul.nav.nav-pill.pull-right
23
23
  - if current_cms_fortress_user
24
24
  %li
@@ -5,6 +5,14 @@
5
5
  %ul
6
6
  - @cms_fortress_user.errors.full_messages.each do |msg|
7
7
  %li= msg
8
+ .control-group
9
+ = f.label :last_name, :class => 'control-label'
10
+ .controls
11
+ = f.text_field :last_name
12
+ .control-group
13
+ = f.label :first_name, :class => 'control-label'
14
+ .controls
15
+ = f.text_field :first_name
8
16
  .control-group
9
17
  = f.label :email, :class => 'control-label'
10
18
  .controls
@@ -4,6 +4,8 @@
4
4
 
5
5
  %table.table.table-hover.table-bordered
6
6
  %tr
7
+ %th Lastname
8
+ %th Firstname
7
9
  %th Email
8
10
  %th Role
9
11
  %th
@@ -11,6 +13,8 @@
11
13
 
12
14
  - @cms_fortress_users.each do |cms_fortress_user|
13
15
  %tr
16
+ %td= cms_fortress_user.last_name
17
+ %td= cms_fortress_user.first_name
14
18
  %td= cms_fortress_user.email
15
19
  %td= cms_fortress_user.role.name
16
20
  %td
@@ -4,27 +4,38 @@
4
4
  %ul.navigation
5
5
  - if admin_page?
6
6
  - if can? :view, 'settings.sites'
7
- %li= active_link_to t('admin.cms.base.sites'), admin_cms_sites_path, :active => ['admin/cms/sites']
7
+ = leftnav_item t('admin.cms.base.sites'), admin_cms_sites_path, :active => ['admin/cms/sites']
8
8
  - if can? :view, 'settings.roles'
9
- %li= active_link_to t('cms.fortress.roles.title'), cms_fortress_roles_path
9
+ = leftnav_item t('cms.fortress.roles.title'), cms_fortress_roles_path
10
10
  - if can? :view, 'settings.users'
11
- %li= active_link_to t('cms.fortress.users.title'), cms_fortress_users_path
11
+ = leftnav_item t('cms.fortress.users.title'), cms_fortress_users_path
12
+
13
+ = render 'cms/fortress/admin/left_settings_nav'
12
14
 
13
15
  - elsif design_page?
14
16
  - if @site && !@site.new_record?
15
17
  - if can? :view, 'designs.layouts'
16
- %li= active_link_to t('admin.cms.base.layouts'), admin_cms_site_layouts_path(@site)
18
+ = leftnav_item t('admin.cms.base.layouts'), admin_cms_site_layouts_path(@site)
17
19
  - if can? :view, 'designs.snippets'
18
- %li= active_link_to t('admin.cms.base.snippets'), admin_cms_site_snippets_path(@site)
19
- - else
20
+ = leftnav_item t('admin.cms.base.snippets'), admin_cms_site_snippets_path(@site)
21
+
22
+ = render 'cms/fortress/admin/left_designs_nav'
23
+
24
+ - elsif content_page?
20
25
  - if @site && !@site.new_record?
21
26
  - if can? :view, 'contents.pages'
22
- %li= active_link_to t('admin.cms.base.pages'), admin_cms_site_pages_path(@site)
27
+ = leftnav_item t('admin.cms.base.pages'), admin_cms_site_pages_path(@site)
23
28
  - if can? :view, 'contents.files'
24
- %li= active_link_to t('admin.cms.base.files'), admin_cms_site_files_path(@site)
29
+ = leftnav_item t('admin.cms.base.files'), admin_cms_site_files_path(@site)
30
+
31
+ = render 'cms/fortress/admin/left_contents_nav'
25
32
 
26
33
  = cms_hook :navigation
27
34
 
35
+ - else
36
+ = render 'cms/fortress/admin/left_nav'
37
+
38
+
28
39
  = render '/admin/cms/partials/navigation_inner'
29
40
 
30
41
  = render '/admin/cms/partials/navigation_after'
data/cms-fortress.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "cms-fortress"
8
- s.version = "1.0.6"
8
+ s.version = "1.0.7"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Melvin Sembrano"]
12
- s.date = "2013-12-12"
12
+ s.date = "2013-12-15"
13
13
  s.description = "Comfortable Mexican Sofa (CMS) - User and role management extension"
14
14
  s.email = "melvinsembrano@gmail.com"
15
15
  s.extra_rdoc_files = [
@@ -47,6 +47,8 @@ Gem::Specification.new do |s|
47
47
  "app/views/.DS_Store",
48
48
  "app/views/admin/cms/pages/_form.html.haml",
49
49
  "app/views/admin/cms/partials/_body_before.html.haml",
50
+ "app/views/cms/fortress/admin/_leftnav.html.haml",
51
+ "app/views/cms/fortress/admin/_topnav.html.haml",
50
52
  "app/views/cms/fortress/admin/contents.html.haml",
51
53
  "app/views/cms/fortress/admin/design.html.haml",
52
54
  "app/views/cms/fortress/admin/roles.html.haml",
@@ -15,6 +15,7 @@ en:
15
15
  edit_title: Edit Role
16
16
  new_title: Create New Role
17
17
  back: Back
18
+ load: Load New Roles
18
19
 
19
20
  users:
20
21
  title: Users
@@ -29,6 +29,8 @@ class DeviseCreateCmsFortressUsers < ActiveRecord::Migration
29
29
  t.string :current_sign_in_ip
30
30
  t.string :last_sign_in_ip
31
31
 
32
+ t.string :first_name, :last_name
33
+
32
34
  ## Confirmable
33
35
  # t.string :confirmation_token
34
36
  # t.datetime :confirmed_at
@@ -8,7 +8,11 @@ class ActionDispatch::Routing::Mapper
8
8
  }
9
9
 
10
10
  scope path, module: 'cms/fortress' do
11
- resources :roles, :as => 'cms_fortress_roles'
11
+ resources :roles, :as => 'cms_fortress_roles' do
12
+ member do
13
+ post :refresh
14
+ end
15
+ end
12
16
  resources :users, :as => 'cms_fortress_users'
13
17
 
14
18
  get 'settings' => 'admin#settings', :as => 'cms_fortress_settings'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cms-fortress
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.6
4
+ version: 1.0.7
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-12-12 00:00:00.000000000 Z
12
+ date: 2013-12-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -193,6 +193,8 @@ files:
193
193
  - app/views/.DS_Store
194
194
  - app/views/admin/cms/pages/_form.html.haml
195
195
  - app/views/admin/cms/partials/_body_before.html.haml
196
+ - app/views/cms/fortress/admin/_leftnav.html.haml
197
+ - app/views/cms/fortress/admin/_topnav.html.haml
196
198
  - app/views/cms/fortress/admin/contents.html.haml
197
199
  - app/views/cms/fortress/admin/design.html.haml
198
200
  - app/views/cms/fortress/admin/roles.html.haml
@@ -265,7 +267,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
265
267
  version: '0'
266
268
  segments:
267
269
  - 0
268
- hash: 124089653421059147
270
+ hash: -2031890954127426435
269
271
  required_rubygems_version: !ruby/object:Gem::Requirement
270
272
  none: false
271
273
  requirements: