permissify 0.0.21 → 0.0.22

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.
@@ -10,8 +10,8 @@ module SystemFixtures::Abilities
10
10
 
11
11
  # Can define PERMISSIFIED_ABILITY_APPLICABILITY in any model
12
12
  # users_only = [Role::PERMISSIFIED_ABILITY_APPLICABILITY]
13
- # products_only => [Product::PERMISSIFIED_ABILITY_APPLICABILITY]
14
- # products_and_roles => users_only + products_only
13
+ # products_only = [Product::PERMISSIFIED_ABILITY_APPLICABILITY]
14
+ # products_and_roles = users_only + products_only
15
15
  #
16
16
  # add_category('Tabs', 'Tabs', users_only, %w(Admin Dealers Corporations Brands Merchants))
17
17
  # { 'Roles' => 'Admin',
@@ -36,9 +36,8 @@ module SystemFixtures::Abilities
36
36
  # add_category('Facebook', 'Social Media', products_and_roles, %w(Post Comment Like Remove))
37
37
  # add_category('Twitter', 'Social Media', products_and_roles, %w(Tweet Retweet Respond Remove))
38
38
  #
39
- #
40
- # [ 'Online Ordering',
41
- # 'Loyalty',
39
+ # [ 'Basic Service',
40
+ # 'Online Ordering',
42
41
  # 'Webpage Builder',
43
42
  # 'eGift',
44
43
  # 'Guest Management',
@@ -23,8 +23,8 @@ class PermissionsController < ApplicationController
23
23
 
24
24
  def create
25
25
  @permissions_object = @permissions_class.new
26
- @permissions_object.name = params[:role][:name]
27
- @permissions_object.from = params[:role][:from]
26
+ @permissions_object.name = params[@corresponding_class_params_key][:name]
27
+ @permissions_object.from = params[@corresponding_class_params_key][:from]
28
28
  @permissions_object.save
29
29
  set_permissions_object
30
30
  @response_message = @permissions_object.errors.full_messages.join(', ')
@@ -38,6 +38,7 @@ class PermissionsController < ApplicationController
38
38
  class_attributes ||= {}
39
39
  # @saved = @permissions_object.update_attributes class_attributes.merge(permission_attributes)
40
40
  attrs = class_attributes.merge(permission_attributes)
41
+ @permissions_object.name = attrs[:name]
41
42
  @permissions_object.permissions = attrs[:permissions]
42
43
  set_permissions_object_specific_values(attrs)
43
44
  # @permissions_object.attributes = class_attributes.merge(permission_attributes)
@@ -71,7 +72,7 @@ class PermissionsController < ApplicationController
71
72
  def set_nav
72
73
  @active_tab = 'admin'
73
74
  @active_section = 'Admin'
74
- @active_nav = 'Roles'
75
+ @active_nav = @permissions_header
75
76
  @current_entity = @entity = Admin.first
76
77
  end
77
78
  end
@@ -4,18 +4,41 @@ class CreateProductsTables < ActiveRecord::Migration
4
4
  create_table :products, :force => true do |t|
5
5
  t.string :name
6
6
  t.text :permissions
7
- t.datetime :deleted_at
8
7
  end
9
8
 
10
9
  create_table :merchants_products, :id => false, :force => true do |t|
11
10
  t.integer :merchant_id, :null => false
12
11
  t.integer :product_id, :null => false
13
12
  end
13
+
14
+ create_table :brands_products, :id => false, :force => true do |t|
15
+ t.integer :brand_id, :null => false
16
+ t.integer :product_id, :null => false
17
+ end
18
+
19
+ create_table :corporations_products, :id => false, :force => true do |t|
20
+ t.integer :corporation_id, :null => false
21
+ t.integer :product_id, :null => false
22
+ end
23
+
24
+ create_table :dealers_products, :id => false, :force => true do |t|
25
+ t.integer :dealer_id, :null => false
26
+ t.integer :product_id, :null => false
27
+ end
28
+
29
+ create_table :admins_products, :id => false, :force => true do |t|
30
+ t.integer :admin_id, :null => false
31
+ t.integer :product_id, :null => false
32
+ end
14
33
 
15
34
  end
16
35
 
17
36
  def down
37
+ drop_table :admins_products
38
+ drop_table :dealers_products
39
+ drop_table :corporations_products
40
+ drop_table :brands_products
41
+ drop_table :merchants_products
18
42
  drop_table :products
19
- drop_table :businesses_products
20
43
  end
21
44
  end
@@ -1,5 +1,6 @@
1
1
  class ProductsController < PermissionsController
2
- def set_permissions_class; set_the_permissions_class(Products, :product, 'product_', 'Product', 'Products'); end
2
+ def set_permissions_class; set_the_permissions_class(Product, :product, 'product_', 'Product', 'Products'); end
3
3
  def set_permissions_object; @product = @permissions_object; end
4
+ def set_permissions_object_specific_values(attrs); end
4
5
  end
5
6
 
@@ -0,0 +1,12 @@
1
+ module PermissifiedProductsInterface
2
+ module Admin
3
+ def permissible_products
4
+ []
5
+ end
6
+
7
+ include Permissify::Union
8
+ PERMISSIFIED_ASSOCIATION = :products
9
+ # PERMISSIFIED_ABILITY_APPLICABILITY = Product::PERMISSIFIED_ABILITY_APPLICABILITY
10
+
11
+ end
12
+ end
@@ -3,5 +3,10 @@ module PermissifiedProductsInterface
3
3
  def permissible_products
4
4
  self.corporation.products + self.products
5
5
  end
6
+
7
+ include Permissify::Union
8
+ PERMISSIFIED_ASSOCIATION = :products
9
+ # PERMISSIFIED_ABILITY_APPLICABILITY = Product::PERMISSIFIED_ABILITY_APPLICABILITY
10
+
6
11
  end
7
12
  end
@@ -3,5 +3,10 @@ module PermissifiedProductsInterface
3
3
  def permissible_products
4
4
  self.products
5
5
  end
6
+
7
+ include Permissify::Union
8
+ PERMISSIFIED_ASSOCIATION = :products
9
+ # PERMISSIFIED_ABILITY_APPLICABILITY = Product::PERMISSIFIED_ABILITY_APPLICABILITY
10
+
6
11
  end
7
12
  end
@@ -3,5 +3,10 @@ module PermissifiedProductsInterface
3
3
  def permissible_products
4
4
  self.products
5
5
  end
6
+
7
+ include Permissify::Union
8
+ PERMISSIFIED_ASSOCIATION = :products
9
+ # PERMISSIFIED_ABILITY_APPLICABILITY = Product::PERMISSIFIED_ABILITY_APPLICABILITY
10
+
6
11
  end
7
12
  end
@@ -3,5 +3,10 @@ module PermissifiedProductsInterface
3
3
  def permissible_products
4
4
  self.corporation.products + self.brand.products + self.products
5
5
  end
6
+
7
+ include Permissify::Union
8
+ PERMISSIFIED_ASSOCIATION = :products
9
+ # PERMISSIFIED_ABILITY_APPLICABILITY = Product::PERMISSIFIED_ABILITY_APPLICABILITY
10
+
6
11
  end
7
12
  end
@@ -1,6 +1,12 @@
1
1
  class Product < ActiveRecord::Base
2
2
 
3
3
  include Permissify::Model
4
+ PERMISSIFIED_ABILITY_APPLICABILITY = 'Product'
5
+ has_and_belongs_to_many :admins
6
+ has_and_belongs_to_many :dealers
7
+ has_and_belongs_to_many :corporations
8
+ has_and_belongs_to_many :brands
9
+ has_and_belongs_to_many :merchants
4
10
 
5
11
  # TODO : see how much of the following stuff can be rolled into ModelClass :
6
12
  validates_presence_of :name
@@ -11,7 +17,6 @@ class Product < ActiveRecord::Base
11
17
  class << self
12
18
  include Permissify::ModelClass
13
19
  include SystemFixtures::Products # app needs to provide this logic/specification : see example at app/models/system_fixtures/products.rb
14
- PERMISSIFIED_ABILITY_APPLICABILITY = 'Product'
15
20
  end
16
21
 
17
22
  end
@@ -6,15 +6,15 @@ module SystemFixtures::Products
6
6
  [4, 'Webpage Builder'],
7
7
  [5, 'eGift'],
8
8
  [6, 'Guest Management'],
9
- [7, 'Marketing Engine']
10
- [8, 'Social Media 1']
11
- [9, 'Social Media 2']
12
- [10, 'Social Media 3']
13
- [11, 'Social Marketing Engine']
9
+ [7, 'Marketing Engine'],
10
+ [8, 'Social Media 1'],
11
+ [9, 'Social Media 2'],
12
+ [10, 'Social Media 3'],
13
+ [11, 'Social Marketing Engine'],
14
14
  ]
15
15
 
16
- def seeded?(tier); tier.id < 8; end
17
- def seed; create_seeds :products, SEED_SPECIFICATIONS; end
16
+ def seeded?(product); product.id <= SEED_SPECIFICATIONS.count; end
17
+ def seed; create_seeds SEED_SPECIFICATIONS; end
18
18
 
19
19
  def create_basic_service; create_with 1; end
20
20
  def create_online_ordering; create_with 2; end
@@ -26,33 +26,30 @@ module SystemFixtures::Products
26
26
  def create_social_media_1; create_with 8; end
27
27
  def create_social_media_2; create_with 9; end
28
28
  def create_social_media_3; create_with 10; end
29
- def create_social_marketing_engine; create_with 10; end
29
+ def create_social_marketing_engine; create_with 11; end
30
30
  def create_with(id); create_with_id(:product, id, SEED_SPECIFICATIONS.assoc(id)[1]); end
31
31
 
32
32
  def basic_service_permissions
33
- permissions = Ability.create_permissions_hash([], [], %w(Product Role))
34
- permissions
33
+ ph :basic_service_on
35
34
  end
36
35
  def online_ordering_permissions; ph :online_ordering_on; end
37
36
  def loyalty_permissions; ph :loyalty_on; end
38
- def webpage_builder_permissions
39
- permissions_hash = Ability.create_permissions_hash([], %w(email sms social_media), %w(Product Role)).merge(ph(:webpage_builder_on))
40
- end
37
+ def webpage_builder_permissions; ph :webpage_builder_on; end
41
38
  def egift_permissions; ph :egift_on; end
42
39
  def guest_management_permissions; ph :guest_management_on; end
43
40
  def marketing_engine_permissions; ph :marketing_engine_on; end
44
41
 
45
42
  def social_media_1_permissions
46
43
  permissions = Ability.create_permissions_hash([], %w(social_media facebook twitter), %w(Product Role))
47
- permissions[:social_media_setup] = {'0' => '1'}
48
- permissions[:social_media_view] = {'0' => '1'}
44
+ permissions['social_media_setup'] = {'0' => '1'}
45
+ permissions['social_media_view'] = {'0' => '1'}
49
46
  permissions
50
47
  end
51
48
  def social_media_2_permissions
52
49
  permissions = social_media_1_permissions
53
- permissions[:social_media_create] = {'0' => '1'}
54
- permissions[:facebook_post] = {'0' => '1'}
55
- permissions[:twitter_tweet] = {'0' => '1'}
50
+ permissions['social_media_create'] = {'0' => '1'}
51
+ permissions['facebook_post'] = {'0' => '1'}
52
+ permissions['twitter_tweet'] = {'0' => '1'}
56
53
  permissions
57
54
  end
58
55
  def social_media_3_permissions
@@ -60,7 +57,8 @@ module SystemFixtures::Products
60
57
  end
61
58
  def social_marketing_engine_permissions
62
59
  permissions = social_media_3_permissions
63
- permissions[:marketing_engine_on] = {'0' => '1'}
60
+ permissions['marketing_engine_on'] = {'0' => '1'}
61
+ permissions['social_media_repeat'] = {'0' => '1'}
64
62
  permissions
65
63
  end
66
64
 
@@ -1,24 +1,4 @@
1
1
  <tr>
2
2
  <td ><%= label :product, :name, "Name"%></td>
3
3
  <td><%= text_field :product, :name, :maxlength => 255, :size => 46 %></td>
4
- <td style="vertical-align:bottom;"><%= required_field %></td>
5
- </tr>
6
-
7
- <tr>
8
- <td style="vertical-align:text-top;"><%= label :product, :description, "Description" %></td>
9
- <td colspan="2"><%= text_area :product, :description, :rows => 2, :columns => 60 %></td>
10
- </tr>
11
-
12
- <tr>
13
- <td style="vertical-align:text-top;"><%= "revenuePWR Instances" %></td>
14
- <td>
15
- <div class="checkCont">
16
- <% Instance.find(:all, :conditions => ["id in (?)", @current_user.instances.collect(&:id)]).each do |i| %>
17
- <label>
18
- <%= check_box_tag "#{@permissions_object.class.to_s.underscore}[instance_ids][]", i.id, @permissions_object.instances.include?(i) %>
19
- <%= i.name %>
20
- </label><br/>
21
- <% end %>
22
- </div>
23
- </td>
24
4
  </tr>
@@ -1,7 +1,10 @@
1
1
  class Role < ActiveRecord::Base
2
2
  DOMAIN_TYPES = %w(Admin Dealer Corporation Brand Merchant)
3
3
  # DOMAIN_TYPES = %w(Admin Operations CallCenter)
4
+
4
5
  include Permissify::Model
6
+ PERMISSIFIED_ABILITY_APPLICABILITY = 'Role'
7
+
5
8
  # is_paranoid
6
9
  # default_scope :conditions => {:deleted_at => nil}, :order => "roles.name"
7
10
  has_and_belongs_to_many :users
@@ -16,7 +19,6 @@ class Role < ActiveRecord::Base
16
19
  class << self
17
20
  include Permissify::ModelClass
18
21
  include SystemFixtures::Roles
19
- PERMISSIFIED_ABILITY_APPLICABILITY = 'Role'
20
22
 
21
23
  def force_seed_id(table, permissions_model, id)
22
24
  # not sure if this is still needed, may differ depending on db adapter (written against mysql)
@@ -1,4 +1,4 @@
1
- <%= form_for Role.new, :remote => true do |f| %>
1
+ <%= form_for @permissions_class.new, :remote => true do |f| %>
2
2
  <div id="copy_form_<%= @permissions_object.id %>" style="display:none;background-color:#fffff0;padding:3px;" class="copy_form">
3
3
  <%= f.hidden_field :from, :value => @permissions_object.id %>
4
4
  <%= f.text_field :name, :value => @permissions_object.name + ' copy', :maxlength => 31, :size => 17 %>
@@ -1 +1 @@
1
- <%= "#{permissions_group.size} #{@permissions_header}#{permissions_group.size == 1 ? '' : 's'}" %>
1
+ <%= "#{permissions_group.size} #{@permissions_header.singularize}#{permissions_group.size == 1 ? '' : 's'}" %>
@@ -1,5 +1,5 @@
1
- $("#permissions_header").html("<%= "#{permissions_group.size} #{@permissions_header}#{permissions_group.size == 1 ? '' : 's'}" %>");
2
- $("#delete_role_<%= @permissions_object.id.to_s %>").html("DELETED");
3
- $("#data_role_<%= @permissions_object.id.to_s %>").addClass('deletedRole');
4
- $("#data_role_<%= @permissions_object.id.to_s %>").slideUp(3000);
5
- // $("#errors_role_<%= @permissions_object.id.to_s %>").remove();
1
+ $("#permissions_header").html("<%= "#{permissions_group.size} #{@permissions_header.singularize}#{permissions_group.size == 1 ? '' : 's'}" %>");
2
+ $("#delete_<%= @corresponding_class_params_key %>_<%= @permissions_object.id.to_s %>").html("DELETED");
3
+ $("#data_<%= @corresponding_class_params_key %>_<%= @permissions_object.id.to_s %>").addClass('deletedRole');
4
+ $("#data_<%= @corresponding_class_params_key %>_<%= @permissions_object.id.to_s %>").slideUp(3000);
5
+ // $("#errors_<%= @corresponding_class_params_key %>_<%= @permissions_object.id.to_s %>").remove();
@@ -1 +1 @@
1
- window.location = "/roles?id=<%= @permissions_object.id %>"
1
+ window.location = "/<%= @permissions_object.class.name.downcase.pluralize %>?id=<%= @permissions_object.id %>"
@@ -73,11 +73,9 @@ module PermissionsHelper
73
73
  'Brand Admin',
74
74
  'Merchant Admin'
75
75
  ],
76
- # 'products' => [ 'Branch and Location Portals : Settings',
77
- # 'Branch and Location Portals : Social Media',
78
- # 'Branch and Location Portals : Web Page',
79
- # 'Solutions'
80
- # ]
76
+ 'product' => [ 'Social Media',
77
+ 'Solutions',
78
+ ]
81
79
  }[@permissions_name]
82
80
  end
83
81
 
@@ -19,6 +19,11 @@ module Permissify
19
19
  find(id)
20
20
  end
21
21
 
22
+ def force_seed_id(table, permissions_model, id)
23
+ # not sure if this is still needed, may differ depending on db adapter (written against mysql)
24
+ ActiveRecord::Base.connection.execute "UPDATE #{table}s SET id=#{id} WHERE id=#{permissions_model.id};"
25
+ end
26
+
22
27
  def locate(id, name)
23
28
  model_with_id = find_by_id(id) # interface method : ActiveRecord::Base.find_by_id
24
29
  model_with_id ||= send("create_#{underscored_name_symbol(name)}") # interface methods needed for each seeded model
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: permissify
3
3
  version: !ruby/object:Gem::Version
4
- hash: 53
4
+ hash: 51
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 21
10
- version: 0.0.21
9
+ - 22
10
+ version: 0.0.22
11
11
  platform: ruby
12
12
  authors:
13
13
  - Frederick Fix
@@ -72,6 +72,7 @@ files:
72
72
  - lib/generators/permissify/product/product_generator.rb
73
73
  - lib/generators/permissify/product/template/controller.rb
74
74
  - lib/generators/permissify/product/template/helper.rb
75
+ - lib/generators/permissify/product/template/interface/admin.rb
75
76
  - lib/generators/permissify/product/template/interface/brand.rb
76
77
  - lib/generators/permissify/product/template/interface/corporation.rb
77
78
  - lib/generators/permissify/product/template/interface/dealer.rb