pbw 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/MIT-LICENSE +1 -1
- data/Rakefile +7 -0
- data/app/controllers/pbw/application_controller.rb +9 -3
- data/app/controllers/pbw/areas_controller.rb +7 -0
- data/app/controllers/pbw/base_models_controller.rb +106 -0
- data/app/controllers/pbw/capabilities_controller.rb +7 -0
- data/app/controllers/pbw/constraints_controller.rb +7 -0
- data/app/controllers/pbw/item_containers_controller.rb +7 -0
- data/app/controllers/pbw/item_conversions_controller.rb +7 -0
- data/app/controllers/pbw/item_transfers_controller.rb +7 -0
- data/app/controllers/pbw/items_controller.rb +7 -0
- data/app/controllers/pbw/processes_controller.rb +7 -0
- data/app/controllers/pbw/roles_controller.rb +5 -2
- data/app/controllers/pbw/tokens_controller.rb +7 -0
- data/app/controllers/pbw/triggers_controller.rb +7 -0
- data/app/controllers/pbw/user_tokens_controller.rb +7 -0
- data/app/models/pbw/area.rb +17 -0
- data/app/models/pbw/capability.rb +5 -0
- data/app/models/pbw/constraint.rb +6 -0
- data/app/models/pbw/item.rb +15 -0
- data/app/models/pbw/item_container.rb +12 -0
- data/app/models/pbw/item_conversion.rb +9 -0
- data/app/models/pbw/item_transfer.rb +9 -0
- data/app/models/pbw/permission.rb +1 -0
- data/app/models/pbw/process.rb +10 -0
- data/app/models/pbw/role.rb +1 -0
- data/app/models/pbw/rule.rb +11 -0
- data/app/models/pbw/token.rb +16 -0
- data/app/models/pbw/trigger.rb +7 -0
- data/app/models/pbw/user.rb +7 -5
- data/app/models/pbw/user_token.rb +16 -0
- data/app/views/layouts/pbw/application.html.erb +41 -8
- data/config/initializers/devise.rb +80 -4
- data/config/locales/devise.en.yml +59 -0
- data/config/routes.rb +11 -0
- data/lib/generators/pbw/install/install_generator.rb +9 -1
- data/lib/generators/pbw/install/templates/application.html.erb +47 -0
- data/lib/pbw/engine.rb +33 -13
- data/lib/pbw/version.rb +1 -1
- data/public/Foundation-MIT-LICENSE.txt +20 -0
- data/public/config.rb +26 -0
- data/public/humans.txt +8 -0
- data/public/javascripts/foundation/foundation.alerts.js +52 -0
- data/public/javascripts/foundation/foundation.clearing.js +516 -0
- data/public/javascripts/foundation/foundation.cookie.js +74 -0
- data/public/javascripts/foundation/foundation.dropdown.js +178 -0
- data/public/javascripts/foundation/foundation.forms.js +525 -0
- data/public/javascripts/foundation/foundation.interchange.js +271 -0
- data/public/javascripts/foundation/foundation.joyride.js +844 -0
- data/public/javascripts/foundation/foundation.js +447 -0
- data/public/javascripts/foundation/foundation.magellan.js +134 -0
- data/public/javascripts/foundation/foundation.orbit.js +390 -0
- data/public/javascripts/foundation/foundation.placeholder.js +179 -0
- data/public/javascripts/foundation/foundation.reveal.js +330 -0
- data/public/javascripts/foundation/foundation.section.js +422 -0
- data/public/javascripts/foundation/foundation.tooltips.js +208 -0
- data/public/javascripts/foundation/foundation.topbar.js +303 -0
- data/public/javascripts/vendor/custom.modernizr.js +4 -0
- data/public/javascripts/vendor/jquery.js +9807 -0
- data/public/javascripts/vendor/zepto.js +2000 -0
- data/public/robots.txt +4 -0
- data/public/sass/_normalize.scss +402 -0
- data/public/sass/_settings.scss +1271 -0
- data/public/sass/app.scss +48 -0
- data/public/stylesheets/app.css +6686 -0
- metadata +82 -4
- data/app/assets/javascripts/pbw/application.js +0 -13
- data/app/assets/stylesheets/pbw/application.css +0 -13
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ZGIzNWI0MmRmMWE4YTYxMTdjYTU5MzI3Y2M0NjA0MzcwOWJiOGQ4OA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
YzQ5ZTM5MDE2Njk2N2VkMzI0ZDIyMjk5NjgzZmUwYjNjMDU4ODU1MQ==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MDNkNTE3Yjg2MWEwY2I0YjliZTI4M2YwNTBmYzNjNDcwOGZkOTdmM2I5MWNj
|
10
|
+
NWFhOGJjZjhlYjIwNjQxOGUyMjliMTQ5MDA5MGRkYTZiOGYzNDE3NjViYzVm
|
11
|
+
OWQ0OTkxZjU0OGI5M2E5ZDdlOWZmMjg2MWUzNDRiNGQyZWFiMzc=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZDZhYmRmMDdkNmZmYTY2YjdiYTA2ODY2ZWVkZWE5ZWQ5NmMxZjI0ZmNmZTky
|
14
|
+
ZmZjNDIzODFlYWQ3MTE2NDllNTc4OWI4YmVmNWIyMjk4NTRiZWU5ZjkwOTJi
|
15
|
+
MTFlNWQwMjQ5MzhiNGQwZmIzOTU1ZDhiOTdkYWE2MDE4Yzg0MjY=
|
data/MIT-LICENSE
CHANGED
data/Rakefile
CHANGED
@@ -2,13 +2,19 @@ module Pbw
|
|
2
2
|
class ApplicationController < ActionController::Base
|
3
3
|
|
4
4
|
rescue_from ::CanCan::AccessDenied do |exception|
|
5
|
-
flash[:alert] = "Access denied. You are not authorized to access the requested page."
|
6
5
|
respond_to do |format|
|
7
|
-
format.json {render json:
|
8
|
-
format.html {redirect_to root_path}
|
6
|
+
format.json {render json: {:error => exception.message}, status: 401}
|
7
|
+
format.html {redirect_to root_path, :error => exception.message}
|
9
8
|
end
|
10
9
|
end
|
11
10
|
|
11
|
+
rescue_from Mongoid::Errors::DocumentNotFound do |exception|
|
12
|
+
respond_to do |format|
|
13
|
+
format.html {redirect_to root_url, :error => exception.message}
|
14
|
+
format.json {render json: {:error => exception.message}, status: 404}
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
12
18
|
protected
|
13
19
|
|
14
20
|
def self.permission
|
@@ -0,0 +1,106 @@
|
|
1
|
+
module Pbw
|
2
|
+
class BaseModelsController < ApplicationController
|
3
|
+
respond_to :json
|
4
|
+
|
5
|
+
attr_accessor :model_class
|
6
|
+
|
7
|
+
before_filter :authenticate_user!
|
8
|
+
before_filter :set_model_class
|
9
|
+
before_filter :model_for_read, :only => [:show]
|
10
|
+
before_filter :model_for_update, :only => [:edit, :update, :destroy]
|
11
|
+
before_filter :index_models, :only => [:index]
|
12
|
+
|
13
|
+
def index
|
14
|
+
session[:referrer] = request.url
|
15
|
+
respond_with(@models) do |format|
|
16
|
+
format.json { render json: @models }
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def show
|
21
|
+
respond_with(@model) do |format|
|
22
|
+
format.json { render json: @model }
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def edit
|
27
|
+
respond_with(@model) do |format|
|
28
|
+
format.json { render json: @model }
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def new
|
33
|
+
authorize! :manage, Admin
|
34
|
+
@model = model_class.new
|
35
|
+
respond_with(@model) do |format|
|
36
|
+
format.json { render json: @model }
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def create
|
41
|
+
authorize! :manage, model_class
|
42
|
+
@model = model_class.new(params[model_param])
|
43
|
+
@model.image = @image if @image
|
44
|
+
if @model.save
|
45
|
+
respond_with(@model) do |format|
|
46
|
+
format.json { render json: @model }
|
47
|
+
end
|
48
|
+
else
|
49
|
+
respond_with(@model) do |format|
|
50
|
+
format.json { render json: @model.errors.full_messages, status: :unprocessable_entity}
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def update
|
56
|
+
if @model.update_attributes(params[model_param])
|
57
|
+
if @image
|
58
|
+
@model.image = @image
|
59
|
+
@model.save
|
60
|
+
end
|
61
|
+
respond_with(@model) do |format|
|
62
|
+
format.json { render json: @model }
|
63
|
+
end
|
64
|
+
else
|
65
|
+
respond_with(@model) do |format|
|
66
|
+
format.json { render json: @model.errors.full_messages, status: :unprocessable_entity}
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
def destroy
|
72
|
+
if @model.destroy
|
73
|
+
respond_with(@model) do |format|
|
74
|
+
format.json { head :no_content }
|
75
|
+
end
|
76
|
+
else
|
77
|
+
respond_with(@model) do |format|
|
78
|
+
format.json { render json: @model.errors.full_messages, status: :unprocessable_entity}
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
def model_param
|
84
|
+
model_class.name.underscore.downcase.to_sym
|
85
|
+
end
|
86
|
+
|
87
|
+
def model_id
|
88
|
+
params[:id]
|
89
|
+
end
|
90
|
+
|
91
|
+
def index_models
|
92
|
+
authorize! :read, model_class
|
93
|
+
@models = model_class.desc(:created_at)
|
94
|
+
end
|
95
|
+
|
96
|
+
def model_for_read
|
97
|
+
@model = model_class.find(model_id)
|
98
|
+
end
|
99
|
+
|
100
|
+
def model_for_update
|
101
|
+
@model = model_class.find(model_id)
|
102
|
+
authorize! :update, @model
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
end
|
@@ -18,7 +18,7 @@ module Pbw
|
|
18
18
|
|
19
19
|
def edit
|
20
20
|
@role = Role.find(params[:id])
|
21
|
-
@permissions = Permission.all
|
21
|
+
@permissions = Permission.all
|
22
22
|
@role_permissions = @role.permissions.collect{|p| p.id}
|
23
23
|
render json: {role: @role, permissions: @permissions, role_permissions: @role_permissions}
|
24
24
|
end
|
@@ -37,7 +37,10 @@ module Pbw
|
|
37
37
|
private
|
38
38
|
|
39
39
|
def is_super_admin?
|
40
|
-
|
40
|
+
unless current_user.super_admin?
|
41
|
+
render json: {:error => "Access denied. You are not authorized to access the requested page."}, status: 401
|
42
|
+
return false
|
43
|
+
end
|
41
44
|
end
|
42
45
|
end
|
43
46
|
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Pbw
|
2
|
+
class Area
|
3
|
+
include ::Mongoid::Document
|
4
|
+
include ::Mongoid::Timestamps
|
5
|
+
field :name, type: String
|
6
|
+
validates_presence_of :name
|
7
|
+
validates_uniqueness_of :name
|
8
|
+
|
9
|
+
has_and_belongs_to_many :user_tokens
|
10
|
+
has_many :item_containers
|
11
|
+
has_and_belongs_to_many :constraints
|
12
|
+
has_and_belongs_to_many :processes
|
13
|
+
has_and_belongs_to_many :triggers
|
14
|
+
|
15
|
+
attr_accessible :name
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Pbw
|
2
|
+
class Item
|
3
|
+
include ::Mongoid::Document
|
4
|
+
include ::Mongoid::Timestamps
|
5
|
+
field :name, type: String
|
6
|
+
validates_presence_of :name
|
7
|
+
validates_uniqueness_of :name
|
8
|
+
|
9
|
+
has_many :item_containers
|
10
|
+
has_many :item_transfers
|
11
|
+
has_many :item_conversions
|
12
|
+
|
13
|
+
attr_accessible :name
|
14
|
+
end
|
15
|
+
end
|
data/app/models/pbw/role.rb
CHANGED
@@ -0,0 +1,16 @@
|
|
1
|
+
module Pbw
|
2
|
+
class Token
|
3
|
+
include ::Mongoid::Document
|
4
|
+
include ::Mongoid::Timestamps
|
5
|
+
field :name, type: String
|
6
|
+
validates_presence_of :name
|
7
|
+
|
8
|
+
has_and_belongs_to_many :capabilities
|
9
|
+
has_and_belongs_to_many :constraints
|
10
|
+
has_and_belongs_to_many :processes
|
11
|
+
has_and_belongs_to_many :triggers
|
12
|
+
has_many :user_tokens
|
13
|
+
|
14
|
+
attr_accessible :name
|
15
|
+
end
|
16
|
+
end
|
data/app/models/pbw/user.rb
CHANGED
@@ -1,11 +1,10 @@
|
|
1
1
|
module Pbw
|
2
2
|
class User
|
3
3
|
include ::Mongoid::Document
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
:recoverable, :rememberable, :trackable, :validatable
|
4
|
+
include ::Mongoid::Timestamps
|
5
|
+
|
6
|
+
devise :database_authenticatable, :registerable, :timeoutable, :confirmable,
|
7
|
+
:recoverable, :rememberable, :trackable, :validatable, :lockable, :token_authenticatable
|
9
8
|
|
10
9
|
## Database authenticatable
|
11
10
|
field :email, :type => String, :default => ""
|
@@ -47,6 +46,9 @@ module Pbw
|
|
47
46
|
## Token authenticatable
|
48
47
|
field :authentication_token, :type => String
|
49
48
|
|
49
|
+
has_many :resource_containers
|
50
|
+
has_many :user_tokens
|
51
|
+
|
50
52
|
def super_admin?
|
51
53
|
self.role.name == "Super Admin"
|
52
54
|
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Pbw
|
2
|
+
class UserToken
|
3
|
+
include ::Mongoid::Document
|
4
|
+
include ::Mongoid::Timestamps
|
5
|
+
field :name, type: String
|
6
|
+
validates_presence_of :name
|
7
|
+
|
8
|
+
belongs_to :token
|
9
|
+
belongs_to :user
|
10
|
+
|
11
|
+
has_and_belongs_to_many :areas
|
12
|
+
has_many :item_containers
|
13
|
+
|
14
|
+
attr_accessible :name
|
15
|
+
end
|
16
|
+
end
|
@@ -1,14 +1,47 @@
|
|
1
|
+
|
1
2
|
<!DOCTYPE html>
|
2
|
-
<html>
|
3
|
+
<!--[if IE 8]> <html class="no-js lt-ie9" lang="en" > <![endif]-->
|
4
|
+
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
|
3
5
|
<head>
|
4
|
-
<
|
5
|
-
|
6
|
-
|
7
|
-
|
6
|
+
<meta charset="utf-8" />
|
7
|
+
<meta name="viewport" content="width=device-width" />
|
8
|
+
<title>PBW</title>
|
9
|
+
<link rel="stylesheet" href="stylesheets/app.css" />
|
10
|
+
<script src="javascripts/vendor/custom.modernizr.js"></script>
|
8
11
|
</head>
|
9
12
|
<body>
|
13
|
+
<div class="row">
|
14
|
+
<div class="large-12 columns">
|
15
|
+
<h2>Welcome to PBW</h2>
|
16
|
+
<p>This is version <%=Pbw::Engine.version%></p>
|
17
|
+
<hr />
|
18
|
+
</div>
|
19
|
+
</div>
|
10
20
|
|
11
|
-
|
12
|
-
|
21
|
+
<script>
|
22
|
+
document.write('<script src=' +
|
23
|
+
('__proto__' in {} ? 'javascripts/vendor/zepto' : 'javascripts/vendor/jquery') +
|
24
|
+
'.js><\/script>')
|
25
|
+
</script>
|
26
|
+
<script src="javascripts/foundation/foundation.js"></script>
|
27
|
+
<script src="javascripts/foundation/foundation.alerts.js"></script>
|
28
|
+
<script src="javascripts/foundation/foundation.clearing.js"></script>
|
29
|
+
<script src="javascripts/foundation/foundation.cookie.js"></script>
|
30
|
+
<script src="javascripts/foundation/foundation.dropdown.js"></script>
|
31
|
+
<script src="javascripts/foundation/foundation.forms.js"></script>
|
32
|
+
<script src="javascripts/foundation/foundation.interchange.js"></script>
|
33
|
+
<script src="javascripts/foundation/foundation.joyride.js"></script>
|
34
|
+
<script src="javascripts/foundation/foundation.magellan.js"></script>
|
35
|
+
<script src="javascripts/foundation/foundation.orbit.js"></script>
|
36
|
+
<script src="javascripts/foundation/foundation.placeholder.js"></script>
|
37
|
+
<script src="javascripts/foundation/foundation.reveal.js"></script>
|
38
|
+
<script src="javascripts/foundation/foundation.section.js"></script>
|
39
|
+
<script src="javascripts/foundation/foundation.tooltips.js"></script>
|
40
|
+
<script src="javascripts/foundation/foundation.topbar.js"></script>
|
41
|
+
|
42
|
+
|
43
|
+
<script>
|
44
|
+
$(document).foundation();
|
45
|
+
</script>
|
13
46
|
</body>
|
14
|
-
</html>
|
47
|
+
</html>
|
@@ -1,5 +1,81 @@
|
|
1
|
-
require 'devise/orm/mongoid'
|
2
|
-
|
3
1
|
Devise.setup do |config|
|
4
|
-
config.
|
5
|
-
|
2
|
+
#config.mailer_sender = Pbw::Engine.config.mail_sender
|
3
|
+
|
4
|
+
config.mailer = "Devise::Mailer"
|
5
|
+
|
6
|
+
require 'devise/orm/mongoid'
|
7
|
+
|
8
|
+
config.authentication_keys = [ :email ]
|
9
|
+
|
10
|
+
config.request_keys = []
|
11
|
+
|
12
|
+
config.case_insensitive_keys = [ :email ]
|
13
|
+
|
14
|
+
config.strip_whitespace_keys = [ :email ]
|
15
|
+
|
16
|
+
config.params_authenticatable = true
|
17
|
+
|
18
|
+
config.http_authenticatable = false
|
19
|
+
|
20
|
+
config.http_authenticatable_on_xhr = true
|
21
|
+
|
22
|
+
config.http_authentication_realm = "Application"
|
23
|
+
|
24
|
+
config.paranoid = true
|
25
|
+
|
26
|
+
config.skip_session_storage = [:http_auth]
|
27
|
+
|
28
|
+
config.stretches = Rails.env.test? ? 1 : 10
|
29
|
+
|
30
|
+
config.pepper = "63818839cfabfff3dcf5983671b4d2f01708727af5d512fd79a8afe7e744187a8976280cd31e8d1b023c2c29f4f396810c90ef15de5faaa20595e84bee4c9545"
|
31
|
+
|
32
|
+
config.allow_unconfirmed_access_for = 2.days
|
33
|
+
|
34
|
+
config.confirm_within = 3.days
|
35
|
+
|
36
|
+
config.reconfirmable = true
|
37
|
+
|
38
|
+
config.confirmation_keys = [ :email ]
|
39
|
+
|
40
|
+
config.remember_for = 2.weeks
|
41
|
+
|
42
|
+
config.extend_remember_period = false
|
43
|
+
|
44
|
+
config.rememberable_options = {}
|
45
|
+
|
46
|
+
config.password_length = 8..128
|
47
|
+
|
48
|
+
config.email_regexp = /\A[^@]+@[^@]+\z/
|
49
|
+
|
50
|
+
config.timeout_in = 30.minutes
|
51
|
+
|
52
|
+
config.expire_auth_token_on_timeout = false
|
53
|
+
|
54
|
+
config.lock_strategy = :failed_attempts
|
55
|
+
|
56
|
+
config.unlock_keys = [ :email ]
|
57
|
+
|
58
|
+
config.unlock_strategy = :email
|
59
|
+
|
60
|
+
config.maximum_attempts = 5
|
61
|
+
|
62
|
+
config.reset_password_keys = [ :email ]
|
63
|
+
|
64
|
+
config.reset_password_within = 6.hours
|
65
|
+
|
66
|
+
config.encryptor = :sha512
|
67
|
+
|
68
|
+
config.token_authentication_key = :auth_token
|
69
|
+
|
70
|
+
config.scoped_views = false
|
71
|
+
|
72
|
+
config.default_scope = :user
|
73
|
+
|
74
|
+
config.sign_out_all_scopes = true
|
75
|
+
|
76
|
+
config.navigational_formats = ["*/*", :html]
|
77
|
+
|
78
|
+
config.sign_out_via = :delete
|
79
|
+
|
80
|
+
config.router_name = :pbw
|
81
|
+
end
|