usman 0.3.9 → 0.3.10

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.
Files changed (65) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +3 -3
  3. data/app/controllers/usman/admin_controller.rb +1 -18
  4. data/app/controllers/usman/api/v1/docs_controller.rb +53 -12
  5. data/app/controllers/usman/application_controller.rb +2 -0
  6. data/app/controllers/usman/features_controller.rb +4 -2
  7. data/app/controllers/usman/permissions_controller.rb +34 -3
  8. data/app/controllers/usman/resource_controller.rb +6 -1
  9. data/app/controllers/usman/user_roles_controller.rb +1 -0
  10. data/app/helpers/usman/authentication_helper.rb +102 -34
  11. data/app/models/feature.rb +2 -2
  12. data/app/models/permission.rb +11 -0
  13. data/app/models/user.rb +65 -0
  14. data/app/services/usman/sms_service.rb +91 -0
  15. data/app/views/layouts/kuppayam/_sidebar.html.erb +125 -72
  16. data/app/views/usman/dashboard/_index.html.erb +40 -0
  17. data/app/views/usman/dashboard/_super_admin_index.html.erb +22 -0
  18. data/app/views/usman/dashboard/index.html.erb +6 -128
  19. data/app/views/usman/features/_form.html.erb +1 -1
  20. data/app/views/usman/features/_index.html.erb +18 -8
  21. data/app/views/usman/features/_row.html.erb +14 -8
  22. data/app/views/usman/features/_show.html.erb +13 -10
  23. data/app/views/usman/features/index.html.erb +2 -2
  24. data/app/views/usman/permissions/_form.html.erb +2 -2
  25. data/app/views/usman/permissions/_index.html.erb +6 -5
  26. data/app/views/usman/permissions/_row.html.erb +6 -5
  27. data/app/views/usman/permissions/_show.html.erb +5 -5
  28. data/app/views/usman/permissions/index.html.erb +15 -17
  29. data/app/views/usman/registration_devices/_index.html.erb +11 -7
  30. data/app/views/usman/registration_devices/_row.html.erb +18 -18
  31. data/app/views/usman/registrations/_index.html.erb +17 -13
  32. data/app/views/usman/registrations/_row.html.erb +14 -10
  33. data/app/views/usman/roles/_index.html.erb +8 -4
  34. data/app/views/usman/roles/_row.html.erb +7 -5
  35. data/app/views/usman/roles/_show.html.erb +9 -5
  36. data/app/views/usman/roles/index.html.erb +3 -3
  37. data/app/views/usman/sessions/_permission_denied.js.erb +3 -0
  38. data/app/views/usman/user_roles/_index.html.erb +6 -0
  39. data/app/views/usman/user_roles/_row.html.erb +4 -0
  40. data/app/views/usman/users/_index.html.erb +19 -15
  41. data/app/views/usman/users/_row.html.erb +17 -15
  42. data/app/views/usman/users/_show.html.erb +5 -3
  43. data/app/views/usman/users/index.html.erb +3 -3
  44. data/config/locales/usman/authentication.ar.yml +5 -2
  45. data/config/locales/usman/authentication.en.yml +2 -2
  46. data/config/locales/usman/sms.en.yml +17 -0
  47. data/config/routes.rb +11 -12
  48. data/db/data/dummy/permissions.csv +1 -76
  49. data/db/data/dummy/users.csv +3 -6
  50. data/db/data/users.csv +3 -1
  51. data/db/master_data/features.csv +9 -0
  52. data/db/master_data/roles.csv +1 -0
  53. data/lib/tasks/usman/data.rake +15 -9
  54. data/lib/tasks/usman/master_data.rake +7 -3
  55. data/lib/usman/action_view/permissions_helper.rb +24 -0
  56. data/lib/usman/engine.rb +6 -0
  57. data/lib/usman/version.rb +1 -1
  58. data/lib/usman.rb +1 -0
  59. metadata +27 -12
  60. data/app/controllers/usman/api/v1/docs_base_controller.rb +0 -25
  61. data/app/views/kuppayam/api/docs/_navigation.html.erb +0 -67
  62. data/db/data/dummy/features.csv +0 -17
  63. data/db/data/dummy/roles.csv +0 -5
  64. data/db/data/features.csv +0 -17
  65. data/db/data/roles.csv +0 -5
@@ -9,7 +9,9 @@
9
9
  <th class="hidden-xs hidden-sm">Email</th>
10
10
  <th class="hidden-xs hidden-sm">Roles</th>
11
11
  <th>Status</th>
12
+ <% if display_manage_links? %>
12
13
  <th style="text-align: center;" colspan="2">Actions</th>
14
+ <% end %>
13
15
  </tr>
14
16
  </thead>
15
17
  <tbody>
@@ -72,26 +74,28 @@
72
74
  <% end %>
73
75
  </td>
74
76
 
75
- <td class="action-links" style="width:15%">
77
+ <% if display_manage_links? %>
78
+ <td class="action-links" style="width:15%">
76
79
 
77
- <%= link_to raw("<i class=\"linecons-pencil\"></i> Edit User"), edit_link, :remote=>true, class: "edit" if user.can_be_edited? %>
80
+ <%= link_to raw("<i class=\"linecons-pencil\"></i> Edit User"), edit_link, :remote=>true, class: "edit" if user.can_be_edited? && display_edit_links? %>
78
81
 
79
- <%= link_to raw("<i class=\"linecons-trash\"></i> Delete"), delete_link, method: :delete, role: "menuitem", tabindex: "-1", data: { confirm: 'Are you sure?' }, :remote=>true, class: "delete" if user.can_be_deleted? && (@current_user != user) %>
80
-
81
- </td>
82
-
83
- <td class="action-links" style="width:15%">
82
+ <%= link_to raw("<i class=\"linecons-trash\"></i> Delete"), delete_link, method: :delete, role: "menuitem", tabindex: "-1", data: { confirm: 'Are you sure?' }, :remote=>true, class: "delete" if @current_user.super_admin? && user.can_be_deleted? && (@current_user != user) %>
83
+ </td>
84
+ <% end %>
84
85
 
85
- <!-- Approve -->
86
- <%= link_to raw("<i class=\"fa fa-circle-o mr-5\"></i> Approve"), update_status_user_path(:id =>user.id, :status =>'approved'), :method =>'PUT', :remote=>true, role: "menuitem", tabindex: "-1" if user.can_be_approved? && (@current_user != user) %>
86
+ <% if display_edit_links? %>
87
+ <td class="action-links" style="width:15%">
87
88
 
88
- <!-- Mark as Pending -->
89
- <%= link_to raw("<i class=\"fa fa-circle mr-5\"></i> Mark as Pending"), update_status_user_path(:id =>user.id, :status =>'pending'), :method =>'PUT', :remote=>true, role: "menuitem", tabindex: "-1" if user.can_be_marked_as_pending? && (@current_user != user) %>
90
-
91
- <!-- Suspend -->
92
- <%= link_to raw("<i class=\"fa fa-edit mr-5\"></i> Suspend"), update_status_user_path(:id =>user.id, :status =>'suspended'), :method =>'PUT', :remote=>true, role: "menuitem", tabindex: "-1" if user.can_be_suspended? && (@current_user != user) %>
89
+ <!-- Approve -->
90
+ <%= link_to raw("<i class=\"fa fa-circle-o mr-5\"></i> Approve"), update_status_user_path(:id =>user.id, :status =>'approved'), :method =>'PUT', :remote=>true, role: "menuitem", tabindex: "-1" if user.can_be_approved? && (@current_user != user) %>
93
91
 
94
- </td>
92
+ <!-- Mark as Pending -->
93
+ <%= link_to raw("<i class=\"fa fa-circle mr-5\"></i> Mark as Pending"), update_status_user_path(:id =>user.id, :status =>'pending'), :method =>'PUT', :remote=>true, role: "menuitem", tabindex: "-1" if user.can_be_marked_as_pending? && (@current_user != user) %>
94
+
95
+ <!-- Suspend -->
96
+ <%= link_to raw("<i class=\"fa fa-edit mr-5\"></i> Suspend"), update_status_user_path(:id =>user.id, :status =>'suspended'), :method =>'PUT', :remote=>true, role: "menuitem", tabindex: "-1" if user.can_be_suspended? && (@current_user != user) %>
97
+ </td>
98
+ <% end %>
95
99
 
96
100
  </tr>
97
101
  <% end %>
@@ -55,26 +55,28 @@
55
55
  <% end %>
56
56
  </td>
57
57
 
58
- <td class="action-links" style="width:15%">
58
+ <% if display_manage_links? %>
59
+ <td class="action-links" style="width:15%">
59
60
 
60
- <%= link_to raw("<i class=\"linecons-pencil\"></i> Edit User"), edit_link, :remote=>true, class: "edit" if @user.can_be_edited? %>
61
+ <%= link_to raw("<i class=\"linecons-pencil\"></i> Edit User"), edit_link, :remote=>true, class: "edit" if user.can_be_edited? && display_edit_links? %>
61
62
 
62
- <%= link_to raw("<i class=\"linecons-trash\"></i> Delete"), delete_link, method: :delete, role: "menuitem", tabindex: "-1", data: { confirm: 'Are you sure?' }, :remote=>true, class: "delete" if @user.can_be_deleted? && (@current_user != user) %>
63
-
64
- </td>
65
-
66
- <td class="action-links" style="width:15%">
63
+ <%= link_to raw("<i class=\"linecons-trash\"></i> Delete"), delete_link, method: :delete, role: "menuitem", tabindex: "-1", data: { confirm: 'Are you sure?' }, :remote=>true, class: "delete" if user.can_be_deleted? && (@current_user != user) && display_delete_links? %>
64
+ </td>
65
+ <% end %>
67
66
 
68
- <!-- Approve -->
69
- <%= link_to raw("<i class=\"fa fa-circle-o mr-5\"></i> Approve"), update_status_user_path(:id =>user.id, :status =>'approved'), :method =>'PUT', :remote=>true, role: "menuitem", tabindex: "-1" if user.can_be_approved? && (@current_user != user) %>
67
+ <% if display_edit_links? %>
68
+ <td class="action-links" style="width:15%">
70
69
 
71
- <!-- Mark as Pending -->
72
- <%= link_to raw("<i class=\"fa fa-circle mr-5\"></i> Mark as Pending"), update_status_user_path(:id =>user.id, :status =>'pending'), :method =>'PUT', :remote=>true, role: "menuitem", tabindex: "-1" if user.can_be_marked_as_pending? && (@current_user != user) %>
73
-
74
- <!-- Suspend -->
75
- <%= link_to raw("<i class=\"fa fa-edit mr-5\"></i> Suspend"), update_status_user_path(:id =>user.id, :status =>'suspended'), :method =>'PUT', :remote=>true, role: "menuitem", tabindex: "-1" if user.can_be_suspended? && (@current_user != user) %>
70
+ <!-- Approve -->
71
+ <%= link_to raw("<i class=\"fa fa-circle-o mr-5\"></i> Approve"), update_status_user_path(:id =>user.id, :status =>'approved'), :method =>'PUT', :remote=>true, role: "menuitem", tabindex: "-1" if user.can_be_approved? && (@current_user != user) %>
76
72
 
77
- </td>
73
+ <!-- Mark as Pending -->
74
+ <%= link_to raw("<i class=\"fa fa-circle mr-5\"></i> Mark as Pending"), update_status_user_path(:id =>user.id, :status =>'pending'), :method =>'PUT', :remote=>true, role: "menuitem", tabindex: "-1" if user.can_be_marked_as_pending? && (@current_user != user) %>
75
+
76
+ <!-- Suspend -->
77
+ <%= link_to raw("<i class=\"fa fa-edit mr-5\"></i> Suspend"), update_status_user_path(:id =>user.id, :status =>'suspended'), :method =>'PUT', :remote=>true, role: "menuitem", tabindex: "-1" if user.can_be_suspended? && (@current_user != user) %>
78
+ </td>
79
+ <% end %>
78
80
 
79
81
  </tr>
80
82
 
@@ -6,7 +6,7 @@
6
6
 
7
7
  <div class="col-md-3 col-sm-12 col-xs-12" style="border-right:1px solid #f1f1f1;">
8
8
 
9
- <% if @current_user.super_admin? %>
9
+ <% if display_edit_links? %>
10
10
  <%= edit_image(@user,
11
11
  "profile_picture.image.large.url",
12
12
  upload_image_link(@user, :profile_picture, nil ),
@@ -43,8 +43,9 @@
43
43
 
44
44
  <div class="visible-sm visible-xs mb-50"></div>
45
45
 
46
- </div>
46
+ </div>
47
47
 
48
+ <% if display_manage_links? %>
48
49
  <div class="col-md-3 col-sm-12 col-xs-12">
49
50
 
50
51
  <% edit_link = edit_user_path(id: @user.id) %>
@@ -52,7 +53,7 @@
52
53
 
53
54
  <%= link_to raw("<i class=\"linecons-pencil\"></i> Edit User"), edit_link, :remote=>true, class: "btn btn-block btn-success" if @user.can_be_edited? %>
54
55
 
55
- <%= link_to raw("<i class=\"linecons-trash\"></i> Delete"), delete_link, method: :delete, role: "menuitem", tabindex: "-1", data: { confirm: 'Are you sure?' }, :remote=>true, class: "btn btn-block btn-danger btn-only-hover" if @user.can_be_deleted? && (@current_user != @user) %>
56
+ <%= link_to raw("<i class=\"linecons-trash\"></i> Delete"), delete_link, method: :delete, role: "menuitem", tabindex: "-1", data: { confirm: 'Are you sure?' }, :remote=>true, class: "btn btn-block btn-danger btn-only-hover" if @user.can_be_deleted? && (@current_user != @user) && @current_permission.can_delete? %>
56
57
 
57
58
  <% if @current_user.super_admin? %>
58
59
 
@@ -78,6 +79,7 @@
78
79
  <div class="visible-sm visible-xs mb-50"></div>
79
80
 
80
81
  </div>
82
+ <% end %>
81
83
 
82
84
  </div>
83
85
 
@@ -26,11 +26,11 @@
26
26
  <div class="row">
27
27
  <div class="col-md-6">
28
28
 
29
- <%= theme_button('Add a User', 'plus', new_user_path(), classes: "pull-left", btn_type: "success") %>
29
+ <%= theme_button('Add a User', 'plus', new_user_path(), classes: "pull-left mr-10", btn_type: "success") if @current_user.has_create_permission?(User) %>
30
30
 
31
- <%= theme_button('Refresh', 'refresh', users_path(), classes: "pull-left ml-10", btn_type: "white") %>
31
+ <%= theme_button('Refresh', 'refresh', users_path(), classes: "pull-left mr-10", btn_type: "white") %>
32
32
 
33
- <%= theme_button('Manage Roles', 'nothing linecons-graduation-cap', roles_path(), classes: "pull-left ml-10", btn_type: "white", remote: false) %>
33
+ <%= theme_button('Manage Roles', 'nothing linecons-graduation-cap', roles_path(), classes: "pull-left mr-10", btn_type: "white", remote: false) if @current_user.has_create_permission?(Role) %>
34
34
 
35
35
  <!-- Single button -->
36
36
  <div class="ml-10 btn-group hidden">
@@ -1,4 +1,4 @@
1
- ar:
1
+ en:
2
2
  authentication:
3
3
  permission_denied:
4
4
  heading: "Permission Denied"
@@ -11,7 +11,7 @@ ar:
11
11
  message: "Invalid Username/Email or password."
12
12
  user_is_pending:
13
13
  heading: "Account Pending"
14
- message: "Your account is not yet approved, please contact administrator to activate your account"
14
+ message: "Your account is yet to be approved, please contact administrator to activate your account"
15
15
  user_is_suspended:
16
16
  heading: "Account Suspended"
17
17
  message: "Your account is suspended, please contact administrator"
@@ -21,5 +21,8 @@ ar:
21
21
  logged_out:
22
22
  heading: "Signed Out"
23
23
  message: "You have successfully signed out"
24
+ login_required:
25
+ heading: "Login Required"
26
+ message: "You need to login to access this page."
24
27
  masquerade: "لقد سجلت الدخول بنجاح - %{user}"
25
28
  sign_in_back: "You have successfully signed in back as %{user}"
@@ -11,7 +11,7 @@ en:
11
11
  message: "Invalid Username/Email or password."
12
12
  user_is_pending:
13
13
  heading: "Account Pending"
14
- message: "Your account is not yet to be approved, please contact administrator to activate your account"
14
+ message: "Your account is yet to be approved, please contact administrator to activate your account"
15
15
  user_is_suspended:
16
16
  heading: "Account Suspended"
17
17
  message: "Your account is suspended, please contact administrator"
@@ -24,5 +24,5 @@ en:
24
24
  login_required:
25
25
  heading: "Login Required"
26
26
  message: "You need to login to access this page."
27
- masquerade: "لقد سجلت الدخول بنجاح - %{user}"
27
+ masquerade: "Masqueraded as - %{user}"
28
28
  sign_in_back: "You have successfully signed in back as %{user}"
@@ -0,0 +1,17 @@
1
+ en:
2
+ sms:
3
+ credentials:
4
+ secret_file_not_found:
5
+ heading: "AWS Secret File missing"
6
+ message: "Create the AWS Secret file in YAML format and put the credentials"
7
+ invalid_format:
8
+ heading: "AWS Secret File is not in the required format"
9
+ message: "Region, AccessKeyId & SecretAccessKey shoudl have values"
10
+ unexpected_error:
11
+ heading: "Unexpected Error Occured while creating AWS SNS Client"
12
+ message: "Make sure the region & aws secrets are correct"
13
+ invalid_credentials:
14
+ heading: "AWS Secret File has some issues"
15
+ message: "We were unable to parse the YAML file"
16
+
17
+
data/config/routes.rb CHANGED
@@ -50,27 +50,26 @@ Usman::Engine.routes.draw do
50
50
  namespace :v1 do
51
51
 
52
52
  # Registrations
53
- post :register, :controller => "registrations"
54
- post :resend_otp, :controller => "registrations"
55
- post :verify_otp, :controller => "registrations"
56
- post :accept_tac, :controller => "registrations"
53
+ post :register, :controller => "registrations", as: :register
54
+ post :resend_otp, :controller => "registrations", as: :resend_otp
55
+ post :verify_otp, :controller => "registrations", as: :verify_otp
56
+ post :accept_tac, :controller => "registrations", as: :accept_tac
57
57
 
58
58
  # Profile
59
- post :create_profile, :controller => "profile"
60
- put :update_profile, :controller => "profile"
61
- get :profile_info, :controller => "profile"
59
+ post :create_profile, :controller => "profile", as: :create_profile
60
+ put :update_profile, :controller => "profile", as: :update_profile
61
+ get :profile_info, :controller => "profile", as: :profile_info
62
62
 
63
63
  # Profile Picture
64
- post 'profile/profile_picture_base64', :controller => "profile_picture", action: :profile_picture_base64
65
- post 'profile/profile_picture', :controller => "profile_picture", action: :profile_picture
66
- delete 'profile/profile_picture', :controller => "profile_picture", action: :destroy_profile_picture
64
+ post 'profile/profile_picture_base64', :controller => "profile_picture", action: :profile_picture_base64, as: :profile_picture_base64
65
+ post 'profile/profile_picture', :controller => "profile_picture", action: :profile_picture, as: :profile_picture
66
+ delete 'profile/profile_picture', :controller => "profile_picture", action: :destroy_profile_picture, as: :destroy_profile_picture
67
67
  end
68
68
  end
69
69
 
70
- scope :docs do
70
+ scope :docs, as: 'docs' do
71
71
  namespace :api do
72
72
  namespace :v1 do
73
- get 'index', :controller => "docs"
74
73
  get 'register', :controller => "docs"
75
74
  get 'resend_otp', :controller => "docs"
76
75
  get 'verify_otp', :controller => "docs"
@@ -1,77 +1,2 @@
1
1
  user,feature,can_create,can_read,can_update,can_delete
2
- kpvarma,Products,TRUE,TRUE,TRUE,TRUE
3
- kpvarma,Categories,TRUE,TRUE,TRUE,TRUE
4
- kpvarma,Brands,TRUE,TRUE,TRUE,TRUE
5
- kpvarma,Events & News,TRUE,TRUE,TRUE,TRUE
6
- kpvarma,Subscriptions,TRUE,TRUE,TRUE,TRUE
7
- kpvarma,Enquiries,TRUE,TRUE,TRUE,TRUE
8
- kpvarma,Teams,TRUE,TRUE,TRUE,TRUE
9
- kpvarma,Testimonials,TRUE,TRUE,TRUE,TRUE
10
- kpvarma,Careers / Jobs,TRUE,TRUE,TRUE,TRUE
11
- ,,,,,
12
- vinodh,Products,TRUE,TRUE,TRUE,TRUE
13
- vinodh,Categories,TRUE,TRUE,TRUE,TRUE
14
- vinodh,Brands,TRUE,TRUE,TRUE,TRUE
15
- vinodh,Events & News,TRUE,TRUE,TRUE,TRUE
16
- vinodh,Subscriptions,TRUE,TRUE,TRUE,TRUE
17
- vinodh,Enquiries,TRUE,TRUE,TRUE,TRUE
18
- vinodh,Teams,TRUE,TRUE,TRUE,TRUE
19
- vinodh,Testimonials,TRUE,TRUE,TRUE,TRUE
20
- vinodh,Careers / Jobs,TRUE,TRUE,TRUE,TRUE
21
- ,,,,,
22
- junaid.ramzan,Products,TRUE,TRUE,TRUE,TRUE
23
- junaid.ramzan,Categories,TRUE,TRUE,TRUE,TRUE
24
- junaid.ramzan,Brands,TRUE,TRUE,TRUE,TRUE
25
- junaid.ramzan,Events & News,TRUE,TRUE,TRUE,TRUE
26
- junaid.ramzan,Subscriptions,TRUE,TRUE,TRUE,TRUE
27
- junaid.ramzan,Enquiries,TRUE,TRUE,TRUE,TRUE
28
- junaid.ramzan,Teams,TRUE,TRUE,TRUE,TRUE
29
- junaid.ramzan,Testimonials,TRUE,TRUE,TRUE,TRUE
30
- junaid.ramzan,Careers / Jobs,TRUE,TRUE,TRUE,TRUE
31
- ,,,,,
32
- angelo.joseph,Products,TRUE,TRUE,TRUE,TRUE
33
- angelo.joseph,Categories,TRUE,TRUE,TRUE,TRUE
34
- angelo.joseph,Brands,TRUE,TRUE,TRUE,TRUE
35
- angelo.joseph,Events & News,FALSE,FALSE,FALSE,FALSE
36
- angelo.joseph,Subscriptions,FALSE,FALSE,FALSE,FALSE
37
- angelo.joseph,Enquiries,FALSE,FALSE,FALSE,FALSE
38
- angelo.joseph,Teams,FALSE,FALSE,FALSE,FALSE
39
- angelo.joseph,Testimonials,FALSE,FALSE,FALSE,FALSE
40
- angelo.joseph,Careers / Jobs,FALSE,FALSE,FALSE,FALSE
41
- ,,,,,
42
- guna.neweast,Products,TRUE,TRUE,TRUE,TRUE
43
- guna.neweast,Categories,TRUE,TRUE,TRUE,TRUE
44
- guna.neweast,Brands,TRUE,TRUE,TRUE,TRUE
45
- guna.neweast,Events & News,FALSE,FALSE,FALSE,FALSE
46
- guna.neweast,Subscriptions,FALSE,FALSE,FALSE,FALSE
47
- guna.neweast,Enquiries,FALSE,FALSE,FALSE,FALSE
48
- guna.neweast,Teams,FALSE,FALSE,FALSE,FALSE
49
- guna.neweast,Testimonials,FALSE,FALSE,FALSE,FALSE
50
- guna.neweast,Careers / Jobs,FALSE,FALSE,FALSE,FALSE
51
- ,,,,,
52
- stephen.price,Products,TRUE,TRUE,TRUE,TRUE
53
- stephen.price,Categories,TRUE,TRUE,TRUE,TRUE
54
- stephen.price,Brands,TRUE,TRUE,TRUE,TRUE
55
- stephen.price,Events & News,FALSE,FALSE,FALSE,FALSE
56
- stephen.price,Subscriptions,FALSE,FALSE,FALSE,FALSE
57
- stephen.price,Enquiries,FALSE,FALSE,FALSE,FALSE
58
- stephen.price,Teams,FALSE,FALSE,FALSE,FALSE
59
- stephen.price,Testimonials,FALSE,FALSE,FALSE,FALSE
60
- stephen.price,Careers / Jobs,FALSE,FALSE,FALSE,FALSE
61
- ,,,,,
62
- silk.smitha,Users,TRUE,TRUE,TRUE,TRUE
63
- silk.smitha,Roles,TRUE,TRUE,TRUE,TRUE
64
- silk.smitha,Products,TRUE,TRUE,TRUE,TRUE
65
- silk.smitha,Categories,TRUE,TRUE,TRUE,TRUE
66
- silk.smitha,Brands,TRUE,TRUE,TRUE,TRUE
67
- silk.smitha,Stores,TRUE,TRUE,TRUE,TRUE
68
- silk.smitha,Suppliers,TRUE,TRUE,TRUE,TRUE
69
- silk.smitha,Countries,TRUE,TRUE,TRUE,TRUE
70
- silk.smitha,Regions,TRUE,TRUE,TRUE,TRUE
71
- silk.smitha,Exchange Rates,TRUE,TRUE,TRUE,TRUE
72
- silk.smitha,Events & News,TRUE,TRUE,TRUE,TRUE
73
- silk.smitha,Subscriptions,TRUE,TRUE,TRUE,TRUE
74
- silk.smitha,Enquiries,TRUE,TRUE,TRUE,TRUE
75
- silk.smitha,Teams,TRUE,TRUE,TRUE,TRUE
76
- silk.smitha,Testimonials,TRUE,TRUE,TRUE,TRUE
77
- silk.smitha,Careers / Jobs,TRUE,TRUE,TRUE,TRUE
2
+ kpvarma,User,TRUE,TRUE,TRUE,TRUE
@@ -2,10 +2,7 @@ name,username,designation,email,phone,super_admin,status
2
2
  Krishna Prasad Varma,kpvarma,Site Admin,prasad@rightsolutions.io,,TRUE,approved
3
3
  Vinodh Ellath,vinodh,Site Admin,vinodh@rightsolutions.io,,TRUE,approved
4
4
  Junaid Ramzan,junaid.ramzan,Site Admin,junaid.ramzan@gmail.com,,TRUE,approved
5
- Oleksandra,oleksandra,Merchandise Manager,oleksandra@yopmail.com,,FALSE,approved
5
+ Sanoop S Nair,sanoop,Site Admin,sanoop@yopmail.com,,TRUE,approved
6
+ Abdul Anas,sanoop,Site Admin,abdul.anas@yopmail.com,,TRUE,approved
6
7
  Staff User 1,staff_user.1,IT Support,staff_user_1@yopmail.com,,FALSE,pending
7
- Staff User 2,staff_user.2,Sales Girl,staff_user_2@yopmail.com,,FALSE,suspended
8
- Stephen Price,stephen.price,General Manager,stephen.price@yopmail.com,,FALSE,approved
9
- Angelo Joseph,angelo.joseph,General Manager,angelo.joseph@yopmail.com,,FALSE,approved
10
- Gunashekharan,guna.neweast,IT Admin,guna.neweast@yopmail.com,,FALSE,approved
11
- Silk Smitha,silk.smitha,QA Analyst,silk.smitha@yopmail.com,,FALSE,approved
8
+ Staff User 2,staff_user.2,Sales Girl,staff_user_2@yopmail.com,,FALSE,suspended
data/db/data/users.csv CHANGED
@@ -1,4 +1,6 @@
1
1
  name,username,designation,email,phone,super_admin,status
2
2
  Krishna Prasad Varma,kpvarma,Site Admin,prasad@rightsolutions.io,,TRUE,approved
3
3
  Vinodh Ellath,vinodh,Site Admin,vinodh@rightsolutions.io,,TRUE,approved
4
- Junaid Ramzan,junaid.ramzan,Site Admin,junaid.ramzan@gmail.com,,TRUE,approved
4
+ Junaid Ramzan,junaid.ramzan,Site Admin,junaid.ramzan@gmail.com,,TRUE,approved
5
+ Sanoop S Nair,sanoop,Site Admin,sanoop@yopmail.com,,TRUE,approved
6
+ Abdul Anas,sanoop,Site Admin,abdul.anas@yopmail.com,,TRUE,approved
@@ -0,0 +1,9 @@
1
+ name,status
2
+ User,published
3
+ Registration,unpublished
4
+ Role,published
5
+ Permission,published
6
+ Country,published
7
+ Region,published
8
+ City,published
9
+ Locality,published
@@ -1,2 +1,3 @@
1
1
  name
2
2
  Site Admin
3
+ Content Manager
@@ -9,7 +9,7 @@ namespace 'usman' do
9
9
  desc "Import all data in sequence"
10
10
  task 'all' => :environment do
11
11
 
12
- import_list = ["users", "features", "permissions", "roles"]
12
+ import_list = ["users", "permissions"]
13
13
 
14
14
  import_list.each do |item|
15
15
  print "Importing #{item.titleize} \t".yellow
@@ -25,19 +25,22 @@ namespace 'usman' do
25
25
  puts " "
26
26
  end
27
27
 
28
- ["Feature", "User", "Role", "Permission"].each do |cls_name|
28
+ ["User", "Permission"].each do |cls_name|
29
29
  name = cls_name.underscore.pluralize
30
30
  desc "Import #{cls_name.pluralize}"
31
31
  task name => :environment do
32
32
  verbose = true
33
33
  verbose = false if ["false", "f","0","no","n"].include?(ENV["verbose"].to_s.downcase.strip)
34
+
35
+ destroy_all = false
36
+ destroy_all = true if ["true", "t","1","yes","y"].include?(ENV["destroy_all"].to_s.downcase.strip)
34
37
 
35
38
  path = Rails.root.join('db', 'data', "#{cls_name.constantize.table_name}.csv")
36
- path = Usman::Engine.root.join('db', 'data', 'dummy', "#{cls_name.constantize.table_name}.csv") unless File.exists?(path)
39
+ path = Usman::Engine.root.join('db', 'data', "#{cls_name.constantize.table_name}.csv") unless File.exists?(path)
37
40
 
38
- cls_name.constantize.destroy_all
41
+ cls_name.constantize.destroy_all if destroy_all
39
42
  cls_name.constantize.import_data_file(path, true, verbose)
40
- # puts "Importing Completed".green if verbose
43
+ puts "Importing Completed".green if verbose
41
44
  end
42
45
  end
43
46
 
@@ -46,7 +49,7 @@ namespace 'usman' do
46
49
  desc "Import all dummy data in sequence"
47
50
  task 'all' => :environment do
48
51
 
49
- import_list = ["users", "features", "permissions", "roles"]
52
+ import_list = ["users", "permissions"]
50
53
 
51
54
  import_list.each do |item|
52
55
  print "Loading #{item.split(':').last.titleize} \t".yellow
@@ -62,19 +65,22 @@ namespace 'usman' do
62
65
  puts " "
63
66
  end
64
67
 
65
- ["Feature", "User", "Role", "Permission"].each do |cls_name|
68
+ ["User", "Permission"].each do |cls_name|
66
69
  name = cls_name.underscore.pluralize
67
70
  desc "Load Dummy #{cls_name.pluralize}"
68
71
  task name => :environment do
69
72
  verbose = true
70
73
  verbose = false if ["false", "f","0","no","n"].include?(ENV["verbose"].to_s.downcase.strip)
74
+
75
+ destroy_all = false
76
+ destroy_all = true if ["true", "t","1","yes","y"].include?(ENV["destroy_all"].to_s.downcase.strip)
71
77
 
72
78
  path = Rails.root.join('db', 'data', 'dummy', "#{cls_name.constantize.table_name}.csv")
73
79
  path = Usman::Engine.root.join('db', 'data', 'dummy', "#{cls_name.constantize.table_name}.csv") unless File.exists?(path)
74
80
 
75
- cls_name.constantize.destroy_all
81
+ cls_name.constantize.destroy_all if destroy_all
76
82
  cls_name.constantize.import_data_file(path, true, verbose)
77
- # puts "Importing Completed".green if verbose
83
+ puts "Importing Completed".green if verbose
78
84
  end
79
85
  end
80
86
  end
@@ -9,7 +9,7 @@ namespace 'usman' do
9
9
  desc "Import all data in sequence"
10
10
  task 'all' => :environment do
11
11
 
12
- import_list = ["roles"]
12
+ import_list = ["roles", "features"]
13
13
 
14
14
  import_list.each do |item|
15
15
  print "Importing #{item.titleize} \t".yellow
@@ -25,14 +25,18 @@ namespace 'usman' do
25
25
  puts " "
26
26
  end
27
27
 
28
- ["Role"].each do |cls_name|
28
+ ["Role", "Feature"].each do |cls_name|
29
29
  name = cls_name.underscore.pluralize
30
30
  desc "Import #{cls_name.pluralize}"
31
31
  task name => :environment do
32
32
  verbose = true
33
33
  verbose = false if ["false", "f","0","no","n"].include?(ENV["verbose"].to_s.downcase.strip)
34
+
35
+ destroy_all = false
36
+ destroy_all = true if ["true", "t","1","yes","y"].include?(ENV["destroy_all"].to_s.downcase.strip)
37
+
34
38
  path = Usman::Engine.root.join('db', 'master_data', "#{cls_name.constantize.table_name}.csv")
35
- cls_name.constantize.destroy_all
39
+ cls_name.constantize.destroy_all if destroy_all
36
40
  cls_name.constantize.import_data_file(path, true, verbose)
37
41
  # puts "Importing Completed".green if verbose
38
42
  end
@@ -0,0 +1,24 @@
1
+ module Usman
2
+ module ActionView
3
+ # This module creates Bootstrap wrappers around basic View Tags
4
+ module PermissionsHelper
5
+
6
+ # -------------------
7
+ # Display Helpers
8
+ # -------------------
9
+
10
+ def display_edit_links?
11
+ @current_user.super_admin? || @current_permission.can_update?
12
+ end
13
+
14
+ def display_delete_links?
15
+ @current_user.super_admin? || @current_permission.can_delete?
16
+ end
17
+
18
+ def display_manage_links?
19
+ display_edit_links? || display_delete_links?
20
+ end
21
+
22
+ end
23
+ end
24
+ end
data/lib/usman/engine.rb CHANGED
@@ -20,6 +20,12 @@ module Usman
20
20
  end
21
21
  end
22
22
 
23
+ initializer "usman.action_view" do |app|
24
+ ActiveSupport.on_load :action_view do
25
+ include Usman::ActionView::PermissionsHelper
26
+ end
27
+ end
28
+
23
29
  config.generators do |g|
24
30
  g.test_framework :rspec, :fixture => false
25
31
  g.fixture_replacement :factory_girl, :dir => 'spec/dummy/spec/factories'
data/lib/usman/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Usman
2
- VERSION = '0.3.9'
2
+ VERSION = '0.3.10'
3
3
  end
data/lib/usman.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require "usman/engine"
2
+ require 'usman/action_view/permissions_helper'
2
3
 
3
4
  module Usman
4
5
  # Your code goes here...