Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
dcce63fc
Commit
dcce63fc
authored
Dec 05, 2019
by
mo khan
Committed by
Ash McKenzie
Dec 12, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Extract hash to map to legacy values
parent
0146f8ef
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
9 additions
and
22 deletions
+9
-22
ee/app/models/software_license_policy.rb
ee/app/models/software_license_policy.rb
+3
-0
ee/app/services/software_license_policies/create_service.rb
ee/app/services/software_license_policies/create_service.rb
+3
-10
ee/app/services/software_license_policies/update_service.rb
ee/app/services/software_license_policies/update_service.rb
+3
-12
No files found.
ee/app/models/software_license_policy.rb
View file @
dcce63fc
...
...
@@ -5,6 +5,9 @@
# For use in the License Management feature.
class
SoftwareLicensePolicy
<
ApplicationRecord
include
Presentable
APPROVAL_STATUS
=
{
'blacklisted'
=>
'denied'
}.
freeze
# Only allows modification of the approval status
FORM_EDITABLE
=
%i[approval_status]
.
freeze
...
...
ee/app/services/software_license_policies/create_service.rb
View file @
dcce63fc
...
...
@@ -21,22 +21,15 @@ module SoftwareLicensePolicies
private
def
create_software_license_policy
approval_status
=
params
[
:approval_status
]
classification
=
SoftwareLicensePolicy
::
APPROVAL_STATUS
.
fetch
(
approval_status
,
approval_status
)
policy
=
SoftwareLicense
.
create_policy_for!
(
project:
project
,
name:
params
[
:name
],
classification:
map_from
(
params
[
:approval_status
])
classification:
classification
)
RefreshLicenseComplianceChecksWorker
.
perform_async
(
project
.
id
)
policy
end
def
map_from
(
approval_status
)
case
approval_status
when
'blacklisted'
'denied'
else
approval_status
end
end
end
end
ee/app/services/software_license_policies/update_service.rb
View file @
dcce63fc
...
...
@@ -12,7 +12,9 @@ module SoftwareLicensePolicies
return
success
(
software_license_policy:
software_license_policy
)
unless
params
[
:approval_status
].
present?
begin
software_license_policy
.
update
(
classification:
map_from
(
params
[
:approval_status
]))
approval_status
=
params
[
:approval_status
]
classification
=
SoftwareLicensePolicy
::
APPROVAL_STATUS
.
fetch
(
approval_status
,
approval_status
)
software_license_policy
.
update
(
classification:
classification
)
RefreshLicenseComplianceChecksWorker
.
perform_async
(
project
.
id
)
rescue
ArgumentError
=>
ex
return
error
(
ex
.
message
,
400
)
...
...
@@ -20,16 +22,5 @@ module SoftwareLicensePolicies
success
(
software_license_policy:
software_license_policy
)
end
private
def
map_from
(
approval_status
)
case
approval_status
when
'blacklisted'
'denied'
else
approval_status
end
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment