command_proposal 1.0.3 → 1.0.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0fe3241c83226bc2aebbc46b3b8deaec5886dcd6ed8dea95d53e4d84510fb9c5
4
- data.tar.gz: '09e82ce7d547624f6da07c2536c0c235e4205ff70e76bc8c4e20c07dcbb818da'
3
+ metadata.gz: 4d0b2ef7f0cf5f9044adaab75cb1b28b762086ff77ce659d461b976dd0533e3d
4
+ data.tar.gz: c4c50205f7e2260a9d7659e7c6938808366c07aa00f0e85511fd1269de768e95
5
5
  SHA512:
6
- metadata.gz: 57055fced9213819d5d0b9dfbcd3d1d28430a3f34bae8ff6b16b7b48034d68ae71e50411d5d4db90c83502fa7a1bd7ceb02e6861da8f16a558f952d16dbba7d8
7
- data.tar.gz: 2288b1576b1019d3d1c937d9fa6e346e2facc4b7e58756bed2b6517fb453733c2ec256eda3dec0973c9ffff6ac5331e7b3ff7ee8d8415c241b02543737fe1209
6
+ metadata.gz: 9ee3a6d919ea22545e62488fc0291d476b168b26412433288b6acde185d96bba8e4f9df313d13596faf508f7faabcea1d5d8539e7794a47d897eb117d4fe70e1
7
+ data.tar.gz: faca82d2f612e2a0ec8b78ac09655d794b9e04b108b93b075b2097aff0dd0959dc75c21410fa7a6be4d71fac93f52428d0e497298a66c71b4b7caa6d6930329a
@@ -1,12 +1,14 @@
1
1
  module CommandProposal
2
2
  module PermissionsHelper
3
3
  def can_command?(user=command_user)
4
+ return false unless permitted_to_use?
4
5
  return true unless cmd_config.approval_required?
5
6
 
6
7
  command_user.try("#{cmd_config.role_scope}?")
7
8
  end
8
9
 
9
10
  def can_approve?(iteration)
11
+ return false unless permitted_to_use?
10
12
  return true unless cmd_config.approval_required?
11
13
  return if iteration.nil?
12
14
 
@@ -14,15 +16,24 @@ module CommandProposal
14
16
  end
15
17
 
16
18
  def has_approval?(task)
19
+ return false unless permitted_to_use?
17
20
  return true unless cmd_config.approval_required?
18
21
 
19
22
  task&.approved?
20
23
  end
21
24
 
22
25
  def current_is_author?(iteration)
26
+ return false unless permitted_to_use?
27
+
23
28
  command_user&.id == iteration&.requester&.id
24
29
  end
25
30
 
31
+ def permitted_to_use?
32
+ return true if cmd_config.controller_var.blank?
33
+
34
+ command_user&.send("#{cmd_config.role_scope}?")
35
+ end
36
+
26
37
  def command_user(user=nil)
27
38
  @command_user ||= begin
28
39
  if user.present?
@@ -8,8 +8,8 @@
8
8
  </thead>
9
9
  <tbody>
10
10
  <tr>
11
- <td><%= @iteration&.requester_name %></td>
12
- <td><%= @iteration&.approver_name %></td>
11
+ <td><%= @iteration&.requester_name.presence || "ID: #{@iteration&.requester_id}" if @iteration&.requester_id.present? %></td>
12
+ <td><%= @iteration&.approver_name.presence || "ID: #{@iteration&.approver_id}" if @iteration&.approver_id.present? %></td>
13
13
  <td><%= @iteration&.started_at&.strftime("%b %-d '%y, %-l:%M%P") %></td>
14
14
  <td data-iteration-status><%= @iteration&.status&.capitalize %></td>
15
15
  <td data-iteration-duration><%= humanized_duration(@iteration&.duration) %></td>
@@ -18,7 +18,7 @@ module CommandProposal
18
18
  # Default
19
19
  @approval_required = true
20
20
 
21
- # Required (if approval needed)
21
+ # User details - highly recommended
22
22
  @user_class_name = nil
23
23
  @role_scope = nil
24
24
  @user_name = nil
@@ -4,5 +4,5 @@
4
4
  # gem push command_proposal-__.gem
5
5
 
6
6
  module CommandProposal
7
- VERSION = '1.0.3'
7
+ VERSION = '1.0.4'
8
8
  end
@@ -1,4 +1,9 @@
1
1
  ::CommandProposal.configure do |config|
2
+ # Determines if a user needs a different user to approve their commands.
3
+ # Defaults to true, the recommended value.
4
+ # However, disabling in development could help with testing.
5
+ # config.approval_required = !Rails.env.development?
6
+
2
7
  # Change if your base user class has a different model name
3
8
  config.user_class_name = "User"
4
9
 
@@ -8,6 +13,8 @@
8
13
  # Scope for your user class that determines users who are permitted to interact with commands
9
14
  # It is highly recommended to make this very exclusive, as any users in this scope will be able
10
15
  # to interact with your database directly.
16
+ # Expected that the class will respond to `#{role_scope}` and
17
+ # instances of the class respond to `#{role_scope}?`
11
18
  config.role_scope = :admin
12
19
 
13
20
  # Method called to display a user's name
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: command_proposal
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rocco Nicholls