Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
O
OHR Support
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
97
Issues
97
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
OHR Support
Commits
52a58802
Commit
52a58802
authored
Nov 18, 2011
by
Enrique García
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
finished licenses importer task
parent
25a87138
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
7 deletions
+17
-7
licenses.rake
lib/tasks/licenses.rake
+17
-7
No files found.
lib/tasks/licenses.rake
View file @
52a58802
...
@@ -10,10 +10,10 @@ end
...
@@ -10,10 +10,10 @@ end
namespace
:licenses
do
namespace
:licenses
do
desc
"creates default licenses, imports them, and removes the license custom field from ohwr"
desc
"creates default licenses, imports them, and removes the license custom field from ohwr"
task
:all
=>
[
:
destroy_all
,
:create
]
task
:all
=>
[
:
reset
,
:create
,
:link
,
:remove_custom_field
]
desc
"destroys all licenses"
desc
"destroys all licenses"
task
:
destroy_all
=>
:environment
do
task
:
reset
=>
:environment
do
License
.
destroy_all
License
.
destroy_all
LicenseVersion
.
destroy_all
LicenseVersion
.
destroy_all
...
@@ -31,14 +31,24 @@ namespace :licenses do
...
@@ -31,14 +31,24 @@ namespace :licenses do
create_license
(
"CERN OHL"
,
"cern-ohl"
,
nil
,
"v1.1"
,
Date
.
new
(
2011
,
7
,
8
),
nil
)
create_license
(
"CERN OHL"
,
"cern-ohl"
,
nil
,
"v1.1"
,
Date
.
new
(
2011
,
7
,
8
),
nil
)
end
end
desc
"associates projects to the licenses they belong to"
do
desc
"associates projects to the licenses they belong to"
task
:link
=>
:environment
do
license_custom_field_id
=
CustomField
.
find_by_type_and_name
(
"ProjectCustomField"
,
"License"
).
id
[
"GPL"
,
"LGPL"
,
"TAPR OHL"
,
"CERN OHL"
].
each
do
|
license_name
|
[
"GPL"
,
"LGPL"
,
"TAPR OHL"
,
"CERN OHL"
].
each
do
|
license_name
|
license
=
License
.
find_by_name
(
license_name
)
license
=
License
.
find_by_name
(
license_name
)
license_version
=
license
.
license_versions
.
first
license_version
=
license
.
versions
.
first
Project
.
with_custom_fields
(
:License
=>
license_name
).
each
do
|
p
|
Project
.
with_custom_values
(
license_custom_field_id
=>
license_name
).
each
do
|
p
|
p
.
license
=
license
.
version
writable_p
=
Project
.
find
(
p
.
id
)
p
.
save
writable_p
.
license
=
license_version
writable_p
.
save
end
end
end
end
end
end
desc
"removes the previous custom field"
task
:remove_custom_field
do
CustomField
.
destroy_all
(
:type
=>
"ProjectCustomField"
,
:name
=>
"License"
)
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