faalis 2.1.1 → 2.2.0.pre.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/faalis/dashboard/application.js.erb +1 -1
- data/app/assets/javascripts/faalis/dashboard/init.js.coffee +1 -2
- data/app/assets/javascripts/faalis/dashboard/manifest.js +5 -0
- data/app/assets/javascripts/faalis/simple.js +1 -1
- data/app/assets/stylesheets/faalis/dashboard/ltr/application.css +4 -2
- data/app/assets/stylesheets/faalis/dashboard/rtl/application.css +4 -0
- data/app/assets/stylesheets/faalis/dashboard/share.scss +6 -0
- data/app/controllers/faalis/dashboard/groups_controller.rb +0 -1
- data/app/controllers/faalis/dashboard/users_controller.rb +6 -2
- data/app/helpers/faalis/dashboard_helper.rb +8 -9
- data/app/models/faalis/concerns/user/permission.rb +7 -2
- data/app/models/faalis/concerns/user/user_roles.rb +15 -11
- data/app/models/faalis/user_message.rb +1 -0
- data/app/policies/faalis/application_policy.rb +6 -2
- data/app/views/faalis/dashboard/resource/create.js.erb +1 -1
- data/app/views/faalis/dashboard/resource/index.html.slim +2 -1
- data/app/views/faalis/dashboard/resource/update.js.erb +1 -1
- data/app/views/faalis/dashboard/users/_form.html.slim +1 -1
- data/app/views/layouts/faalis/dashboard.html.erb +1 -1
- data/config/locales/devise.fa.yml +7 -0
- data/config/locales/faalis.fa.yml +46 -3
- data/db/migrate/20131013091000_devise_create_faalis_users.rb +4 -1
- data/db/migrate/20131020124701_create_faalis_groups.rb +4 -1
- data/db/migrate/20131021170923_create_faalis_permissions.rb +4 -1
- data/db/migrate/20131123120422_add_permissions_groups_table.rb +11 -3
- data/db/migrate/20140613120923_add_users_groups_table.rb +7 -2
- data/db/migrate/20160310105736_create_faalis_user_messages.rb +13 -4
- data/lib/faalis.rb +12 -5
- data/lib/faalis/concerns/authorizable.rb +3 -1
- data/lib/faalis/configuration.rb +17 -2
- data/lib/faalis/dashboard.rb +4 -5
- data/lib/faalis/dashboard/dsl.rb +0 -1
- data/lib/faalis/dashboard/dsl/base.rb +6 -3
- data/lib/faalis/dashboard/dsl/create.rb +0 -1
- data/lib/faalis/dashboard/dsl/index.rb +2 -0
- data/lib/faalis/dashboard/models.rb +2 -0
- data/lib/faalis/dashboard/models/sidebar.rb +1 -1
- data/lib/faalis/dashboard/sections.rb +2 -0
- data/lib/faalis/dashboard/sections/resource.rb +41 -54
- data/lib/faalis/dashboard/sections/resource_create.rb +17 -3
- data/lib/faalis/dashboard/sections/resources_index.rb +5 -3
- data/lib/faalis/engine.rb +6 -0
- data/lib/faalis/i18n.rb +2 -1
- data/lib/faalis/liquid.rb +7 -0
- data/lib/faalis/liquid/block.rb +14 -0
- data/lib/faalis/liquid/render_tag.rb +50 -0
- data/lib/faalis/liquid/tag.rb +51 -0
- data/lib/faalis/orm.rb +1 -0
- data/lib/faalis/{route.rb → routes.rb} +42 -20
- data/lib/faalis/version.rb +1 -1
- data/test/controllers/faalis/dashboard/resource_test.rb +118 -0
- data/test/dummy/config/boot.rb +1 -1
- metadata +60 -79
- checksums.yaml.gz.sig +0 -4
- data.tar.gz.sig +0 -1
- data/app/models/faalis/permissions/auth.rb +0 -8
- data/test/dummy/db/test.sqlite3 +0 -0
- data/test/dummy/log/test.log +0 -0
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fa58084bc0e95c18463f7121531662edd065c2b6
|
4
|
+
data.tar.gz: 83a3adcc22686c1a0d9ea788c28adeedd5b91c17
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6bcdd30638560c823282dfbf382ce4de9aa8c196c604e95a54c7cac2fd2a4f4064bb96c4f2bc4e235529b75c87b071baae2c698e729fe811e21813a7928f4ce8
|
7
|
+
data.tar.gz: 9600c5a45d27d5b44a872228116350954606a081186bbb809a48effe4b3959db1d99943d6a59bd275dbdeccdf9d54d55f7d34eeb3d848aef32a4e41dc286cb24
|
@@ -5,17 +5,19 @@
|
|
5
5
|
//= require faalis/dashboard/share
|
6
6
|
//= require_self
|
7
7
|
|
8
|
-
.
|
9
|
-
|
8
|
+
.btn span {
|
9
|
+
padding-left: 0.4em;
|
10
10
|
}
|
11
11
|
|
12
12
|
.user-image {
|
13
13
|
display: inline !important;
|
14
14
|
}
|
15
|
+
|
15
16
|
.user-name-span {
|
16
17
|
width: 100%;
|
17
18
|
display: inline !important;
|
18
19
|
}
|
20
|
+
|
19
21
|
.dropdown.user.user-menu {
|
20
22
|
width: auto;
|
21
23
|
}
|
@@ -24,10 +24,14 @@ module Faalis::Dashboard
|
|
24
24
|
end
|
25
25
|
|
26
26
|
def create
|
27
|
+
|
27
28
|
authorize Faalis::User
|
28
|
-
group_ids = user_params[:groups]
|
29
|
+
#group_ids = user_params[:groups]
|
29
30
|
|
30
|
-
|
31
|
+
parameters = user_params
|
32
|
+
groups = parameters.delete(:groups)
|
33
|
+
@user = Faalis::User.new(parameters)
|
34
|
+
group_ids = groups.map(&:to_i)
|
31
35
|
@user.groups = Faalis::Group.where(id: group_ids)
|
32
36
|
|
33
37
|
respond_to do |f|
|
@@ -3,9 +3,10 @@ require_dependency 'faalis/dashboard/helpers/box_helpers'
|
|
3
3
|
module Faalis
|
4
4
|
module DashboardHelper
|
5
5
|
include Faalis::Dashboard::Helpers::BoxHelpers
|
6
|
-
|
6
|
+
include ::ActionView::Helpers::TranslationHelper
|
7
7
|
def form_label(resource, name)
|
8
|
-
|
8
|
+
key = "forms.#{@resource.class.name.underscore.to_s.gsub('/', '.')}.#{name}"
|
9
|
+
t(key)
|
9
10
|
end
|
10
11
|
|
11
12
|
def localized_time(time)
|
@@ -19,15 +20,13 @@ module Faalis
|
|
19
20
|
href = options.fetch(:href, '#')
|
20
21
|
remote = options.fetch(:remote, false).to_s
|
21
22
|
|
22
|
-
button = "<a class='#{classes}' href='#{href}'"
|
23
|
-
"data-disable-with='#{title} . . .' data-remote='#{remote}'" +
|
24
|
-
"data-disable-class='disabled'>"
|
23
|
+
button = "<a class='#{classes}' href='#{href}' data-remote='#{remote}'>"
|
25
24
|
|
26
25
|
if icon_class
|
27
26
|
button += "<i class='fa fa-#{icon_class}'></i>"
|
28
27
|
end
|
29
28
|
|
30
|
-
button += title + '</a>'
|
29
|
+
button += "<span>#{title}</span>" + '</a>'
|
31
30
|
|
32
31
|
button.html_safe
|
33
32
|
end
|
@@ -40,7 +39,7 @@ module Faalis
|
|
40
39
|
klass = button.fetch(:class, 'btn-success')
|
41
40
|
remote = button.fetch(:remote, false).to_s
|
42
41
|
icons = button.fetch(:icon_class, "")
|
43
|
-
label = button.fetch(:
|
42
|
+
label = button.fetch(:name, '')
|
44
43
|
model = button.fetch(:model, nil)
|
45
44
|
action = button.fetch(:policy, nil)
|
46
45
|
|
@@ -58,8 +57,8 @@ module Faalis
|
|
58
57
|
|
59
58
|
# Translate route name to url dynamically
|
60
59
|
def get_url(route_name, id = nil, engine = Rails.application)
|
61
|
-
return
|
62
|
-
|
60
|
+
return route_name.call if id.nil?
|
61
|
+
return route_name.call(id) unless id.nil?
|
63
62
|
end
|
64
63
|
|
65
64
|
def draw_menu(menu)
|
@@ -9,6 +9,11 @@ module Faalis
|
|
9
9
|
@group_ids.include? group.id
|
10
10
|
end
|
11
11
|
|
12
|
+
# TODO: merge this method and `member_of?`
|
13
|
+
def member_of_group?(group_name)
|
14
|
+
!self.groups.find_by(name: group_name).nil?
|
15
|
+
end
|
16
|
+
|
12
17
|
def has_permission? action, obj
|
13
18
|
perm = self.groups.includes(:permissions)
|
14
19
|
.where(faalis_permissions: { model: obj, permission_type: action })
|
@@ -23,11 +28,11 @@ module Faalis
|
|
23
28
|
alias_method :can?, :has_permission?
|
24
29
|
|
25
30
|
def has_ownership?(record)
|
26
|
-
has_permission? :ownership, record.
|
31
|
+
has_permission? :ownership, record.name
|
27
32
|
end
|
28
33
|
|
29
34
|
def owned?(record)
|
30
|
-
if has_permission? :ownership, record.
|
35
|
+
if has_permission? :ownership, record.name
|
31
36
|
if record.respond_to? :user
|
32
37
|
return true if record.user == self
|
33
38
|
return false
|
@@ -1,20 +1,24 @@
|
|
1
1
|
module Faalis
|
2
2
|
# This concern contains all the role related methods
|
3
3
|
# to use within `Faalis::User`
|
4
|
-
module Concerns
|
4
|
+
module Concerns
|
5
|
+
module User
|
6
|
+
module UserRoles
|
5
7
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
8
|
+
# Return an array of user roles.
|
9
|
+
def roles
|
10
|
+
self.groups.to_a.map(&:role)
|
11
|
+
end
|
10
12
|
|
11
|
-
|
12
|
-
|
13
|
-
|
13
|
+
def role? role
|
14
|
+
roles.include? role.to_s
|
15
|
+
end
|
14
16
|
|
15
|
-
|
16
|
-
|
17
|
-
|
17
|
+
# A shortcut for `role? :admin`
|
18
|
+
def admin?
|
19
|
+
role? :admin
|
20
|
+
end
|
21
|
+
end
|
18
22
|
end
|
19
23
|
end
|
20
24
|
end
|
@@ -39,12 +39,16 @@ class Faalis::ApplicationPolicy
|
|
39
39
|
attr_reader :user, :scope
|
40
40
|
|
41
41
|
def initialize(user, scope)
|
42
|
-
|
42
|
+
@user = user
|
43
43
|
@scope = scope
|
44
44
|
end
|
45
45
|
|
46
46
|
def resolve
|
47
|
-
scope
|
47
|
+
if @user.has_ownership?(scope)
|
48
|
+
scope.where(user: @user)
|
49
|
+
else
|
50
|
+
scope
|
51
|
+
end
|
48
52
|
end
|
49
53
|
end
|
50
54
|
|
@@ -20,7 +20,7 @@
|
|
20
20
|
|
|
21
21
|
.box-tools.hidden-print
|
22
22
|
- if policy(@resources.model).create?
|
23
|
-
= link_button(t("faalis.dashboard.index_view.new_button", title: t("resources.#{@resources.model.name.underscore}")), remote: false, href: get_url(@new_route, nil, @engine), classes: 'btn-success', icon_class: 'plus')
|
23
|
+
= link_button(t("faalis.dashboard.index_view.new_button", title: t("resources.#{@resources.model.name.underscore}")), remote: false, href: get_url(@new_route, nil, @engine), classes: 'btn-success btn-flat', icon_class: 'plus fa-lg')
|
24
24
|
|
25
25
|
= action_buttons(@_action_buttons)
|
26
26
|
|
@@ -51,6 +51,7 @@
|
|
51
51
|
i.fa.fa-remove.fa-lg.btn-remove
|
52
52
|
|
53
53
|
- @_tools_buttons.each do |btn_name, btn|
|
54
|
+
|
54
55
|
a id=("tool_button_#{btn_name}") class=("link pull-left btn btn-xs #{btn[:class] || 'btn-default'}") href=(btn[:block].call(resource)) data-remote=("#{btn[:remote]}")
|
55
56
|
i class=("fa #{btn[:icon_class]}")
|
56
57
|
= btn_name
|
@@ -48,7 +48,7 @@
|
|
48
48
|
.form-group data-name="groups"
|
49
49
|
label
|
50
50
|
= t('faalis.group.groups')
|
51
|
-
select.multiple.select.form-control name="user[groups]" multiple="multiple"
|
51
|
+
select.multiple.select.form-control name="user[groups][]" multiple="multiple"
|
52
52
|
- @groups.each do |group|
|
53
53
|
- if @user.member_of? group
|
54
54
|
option[value=(group.id) selected]
|
@@ -1,15 +1,29 @@
|
|
1
|
-
---
|
2
1
|
fa:
|
2
|
+
dashboard: 'داشبرد'
|
3
|
+
created_at: 'تاریخ ساخت'
|
4
|
+
updated_at: 'تاریخ ویرایش'
|
5
|
+
password: 'گذرواژه'
|
6
|
+
password_confirmation: 'تکرار گذرواژه'
|
7
|
+
index: 'لیست'
|
8
|
+
edit: 'ویرایش'
|
9
|
+
new: 'جدید'
|
10
|
+
edit_password: 'تغییر گذرواژه'
|
11
|
+
sign_out: 'خروج'
|
12
|
+
users: 'کاربران'
|
13
|
+
groups: 'گروه ها'
|
3
14
|
faalis:
|
15
|
+
save: 'ذخیره'
|
16
|
+
cancel: 'انصراف'
|
17
|
+
back: 'بازگشت'
|
4
18
|
confirm_password: تکرار گذرواژه
|
5
19
|
forgot_your_password: گذرواژه را فراموش کردم
|
6
20
|
didnt_receive_confirmation_instructions: "ایمیل اعتبارسنجی را دریافت نکردم"
|
7
21
|
didnt_receive_unlock_instructions: "ایمیل فعال سازی را دریافت نکردم"
|
8
|
-
|
22
|
+
back: 'بازگشت'
|
9
23
|
|
10
24
|
faalis_version: نسخه فالیس
|
11
25
|
copyright_html: |
|
12
|
-
© 2013-
|
26
|
+
© 2013-2016 <a href="http://yellowen.com">Yellowen</a>.
|
13
27
|
|
14
28
|
page_not_found: آدرس پیدا نشد.
|
15
29
|
page_not_found_desc: آدرس که دنبال آن می گردید پیدا نشد
|
@@ -25,9 +39,19 @@ fa:
|
|
25
39
|
|
26
40
|
group:
|
27
41
|
group: گروه
|
42
|
+
groups: 'گروه ها'
|
43
|
+
name: 'نام'
|
44
|
+
role: 'نقش'
|
45
|
+
group_name: 'نام گروه'
|
28
46
|
|
47
|
+
users: 'کاربران'
|
29
48
|
user:
|
30
49
|
user: کاربر
|
50
|
+
first_name: 'نام'
|
51
|
+
last_name: 'نام خانوادگی'
|
52
|
+
email: 'ایمیل'
|
53
|
+
last_signed_in_at: 'آخرین ورود'
|
54
|
+
groups_of_user: 'گروه های کاربر'
|
31
55
|
|
32
56
|
member_since: "عضو از %{date}"
|
33
57
|
not_authorized: شما مجاز به انجام این فعالیت نیستید.
|
@@ -38,9 +62,24 @@ fa:
|
|
38
62
|
errors:
|
39
63
|
fix_errors: ابتدا این خطاها را رفع کنید
|
40
64
|
dashboard:
|
65
|
+
change_password: 'تغییر گذرواژه'
|
66
|
+
actions: 'عملیات'
|
41
67
|
index_view:
|
42
68
|
new_button: '%{title} جدید'
|
69
|
+
user_message: 'پیام خصوصی'
|
70
|
+
user_messages:
|
71
|
+
inbox: 'صندوق پیام ها'
|
72
|
+
sent: 'ارسال شده ها'
|
73
|
+
draft: 'پیش نویس'
|
43
74
|
users: کاربران
|
75
|
+
user:
|
76
|
+
first_name: 'نام'
|
77
|
+
last_name: 'نام خانوادگی'
|
78
|
+
email: 'ایمیل'
|
79
|
+
last_signed_in_at: 'آخرین ورود'
|
80
|
+
groups_of_user: 'گروه های کاربر'
|
81
|
+
user:
|
82
|
+
email: 'ایمیل'
|
44
83
|
groups: گروه ها
|
45
84
|
user_management: مدیریت کاربران
|
46
85
|
dashboard: داشبرد
|
@@ -63,3 +102,7 @@ fa:
|
|
63
102
|
show: نمایش
|
64
103
|
index: لیست
|
65
104
|
ownership: مالکیت
|
105
|
+
permission:
|
106
|
+
permissions: 'سطوح دسترسی'
|
107
|
+
entity_name: 'نام بخش'
|
108
|
+
permission: 'سطح دسترسی'
|
@@ -1,6 +1,9 @@
|
|
1
1
|
class DeviseCreateFaalisUsers < ActiveRecord::Migration
|
2
2
|
def change
|
3
|
-
|
3
|
+
args = {}
|
4
|
+
args[:id] = :uuid if Faalis::Engine.use_uuid
|
5
|
+
|
6
|
+
create_table(:faalis_users, **args) do |t|
|
4
7
|
## Database authenticatable
|
5
8
|
t.string :email, :null => false, :default => ""
|
6
9
|
t.string :encrypted_password, :null => false, :default => ""
|
@@ -1,6 +1,9 @@
|
|
1
1
|
class CreateFaalisPermissions < ActiveRecord::Migration
|
2
2
|
def change
|
3
|
-
|
3
|
+
args = {}
|
4
|
+
args[:id] = :uuid if Faalis::Engine.use_uuid
|
5
|
+
|
6
|
+
create_table :faalis_permissions, **args do |t|
|
4
7
|
t.string :model
|
5
8
|
t.string :permission_type
|
6
9
|
|
@@ -1,8 +1,16 @@
|
|
1
1
|
class AddPermissionsGroupsTable < ActiveRecord::Migration
|
2
2
|
def change
|
3
|
-
|
4
|
-
|
5
|
-
|
3
|
+
args = {}
|
4
|
+
args[:id] = :uuid if Faalis::Engine.use_uuid
|
5
|
+
|
6
|
+
create_table :faalis_groups_permissions, **args do |t|
|
7
|
+
if Faalis::Engine.use_uuid
|
8
|
+
t.uuid :permission_id
|
9
|
+
t.uuid :group_id
|
10
|
+
else
|
11
|
+
t.belongs_to :permission
|
12
|
+
t.belongs_to :group
|
13
|
+
end
|
6
14
|
end
|
7
15
|
end
|
8
16
|
end
|