ishapi 0.1.6 → 0.1.8

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,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0bc2551ac0f596f9a00805d21aac56f9b47bcb95
4
- data.tar.gz: 92906c76403bbedfdfa1c48637ff73c2f47890e2
3
+ metadata.gz: 6fde57c4d2ec802718f51faa22e509d4f8d445d0
4
+ data.tar.gz: e721fa860b52af477142b114a3c98c3e9a2d0679
5
5
  SHA512:
6
- metadata.gz: 28f3be37b2755ea3a4369b9938c394cda3f8383be3dff28de75dc1402b54f43b9b187b93d2942809ac10a397615b05e0767cc9c2f8623a45d7b8698c8a19a19c
7
- data.tar.gz: 3c07240b2b30509bb8eb60feb48a7dbd6d2682bb828829720d29274db762f0b957dbbe488fa1c6b3878ce4eaa30527016223ff732aca36cc101dc3905a8abc36
6
+ metadata.gz: 3b0bce38baf4f21e2dc617a33f71eee4b9b2c126a56a1eb5f48d8a70c2347620520cb10b3d9da9bb72f3e85905401250aa444bddc8cc9467f277e111f9a67e5d
7
+ data.tar.gz: 3c76037a3f826617d3b26e9d1749855b816d585fb58464a61a2893486e8a98e654204dae294a0e6c4fad9fa49e411304c25089d10b2a38df65a24598644fed93
@@ -1,4 +1,3 @@
1
-
2
1
  require_dependency "ishapi/application_controller"
3
2
 
4
3
  module Ishapi
@@ -2,6 +2,14 @@ module Ishapi
2
2
  class ApplicationController < ActionController::Base
3
3
  protect_from_forgery with: :exception
4
4
  layout :false
5
+ before_action :set_current_ability
6
+ check_authorization
7
+
8
+ private
9
+
10
+ def set_current_ability
11
+ @current_ability ||= ::Ishapi::Ability.new( current_user )
12
+ end
5
13
 
6
14
  def puts! a, b=''
7
15
  puts "+++ +++ #{b}"
@@ -3,7 +3,8 @@ module Ishapi
3
3
  class GalleriesController < ApplicationController
4
4
 
5
5
  def show
6
- @gallery = ::Gallery.find_by :galleryname => params[:galleryname]
6
+ @gallery = ::Gallery.unscoped.find_by :galleryname => params[:galleryname]
7
+ authorize! :show, @gallery
7
8
  end
8
9
 
9
10
  end
@@ -0,0 +1,32 @@
1
+
2
+ class Ishapi::Ability
3
+ include ::CanCan::Ability
4
+
5
+ def initialize user
6
+
7
+ #
8
+ # signed in user
9
+ #
10
+ unless user.blank?
11
+
12
+ if user.profile && user.profile.manager?
13
+ can :manage, :all
14
+ end
15
+
16
+ can [ :show ], Gallery do |gallery|
17
+ gallery.user == user
18
+ end
19
+
20
+ end
21
+ user ||= User.new
22
+
23
+ can [ :read ], Gallery do |gallery|
24
+ gallery.is_public
25
+ end
26
+
27
+ can [ :read ], Report do |report|
28
+ report.is_public
29
+ end
30
+
31
+ end
32
+ end
@@ -0,0 +1,14 @@
1
+
2
+ class Ishapi::Ability
3
+ include ::CanCan::Ability
4
+
5
+ def initialize user
6
+ user ||= User.new
7
+
8
+ if user.profile && user.profile.manager?
9
+ can :manage, :all
10
+ else
11
+ can :read, :all
12
+ end
13
+ end
14
+ end
@@ -1,3 +1,4 @@
1
+
1
2
  module Ishapi
2
3
  class ApplicationRecord
3
4
  end
@@ -1,4 +1,8 @@
1
+
1
2
  require "ishapi/engine"
3
+ require 'cancancan'
4
+ require 'kaminari/mongoid'
5
+ require 'kaminari/actionview'
2
6
 
3
7
  module Ishapi
4
8
  # Your code goes here...
@@ -1,3 +1,3 @@
1
1
  module Ishapi
2
- VERSION = '0.1.6'
2
+ VERSION = File.read("VERSION")
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ishapi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - piousbox
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-05-22 00:00:00.000000000 Z
11
+ date: 2017-05-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -38,6 +38,48 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: 6.1.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: cancancan
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '2.0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '2.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: kaminari-mongoid
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: kaminari-actionview
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '1.0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '1.0'
41
83
  - !ruby/object:Gem::Dependency
42
84
  name: rspec
43
85
  requirement: !ruby/object:Gem::Requirement
@@ -112,6 +154,8 @@ files:
112
154
  - app/helpers/ishapi/articles_helper.rb
113
155
  - app/jobs/ishapi/application_job.rb
114
156
  - app/mailers/ishapi/application_mailer.rb
157
+ - app/models/ishapi/ability.rb
158
+ - app/models/ishapi/ability.rb~
115
159
  - app/models/ishapi/application_record.rb
116
160
  - app/models/ishapi/article.rb
117
161
  - app/views/ishapi/articles/_form.html.erb