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 +4 -4
- data/app/helpers/command_proposal/permissions_helper.rb +11 -0
- data/app/views/command_proposal/tasks/_task_detail_table.html.erb +2 -2
- data/lib/command_proposal/configuration.rb +1 -1
- data/lib/command_proposal/version.rb +1 -1
- data/lib/generators/command_proposal/install/templates/initializer.rb +7 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4d0b2ef7f0cf5f9044adaab75cb1b28b762086ff77ce659d461b976dd0533e3d
|
4
|
+
data.tar.gz: c4c50205f7e2260a9d7659e7c6938808366c07aa00f0e85511fd1269de768e95
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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>
|
@@ -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
|