faalis 0.26.3 → 1.0.0.alpha0
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 +4 -4
- data/README.md +35 -6
- data/Rakefile +2 -25
- data/app/assets/javascripts/faalis/angular-manifest.js +8 -2
- data/app/assets/javascripts/faalis/application.js +0 -3
- data/app/assets/javascripts/faalis/dashboard/application.js.erb +0 -5
- data/app/assets/javascripts/faalis/dashboard/functions.js.erb +9 -0
- data/app/assets/javascripts/faalis/dashboard/init.js +1 -1
- data/app/assets/javascripts/faalis/dashboard/modules/auth/group.js +0 -6
- data/app/assets/javascripts/faalis/dashboard/modules/fields/fields.js +1 -1
- data/app/assets/javascripts/faalis/dashboard/modules/fields/image.js +115 -0
- data/app/assets/javascripts/faalis/dashboard/modules/fields/tag.js +76 -0
- data/app/assets/javascripts/faalis/dashboard/variables.js.erb +1 -1
- data/app/assets/locale/templates.pot +282 -0
- data/app/assets/stylesheets/faalis/dashboard/dashboard.css.scss +4 -0
- data/app/assets/stylesheets/faalis/dashboard/ltr/application.css +4 -4
- data/app/assets/stylesheets/faalis/dashboard/rtl/application.css +4 -4
- data/app/assets/stylesheets/faalis/dashboard/rtl/base.css.scss.erb +2 -2
- data/app/controllers/faalis/api/v1/permissions_controller.rb +8 -39
- data/app/controllers/faalis/api/v1/users_controller.rb +7 -7
- data/app/models/ability.rb +4 -6
- data/app/models/faalis/concerns/assignment.rb +2 -2
- data/app/models/faalis/group.rb +18 -4
- data/app/models/faalis/permission.rb +11 -2
- data/app/models/faalis/permissions/auth.rb +3 -2
- data/app/models/faalis/user.rb +27 -73
- data/app/models/faalis/user/auth_definitions.rb +94 -0
- data/app/models/faalis/user/mongoid_fields.rb +76 -0
- data/app/models/faalis/user/permission.rb +21 -0
- data/app/views/angularjs_templates/auth/groups/new.html +0 -20
- data/app/views/angularjs_templates/fields/image/image.html +1 -0
- data/app/views/angularjs_templates/fields/relation/relation.html +3 -1
- data/app/views/angularjs_templates/fields/tag/tag.html +1 -0
- data/app/views/angularjs_templates/nav.html.erb +0 -1
- data/app/views/faalis/api/v1/users/index.json.jbuilder +1 -1
- data/app/views/layouts/faalis/application.html.erb +2 -0
- data/app/views/layouts/faalis/dashboard.html.erb +1 -0
- data/app/views/layouts/faalis/simple.html.erb +1 -0
- data/config/initializers/devise.rb +0 -7
- data/db/migrate/20131013091000_devise_create_faalis_users.rb +3 -2
- data/db/migrate/20140613120923_add_users_groups_table.rb +8 -0
- data/db/migrate/20140617124019_faalis_groups_users.rb +4 -0
- data/db/seeds.rb +39 -11
- data/lib/faalis.rb +5 -4
- data/lib/faalis/concerns.rb +7 -0
- data/lib/faalis/concerns/authorizable.rb +76 -0
- data/lib/faalis/discovery.rb +8 -0
- data/lib/faalis/discovery/permissions.rb +51 -0
- data/lib/faalis/engine.rb +19 -5
- data/lib/faalis/extensions.rb +18 -0
- data/lib/faalis/extensions/base.rb +29 -0
- data/lib/faalis/fake_assets.rb +7 -0
- data/lib/faalis/generators/dashboard_scaffold.rb +23 -5
- data/lib/faalis/omniauth.rb +3 -0
- data/lib/faalis/orm.rb +29 -0
- data/lib/faalis/{active_record.rb → patches/models.rb} +1 -3
- data/lib/faalis/version.rb +1 -1
- data/lib/generators/faalis/install_generator.rb +7 -3
- data/lib/{faalis/plugins.rb → generators/faalis/js/install_i18n_generator.rb} +20 -17
- data/lib/generators/faalis/scaffold_generator.rb +139 -0
- data/lib/generators/faalis/templates/application.js +1 -1
- data/lib/generators/faalis/templates/i18n/Gruntfile.js.erb +30 -0
- data/lib/generators/faalis/templates/i18n/README +13 -0
- data/lib/generators/faalis/templates/i18n/fa.js +3 -0
- data/lib/generators/faalis/templates/js/list_view/README +1 -1
- data/lib/tasks/faalis_tasks.rake +26 -20
- data/lib/tasks/grunt/Gruntfile.js +7 -2
- data/spec/dummy/config/initializers/faalis.rb +40 -0
- metadata +134 -44
- data/app/assets/javascripts/faalis/dashboard/lib/angular-gettext.js +0 -202
- data/app/assets/javascripts/faalis/dashboard/lib/ng-grid.js +0 -3260
- data/app/assets/javascripts/faalis/dashboard/lib/ng-quick-date.js +0 -297
- data/app/assets/javascripts/faalis/dashboard/lib/restangular.js +0 -1066
- data/app/assets/javascripts/faalis/dashboard/lib/select2.js +0 -3255
- data/app/assets/javascripts/faalis/dashboard/lib/ui.select2.js +0 -217
- data/app/assets/stylesheets/faalis/dashboard/ng-grid.css.scss +0 -442
- data/app/assets/stylesheets/faalis/dashboard/ng-quick-date-default-theme.css.scss +0 -20
- data/app/assets/stylesheets/faalis/dashboard/ng-quick-date.css.scss +0 -19
- data/app/assets/stylesheets/faalis/dashboard/select2.css.scss.erb +0 -618
- data/app/controllers/faalis/api/v1/#conversations_controller.rb# +0 -120
- data/app/models/faalis/workflow.rb +0 -4
- data/db/migrate/20140413180202_create_faalis_workflows.rb +0 -9
- data/lib/faalis/permissions.rb +0 -72
- data/lib/faalis/workflows.rb +0 -7
- data/lib/faalis/workflows/base.rb +0 -70
- data/lib/faalis/workflows/discovery.rb +0 -42
- data/lib/generators/faalis/js_scaffold_generator.rb +0 -113
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
module Faalis
|
|
2
|
+
# This module contains all the **Mongoid** related definitions
|
|
3
|
+
module User::MongoidFields
|
|
4
|
+
extend ActiveSupport::Concern
|
|
5
|
+
|
|
6
|
+
included do
|
|
7
|
+
|
|
8
|
+
field :first_name, type: String, default: ''
|
|
9
|
+
field :last_name, type: String, default: ''
|
|
10
|
+
field :email, type: String, default: ''
|
|
11
|
+
field :encrypted_password, type: String, default: ''
|
|
12
|
+
|
|
13
|
+
## Recoverable
|
|
14
|
+
field :reset_password_token, type: String
|
|
15
|
+
field :reset_password_sent_at, type: Time
|
|
16
|
+
|
|
17
|
+
## Recoverable
|
|
18
|
+
field :remember_created_at, type: Time
|
|
19
|
+
|
|
20
|
+
## Trackable
|
|
21
|
+
field :sign_in_count, type: Integer, default: 0
|
|
22
|
+
field :current_sign_in_at, type: Time
|
|
23
|
+
field :last_sign_in_at, type: Time
|
|
24
|
+
field :current_sign_in_ip, type: String
|
|
25
|
+
field :last_sign_in_ip, type: String
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
## Confirmable
|
|
29
|
+
# field :confirmation_token, type: String
|
|
30
|
+
# field :confirmed_at, type: Time
|
|
31
|
+
# field :confirmation_sent_at, type: Time
|
|
32
|
+
# field :unconfirmed_email, type: String # Only if using reconfirmable
|
|
33
|
+
|
|
34
|
+
# Lockable
|
|
35
|
+
field :failed_attempts, type: Integer, default: 0 # Only if lock strategy is :failed_attempts
|
|
36
|
+
field :unlock_token, type: String # Only if unlock strategy is :email or :both
|
|
37
|
+
field :locked_at, type: Time
|
|
38
|
+
|
|
39
|
+
# Token authenticatable
|
|
40
|
+
field :authentication_token, type: String
|
|
41
|
+
|
|
42
|
+
# run 'rake db:mongoid:create_indexes' to create indexes
|
|
43
|
+
if not Devise.omniauth_providers.empty?
|
|
44
|
+
# Service
|
|
45
|
+
field :provider, type: String, default: ''
|
|
46
|
+
field :uid, type: String
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
if Rails.env.production?
|
|
50
|
+
# Confirmable
|
|
51
|
+
field :confirmation_token, type: String
|
|
52
|
+
field :confirmed_at, type: Time
|
|
53
|
+
field :confirmation_sent_at, type: Time
|
|
54
|
+
|
|
55
|
+
# Only if using reconfirmable
|
|
56
|
+
field :unconfirmed_email, type: String
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
index({ email: 1 },
|
|
61
|
+
{ unique: true, background: true })
|
|
62
|
+
index({ reset_password_token: 1 },
|
|
63
|
+
{ unique: true, background: true })
|
|
64
|
+
index({ unlock_token: 1 },
|
|
65
|
+
{ unique: true, background: true })
|
|
66
|
+
index({ authentication_token: 1 },
|
|
67
|
+
{ unique: true, background: true })
|
|
68
|
+
|
|
69
|
+
if Rails.env.production?
|
|
70
|
+
index({ confirmation_token: 1 },
|
|
71
|
+
{ unique: true, background: true })
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
module Faalis
|
|
2
|
+
# This concern contains all the permission related methods
|
|
3
|
+
# to use within `Faalis::User`
|
|
4
|
+
module User::Permission
|
|
5
|
+
|
|
6
|
+
# Return all the user permissions
|
|
7
|
+
def permissions
|
|
8
|
+
perms = []
|
|
9
|
+
|
|
10
|
+
groups.each do |group|
|
|
11
|
+
group.permissions.each do |perm|
|
|
12
|
+
# It's obvious isn't it ?
|
|
13
|
+
yield perm if block_given?
|
|
14
|
+
perms << perm
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
perms
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -15,26 +15,6 @@
|
|
|
15
15
|
</div>
|
|
16
16
|
</fieldset>
|
|
17
17
|
|
|
18
|
-
<fieldset>
|
|
19
|
-
<legend translate>Workflows</legend>
|
|
20
|
-
<div class="row">
|
|
21
|
-
<div class="small-12 columns">
|
|
22
|
-
<p translate>Choose any workflow which you want to allow user to have access to.</p>
|
|
23
|
-
</div>
|
|
24
|
-
</div>
|
|
25
|
-
<div class="row">
|
|
26
|
-
<div class="small-2 columns text-center" ng-repeat="workflow in workflows">
|
|
27
|
-
|
|
28
|
-
<span class="fa-stack fa-2x" ng-if="workflow.have_icon == true">
|
|
29
|
-
<i class="fa fa-circle fa-stack-2x"></i>
|
|
30
|
-
<i class="{{ workflow.icon }} fa-stack-1x fa-inverse"></i>
|
|
31
|
-
</span>
|
|
32
|
-
<img ng-src="workflow.image" ng-if="workflow.have_iamge == true"/>
|
|
33
|
-
<span>{{ workflow.title }}</span>
|
|
34
|
-
</div>
|
|
35
|
-
</div>
|
|
36
|
-
</fieldset>
|
|
37
|
-
|
|
38
18
|
<fieldset>
|
|
39
19
|
<legend translate>Advance Permissions</legend>
|
|
40
20
|
<div class="row">
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<input type="file" />
|
|
@@ -24,7 +24,9 @@
|
|
|
24
24
|
</div>
|
|
25
25
|
<div class="float-right relation_links" ng-if="((field.type === 'belongs_to') || (field.type === 'has_many')) && show_buttons() ">
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
|
|
28
|
+
<!-- Add and Refresh buttons -->
|
|
29
|
+
<span ng-click="help_btn_clicked()" ng-if="show_help_btnn">
|
|
28
30
|
<i class="fa fa-question"></i>
|
|
29
31
|
</span>
|
|
30
32
|
<span>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<input ui-select2="options" type="hidden" ng-model="model" ng-required="required" data-dtr="{{ model }}"/>
|
|
@@ -2,13 +2,6 @@
|
|
|
2
2
|
# Many of these configuration options can be set straight in your model.
|
|
3
3
|
Devise.setup do |config|
|
|
4
4
|
|
|
5
|
-
# ==> ORM configuration
|
|
6
|
-
# Load and configure the ORM. Supports :active_record (default) and
|
|
7
|
-
# :mongoid (bson_ext recommended) by default. Other ORMs may be
|
|
8
|
-
# available as additional gems.
|
|
9
|
-
require 'devise/orm/active_record'
|
|
10
|
-
|
|
11
|
-
|
|
12
5
|
config.secret_key = '04671846f794e5df0e032abb7d3d3876016f1cf0a1ced726429b2807c798de67f08035cc45e953eca23e08661a7f8030f4bcaec91ef184d89f4c721b5925d36b'
|
|
13
6
|
|
|
14
7
|
|
|
@@ -38,6 +38,9 @@ class DeviseCreateFaalisUsers < ActiveRecord::Migration
|
|
|
38
38
|
t.datetime :confirmed_at
|
|
39
39
|
t.datetime :confirmation_sent_at
|
|
40
40
|
t.string :unconfirmed_email # Only if using reconfirmable
|
|
41
|
+
|
|
42
|
+
# Token authenticatable
|
|
43
|
+
t.string :authentication_token
|
|
41
44
|
end
|
|
42
45
|
|
|
43
46
|
## Lockable
|
|
@@ -45,8 +48,6 @@ class DeviseCreateFaalisUsers < ActiveRecord::Migration
|
|
|
45
48
|
t.string :unlock_token # Only if unlock strategy is :email or :both
|
|
46
49
|
t.datetime :locked_at
|
|
47
50
|
|
|
48
|
-
## Token authenticatable
|
|
49
|
-
# t.string :authentication_token
|
|
50
51
|
|
|
51
52
|
|
|
52
53
|
t.timestamps
|
data/db/seeds.rb
CHANGED
|
@@ -2,20 +2,48 @@
|
|
|
2
2
|
|
|
3
3
|
ModelDiscovery::Engine.load_seed
|
|
4
4
|
|
|
5
|
-
Faalis::Workflows::Discovery.build_table_list
|
|
5
|
+
#Faalis::Workflows::Discovery.build_table_list
|
|
6
|
+
Faalis::Discovery::Permissions.create_all_permissions
|
|
6
7
|
|
|
7
|
-
Faalis::
|
|
8
|
+
case Faalis::ORM.current
|
|
9
|
+
when 'active_record'
|
|
10
|
+
admin_group = Faalis::Group.create(name: 'Admin')
|
|
8
11
|
|
|
9
|
-
|
|
10
|
-
:group_id => 1,
|
|
11
|
-
:password => '123123123',
|
|
12
|
-
:password_confirmation => '123123123'})
|
|
12
|
+
admin_group.permissions = Faalis::Permission.all
|
|
13
13
|
|
|
14
|
+
admin = Faalis::User.create(email: 'admin@example.com',
|
|
15
|
+
password: '123123123',
|
|
16
|
+
password_confirmation: '123123123')
|
|
17
|
+
admin.groups << admin_group
|
|
14
18
|
|
|
15
|
-
Faalis::Group.create(
|
|
19
|
+
guest_group = Faalis::Group.create(name: 'Guest', id: 2)
|
|
16
20
|
|
|
17
21
|
|
|
18
|
-
Faalis::User.create(
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
+
user = Faalis::User.create(email: 'user@example.com',
|
|
23
|
+
password: '123123123',
|
|
24
|
+
password_confirmation: '123123123')
|
|
25
|
+
user.groups << guest_group
|
|
26
|
+
|
|
27
|
+
when 'mongoid'
|
|
28
|
+
admin = Faalis::User.create(email: 'admin@example.com',
|
|
29
|
+
password: '123123123',
|
|
30
|
+
password_confirmation: '123123123')
|
|
31
|
+
|
|
32
|
+
admin_group = Faalis::Group.create(name: 'Admin')
|
|
33
|
+
|
|
34
|
+
Faalis::Permission.each do |perm|
|
|
35
|
+
admin_group.permissions << perm
|
|
36
|
+
end
|
|
37
|
+
admin_group.save!
|
|
38
|
+
|
|
39
|
+
admin.groups << admin_group
|
|
40
|
+
|
|
41
|
+
user = Faalis::User.create(email: 'user@example.com',
|
|
42
|
+
password: '123123123',
|
|
43
|
+
password_confirmation: '123123123')
|
|
44
|
+
guest_group = Faalis::Group.new(name: 'Guest')
|
|
45
|
+
user.groups = [guest_group]
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
admin.save
|
|
49
|
+
user.save
|
data/lib/faalis.rb
CHANGED
|
@@ -24,13 +24,14 @@ module Faalis
|
|
|
24
24
|
end
|
|
25
25
|
|
|
26
26
|
require 'faalis/engine'
|
|
27
|
-
require 'faalis/
|
|
27
|
+
require 'faalis/orm'
|
|
28
|
+
require 'faalis/concerns'
|
|
28
29
|
require 'faalis/dashboard'
|
|
30
|
+
require 'faalis/extensions'
|
|
29
31
|
require 'faalis/omniauth'
|
|
30
|
-
require 'faalis/active_record'
|
|
31
32
|
require 'faalis/i18n'
|
|
32
|
-
require 'faalis/plugins'
|
|
33
33
|
require 'faalis/generators/concerns'
|
|
34
34
|
require 'faalis/generators'
|
|
35
|
-
require 'faalis/workflows'
|
|
36
35
|
require 'faalis/route'
|
|
36
|
+
require 'faalis/discovery'
|
|
37
|
+
require 'faalis/fake_assets'
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
module Faalis
|
|
2
|
+
module Concerns
|
|
3
|
+
# Authorizable modules of Faalis which each resource model should
|
|
4
|
+
# includes this concern. Without this concern, models can not be authorized
|
|
5
|
+
module Authorizable
|
|
6
|
+
extend ActiveSupport::Concern
|
|
7
|
+
|
|
8
|
+
# Class methods which will add to model by including
|
|
9
|
+
# `Faalis::Concerns::Authorizable`
|
|
10
|
+
module ClassMethods
|
|
11
|
+
# Default permission hash
|
|
12
|
+
@@permissions = {
|
|
13
|
+
read: nil,
|
|
14
|
+
update: nil,
|
|
15
|
+
create: nil,
|
|
16
|
+
destroy: nil,
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
@@only_owner = false
|
|
20
|
+
|
|
21
|
+
# Return an array of strings representation of permissions
|
|
22
|
+
def permission_strings(model)
|
|
23
|
+
strings = []
|
|
24
|
+
model_name = model.to_s
|
|
25
|
+
humanize_name = ActiveModel::Name.new(model).human
|
|
26
|
+
if model.respond_to? :model_name
|
|
27
|
+
model_name = model.model_name
|
|
28
|
+
humanize_name = model_name.human
|
|
29
|
+
end
|
|
30
|
+
@@permissions.each do |key, value|
|
|
31
|
+
strings << {
|
|
32
|
+
name: "#{key}|#{model_name}",
|
|
33
|
+
string: _("can %s %s") % [_(key.to_s), humanize_name]
|
|
34
|
+
}
|
|
35
|
+
end
|
|
36
|
+
strings
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def possible_permissions
|
|
40
|
+
@@permissions.keys
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
# Define permissions using this method
|
|
44
|
+
def permissions(*args)
|
|
45
|
+
|
|
46
|
+
args.each do |permission|
|
|
47
|
+
if permission.class == Symbol
|
|
48
|
+
if not @@permissions.include? permission
|
|
49
|
+
@@permission[permission] = nil
|
|
50
|
+
|
|
51
|
+
elsif permission.class == Hash
|
|
52
|
+
|
|
53
|
+
permission.each do |key, value|
|
|
54
|
+
@@permissions[key.to_sym] = value
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
# This force user to have access to resources which is his.
|
|
65
|
+
def only_his_objects
|
|
66
|
+
@@only_owner = true
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def only_his_objects?
|
|
70
|
+
@@only_owner
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
end
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
module Faalis
|
|
2
|
+
module Discovery
|
|
3
|
+
class Permissions
|
|
4
|
+
|
|
5
|
+
# Run the given block fir each object with permissions
|
|
6
|
+
def self.permission_objects(&block)
|
|
7
|
+
objects = []
|
|
8
|
+
|
|
9
|
+
# Walkthrough all models in application by using
|
|
10
|
+
# model_discovery gem and check for `permission_strings`
|
|
11
|
+
# method in models (If `Faalis::Permissions` included in
|
|
12
|
+
# model it has the permission_strings). And concat the
|
|
13
|
+
# permissions to `@permissions` instance method.
|
|
14
|
+
::ApplicationModels.to_adapter.find_all.each do |m|
|
|
15
|
+
model = m.model.constantize
|
|
16
|
+
if model.respond_to? :permission_strings
|
|
17
|
+
block.call(model)
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# Check also for entities which don't have a model but
|
|
22
|
+
# we need to use them in our permissions.
|
|
23
|
+
Faalis::Engine.models_with_permission.each do |m|
|
|
24
|
+
model = m.constantize
|
|
25
|
+
if model.respond_to? :permission_strings
|
|
26
|
+
block.call(model)
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def self.all_permissions
|
|
32
|
+
permissions = []
|
|
33
|
+
permission_objects do |object|
|
|
34
|
+
permissions.concat(object.permission_strings(object))
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
permissions.uniq
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def self.create_all_permissions
|
|
41
|
+
|
|
42
|
+
permission_objects do |object|
|
|
43
|
+
object.possible_permissions.each do |perm|
|
|
44
|
+
Faalis::Permission.create(model: object.to_s,
|
|
45
|
+
permission_type: perm)
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|