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.
Files changed (60) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/faalis/dashboard/application.js.erb +1 -1
  3. data/app/assets/javascripts/faalis/dashboard/init.js.coffee +1 -2
  4. data/app/assets/javascripts/faalis/dashboard/manifest.js +5 -0
  5. data/app/assets/javascripts/faalis/simple.js +1 -1
  6. data/app/assets/stylesheets/faalis/dashboard/ltr/application.css +4 -2
  7. data/app/assets/stylesheets/faalis/dashboard/rtl/application.css +4 -0
  8. data/app/assets/stylesheets/faalis/dashboard/share.scss +6 -0
  9. data/app/controllers/faalis/dashboard/groups_controller.rb +0 -1
  10. data/app/controllers/faalis/dashboard/users_controller.rb +6 -2
  11. data/app/helpers/faalis/dashboard_helper.rb +8 -9
  12. data/app/models/faalis/concerns/user/permission.rb +7 -2
  13. data/app/models/faalis/concerns/user/user_roles.rb +15 -11
  14. data/app/models/faalis/user_message.rb +1 -0
  15. data/app/policies/faalis/application_policy.rb +6 -2
  16. data/app/views/faalis/dashboard/resource/create.js.erb +1 -1
  17. data/app/views/faalis/dashboard/resource/index.html.slim +2 -1
  18. data/app/views/faalis/dashboard/resource/update.js.erb +1 -1
  19. data/app/views/faalis/dashboard/users/_form.html.slim +1 -1
  20. data/app/views/layouts/faalis/dashboard.html.erb +1 -1
  21. data/config/locales/devise.fa.yml +7 -0
  22. data/config/locales/faalis.fa.yml +46 -3
  23. data/db/migrate/20131013091000_devise_create_faalis_users.rb +4 -1
  24. data/db/migrate/20131020124701_create_faalis_groups.rb +4 -1
  25. data/db/migrate/20131021170923_create_faalis_permissions.rb +4 -1
  26. data/db/migrate/20131123120422_add_permissions_groups_table.rb +11 -3
  27. data/db/migrate/20140613120923_add_users_groups_table.rb +7 -2
  28. data/db/migrate/20160310105736_create_faalis_user_messages.rb +13 -4
  29. data/lib/faalis.rb +12 -5
  30. data/lib/faalis/concerns/authorizable.rb +3 -1
  31. data/lib/faalis/configuration.rb +17 -2
  32. data/lib/faalis/dashboard.rb +4 -5
  33. data/lib/faalis/dashboard/dsl.rb +0 -1
  34. data/lib/faalis/dashboard/dsl/base.rb +6 -3
  35. data/lib/faalis/dashboard/dsl/create.rb +0 -1
  36. data/lib/faalis/dashboard/dsl/index.rb +2 -0
  37. data/lib/faalis/dashboard/models.rb +2 -0
  38. data/lib/faalis/dashboard/models/sidebar.rb +1 -1
  39. data/lib/faalis/dashboard/sections.rb +2 -0
  40. data/lib/faalis/dashboard/sections/resource.rb +41 -54
  41. data/lib/faalis/dashboard/sections/resource_create.rb +17 -3
  42. data/lib/faalis/dashboard/sections/resources_index.rb +5 -3
  43. data/lib/faalis/engine.rb +6 -0
  44. data/lib/faalis/i18n.rb +2 -1
  45. data/lib/faalis/liquid.rb +7 -0
  46. data/lib/faalis/liquid/block.rb +14 -0
  47. data/lib/faalis/liquid/render_tag.rb +50 -0
  48. data/lib/faalis/liquid/tag.rb +51 -0
  49. data/lib/faalis/orm.rb +1 -0
  50. data/lib/faalis/{route.rb → routes.rb} +42 -20
  51. data/lib/faalis/version.rb +1 -1
  52. data/test/controllers/faalis/dashboard/resource_test.rb +118 -0
  53. data/test/dummy/config/boot.rb +1 -1
  54. metadata +60 -79
  55. checksums.yaml.gz.sig +0 -4
  56. data.tar.gz.sig +0 -1
  57. data/app/models/faalis/permissions/auth.rb +0 -8
  58. data/test/dummy/db/test.sqlite3 +0 -0
  59. data/test/dummy/log/test.log +0 -0
  60. metadata.gz.sig +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a9a8467c27e4b5bc5e97650d84280a5b47a063f1
4
- data.tar.gz: 5e44dc7ea9f1a5e6f1cb29a3a28ada7842652f29
3
+ metadata.gz: fa58084bc0e95c18463f7121531662edd065c2b6
4
+ data.tar.gz: 83a3adcc22686c1a0d9ea788c28adeedd5b91c17
5
5
  SHA512:
6
- metadata.gz: 2eae75d88cfe139f49133237edd7e962d3d3fb53be8de0dab5fdd7b3cb239a63387a06f72142b7635f7faf80728172858ca3e6578e3f11dd2a93b445590ad6f4
7
- data.tar.gz: 5e04d9cbe4eab5e06d5dd5f0243641d0708ac579af95cb06fc86eaf01f97430febce7b3d05ac44a4a4d9f8bb1439dec3416a0e4e365652fd9ebf8f41b60fe166
6
+ metadata.gz: 6bcdd30638560c823282dfbf382ce4de9aa8c196c604e95a54c7cac2fd2a4f4064bb96c4f2bc4e235529b75c87b071baae2c698e729fe811e21813a7928f4ce8
7
+ data.tar.gz: 9600c5a45d27d5b44a872228116350954606a081186bbb809a48effe4b3959db1d99943d6a59bd275dbdeccdf9d54d55f7d34eeb3d848aef32a4e41dc286cb24
@@ -17,7 +17,7 @@
17
17
  //= require turbolinks
18
18
 
19
19
  // Misc ---------------------------
20
- //= require sugar/sugar-full.development
20
+ //= require sugar
21
21
 
22
22
  // JQuery Libraries ---------------
23
23
  //= require admin_lte/admin_lte
@@ -1,7 +1,6 @@
1
1
  # Setup select2 for selects with multiple class
2
2
  setup_select2 = ->
3
- $("select.multiple.select").select2()
4
-
3
+ $("select.multiple.select").select2({tags:[]})
5
4
  setup_icheck = ->
6
5
  $('input').iCheck {
7
6
  labelHover: false,
@@ -0,0 +1,5 @@
1
+ //= link dashboard/application.js
2
+ //= link faalis/dashboard/ltr/application.css
3
+ //= link faalis/dashboard/rtl/application.css
4
+ //= link faalis/simple/ltr/application.css
5
+ //= link faalis/simple/rtl/application.css
@@ -5,7 +5,7 @@
5
5
  //= require turbolinks
6
6
 
7
7
  // Misc ---------------------------
8
- //= require sugar/sugar-full.development
8
+ //= require sugar
9
9
 
10
10
  // JQuery Libraries ---------------
11
11
  //= require admin_lte/admin_lte
@@ -5,17 +5,19 @@
5
5
  //= require faalis/dashboard/share
6
6
  //= require_self
7
7
 
8
- .fa {
9
- padding-right: 0.4em;
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
  }
@@ -5,3 +5,7 @@
5
5
  //= require faalis/dashboard/share
6
6
  //= require faalis/dashboard/rtl/base
7
7
  //= require_self
8
+
9
+ .btn span {
10
+ padding-right: 0.4em;
11
+ }
@@ -54,3 +54,9 @@
54
54
  margin-left: 5px;
55
55
  margin-right: 5px;
56
56
  }
57
+
58
+ html, body, .wrapper {
59
+ min-height: 100% !important;
60
+ height: 100% !important;
61
+ overflow-y: scroll;
62
+ }
@@ -42,7 +42,6 @@ module Faalis::Dashboard
42
42
  def update
43
43
  @group = Faalis::Group.find(params[:id])
44
44
  authorize @group
45
-
46
45
  @group.permissions = populate_permissions
47
46
  @group.name = group_params[:name]
48
47
  @group.role = group_params[:name].underscore
@@ -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
- @user = Faalis::User.new(user_params)
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
- ::I18n.t("forms.#{@resource.class.name.underscore.to_s.gsub('/', '.')}.#{name}")
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(:label, '')
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 engine.routes.url_helpers.send(route_name, { id: id.to_s }) unless id.nil?
62
- engine.routes.url_helpers.send(route_name)
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.class.to_s
31
+ has_permission? :ownership, record.name
27
32
  end
28
33
 
29
34
  def owned?(record)
30
- if has_permission? :ownership, record.class.to_s
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::User::UserRoles
4
+ module Concerns
5
+ module User
6
+ module UserRoles
5
7
 
6
- # Return an array of user roles.
7
- def roles
8
- self.groups.to_a.map(&:role)
9
- end
8
+ # Return an array of user roles.
9
+ def roles
10
+ self.groups.to_a.map(&:role)
11
+ end
10
12
 
11
- def role? role
12
- roles.include? role.to_s
13
- end
13
+ def role? role
14
+ roles.include? role.to_s
15
+ end
14
16
 
15
- # A shortcut for `role? :admin`
16
- def admin?
17
- role? :admin
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
@@ -1,5 +1,6 @@
1
1
  module Faalis
2
2
  class UserMessage < ActiveRecord::Base
3
+ include ::Faalis::Concerns::Authorizable
3
4
  belongs_to :sender, class_name: 'Faalis::User'
4
5
  belongs_to :reciever, class_name: 'Faalis::User'
5
6
  end
@@ -39,12 +39,16 @@ class Faalis::ApplicationPolicy
39
39
  attr_reader :user, :scope
40
40
 
41
41
  def initialize(user, scope)
42
- @@user = @user
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
 
@@ -1,3 +1,3 @@
1
1
  success_message('<%= @_msg || t("faalis.dashboard.create_success_msg", resource: @resource_title) %>');
2
- var target = '<%= get_url(@index_route, @resource.id, @engine) %>';
2
+ var target = '<%= get_url(@index_route, nil, @engine) %>';
3
3
  redirect_to(target);
@@ -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
@@ -1,3 +1,3 @@
1
1
  success_message('<%= @_msg || t("faalis.dashboard.edit_success_msg", resource: @resource_title) %>');
2
- var target = '<%= get_url(@index_route, @resource.id, @engine) %>';
2
+ var target = '<%= get_url(@index_route, nil, @engine) %>';
3
3
  redirect_to(target);
@@ -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]
@@ -45,7 +45,7 @@
45
45
  <%= yield %>
46
46
  </section><!-- /.content -->
47
47
  </div>
48
- <%= render 'faalis/dashboard/shared/footer' %>
48
+
49
49
  <%= render 'faalis/dashboard/shared/control_sidebar' %>
50
50
  </div>
51
51
  </body>
@@ -1,4 +1,11 @@
1
1
  fa:
2
+ activerecord:
3
+ errors:
4
+ models:
5
+ faalis/user:
6
+ attributes:
7
+ email:
8
+ taken: ' قبلا در سیستم ثبت شده است'
2
9
  errors:
3
10
  messages:
4
11
  expired: 'منقضی شده، لطفا درخواست جدید بدهید'
@@ -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
- &copy; 2013-2015 <a href="http://yellowen.com">Yellowen</a>.
26
+ &copy; 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
- create_table(:faalis_users) do |t|
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 CreateFaalisGroups < ActiveRecord::Migration
2
2
  def change
3
- create_table :faalis_groups do |t|
3
+ args = {}
4
+ args[:id] = :uuid if Faalis::Engine.use_uuid
5
+
6
+ create_table :faalis_groups, **args do |t|
4
7
  t.string :name
5
8
  t.string :role
6
9
 
@@ -1,6 +1,9 @@
1
1
  class CreateFaalisPermissions < ActiveRecord::Migration
2
2
  def change
3
- create_table :faalis_permissions do |t|
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
- create_table :faalis_groups_permissions do |t|
4
- t.belongs_to :permission
5
- t.belongs_to :group
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