Skip to content

Commit

Permalink
Merge pull request #606 from DMPRoadmap/development
Browse files Browse the repository at this point in the history
Fix for missing question format settings
  • Loading branch information
briri authored Aug 24, 2017
2 parents d9bde11 + fced606 commit d9085e7
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 9 deletions.
20 changes: 11 additions & 9 deletions db/seeds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,21 @@
{name: 'orcid', description: 'ORCID', active: true,
logo_url:'http://orcid.org/sites/default/files/images/orcid_16x16.png',
user_landing_url:'https://orcid.org' },
{name: 'shibboleth', description: 'your institutional credentials', active: true,
{name: 'shibboleth', description: 'Your institutional credentials', active: true,
},
]
identifier_schemes.map{ |is| IdentifierScheme.create!(is) if IdentifierScheme.find_by(name: is[:name]).nil? }

# Question Formats
# -------------------------------------------------------
question_formats = [
{title: "Text area", option_based: false},
{title: "Text field", option_based: false},
{title: "Radio buttons", option_based: true},
{title: "Check box", option_based: true},
{title: "Dropdown", option_based: true},
{title: "Multi select box", option_based: true},
{title: "Date", option_based: false}
{title: "Text area", option_based: false, formattype: 0},
{title: "Text field", option_based: false, formattype: 1},
{title: "Radio buttons", option_based: true, formattype: 2},
{title: "Check box", option_based: true, formattype: 3},
{title: "Dropdown", option_based: true, formattype: 4},
{title: "Multi select box", option_based: true, formattype: 5},
{title: "Date", option_based: true, formattype: 6}
]
question_formats.map{ |qf| QuestionFormat.create!(qf) if QuestionFormat.find_by(title: qf[:title]).nil? }

Expand Down Expand Up @@ -154,7 +154,9 @@
# -------------------------------------------------------
token_permission_types = [
{token_type: 'guidances', text_description: 'allows a user access to the guidances api endpoint'},
{token_type: 'plans', text_description: 'allows a user access to the plans api endpoint'}
{token_type: 'plans', text_description: 'allows a user access to the plans api endpoint'},
{token_type: 'templates', text_description: 'allows a user access to the templates api endpoint'},
{token_type: 'statistics', text_description: 'allows a user access to the statistics api endpoint'}
]
token_permission_types.map{ |tpt| TokenPermissionType.create!(tpt) if TokenPermissionType.find_by(token_type: tpt[:token_type]).nil? }

Expand Down
49 changes: 49 additions & 0 deletions lib/tasks/bugfix.rake
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
namespace :bugfix do

desc "Bug fixes for version v0.3.3"
task v0_3_3: :environment do
Rake::Task['bugfix:fix_question_formats'].execute
Rake::Task['bugfix:add_missing_token_permission_types'].execute
end

desc "Add the missing formattype to the question_formats table"
task fix_question_formats: :environment do
QuestionFormat.all.each do |qf|
case qf.title.downcase
when 'text area'
qf.formattype = :textarea
when 'text field'
qf.formattype = :textfield
when 'radio buttons'
qf.formattype = :radiobuttons
when 'check box'
qf.formattype = :checkbox
when 'dropdown'
qf.formattype = :dropdown
when 'multi select box'
qf.formattype = :multiselectbox
when 'date'
qf.formattype = :date
end

qf.save!
end

if QuestionFormat.find_by(formattype: :date).nil?
QuestionFormat.create!({title: "Date", option_based: true, formattype: 6})
end
end

desc "Add the missing token_permission_types"
task add_missing_token_permission_types: :environment do
if TokenPermissionType.find_by(token_type: 'templates').nil?
TokenPermissionType.create!({token_type: 'templates',
text_description: 'allows a user access to the templates api endpoint'})
end
if TokenPermissionType.find_by(token_type: 'statistics').nil?
TokenPermissionType.create!({token_type: 'statistics',
text_description: 'allows a user access to the statistics api endpoint'})
end
end

end

0 comments on commit d9085e7

Please sign in to comment.