diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..b0e3e12 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,11 @@ +language: ruby +rvm: + - 2.0.0-p247 + +services: + - mysql + +before_script: + - cp config/database_example.yml config/database.yml + - cp config/secrets_example.yml config/secrets.yml + - mysql -e 'create database IF NOT EXISTS roadmap_test;' -uroot diff --git a/Gemfile b/Gemfile index 23909f1..65dc3d3 100644 --- a/Gemfile +++ b/Gemfile @@ -5,7 +5,6 @@ gem 'rails', '4.0.0' # additional gems for rails 4 -gem 'turbolinks' gem 'railties', '= 4.0.0' # add these gems to help with the transition: gem 'protected_attributes' @@ -27,7 +26,7 @@ # Use SCSS for stylesheets gem 'less-rails' gem 'twitter-bootstrap-rails', '2.2.8' -gem 'therubyracer', '0.11.4', platforms: :ruby +gem 'therubyracer', '>=0.11.4', platforms: :ruby #'0.11.4', platforms: :ruby gem 'libv8' @@ -108,6 +107,3 @@ # API # gem 'swagger-docs' - -# TODO where to put it? -gem "i18n-js", ">= 3.0.0.rc11" diff --git a/README.md b/README.md index eae0ba3..67fcb25 100644 --- a/README.md +++ b/README.md @@ -1,17 +1,103 @@ ## DMP Roadmap +DMP Roadmap is a Data Management Planning tool. It allows users to create data management plans for the projects using funder specific templates and institutional guidance. Once a plan has been completed it can be downloaded and inserted into your grant proposals. + +Management and development of the DMP Roadmap is jointly provided by the Digital Curation Centre (DCC), http://www.dcc.ac.uk/, and the University of California Curation Center (UC3), http://www.cdlib.org/services/uc3/ + +The tool has four main functions +1. To help create and maintain different versions of Data Management Plans; +2. To provide useful guidance on data management issues and how to meet research funders' requirements; +3. To export attractive and useful plans in a variety of formats; +4. To allow collaborative work when creating Data Management Plans. + #### Current Release v.0.1.0 +[![Build Status](https://travis-ci.org/DMPRoadmap/roadmap.svg)](https://travis-ci.org/DMPRoadmap/roadmap) #### Summary +#### Pre-requisites +Roadmap is a Ruby on Rails application and you will need to have: +1. Ruby >= 2.0.0p247 +2. Rails >= 4.0 +3. MySql >= 5.0 + +Further details on how to install Ruby on Rails applications are available from the Ruby on Rails site: http://rubyonrails.org + +Further details on how to install MySQL and create your first user and database. Be sure to follow the instructions for your particular environment. +* Install: http://dev.mysql.com/downloads/mysql/ +* +* Create a user: http://dev.mysql.com/doc/refman/5.7/en/create-user.html +* Create the database: http://dev.mysql.com/doc/refman/5.7/en/creating-database.html + +You may also find the following resources handy: + +* The Getting Started Guide: http://guides.rubyonrails.org/getting_started.html +* Ruby on Rails Tutorial Book: http://www.railstutorial.org/ + #### Installation -Clone the repository and build from the latest tag +* Create your mysql db. Select UTF-8 Unicode (utf8mb4) encoding. +* Fork the repository and then clone it onto your server + +> > git clone https://github.com/[your organization]/roadmap.git + +> > cd roadmap + +* Make copies of the yaml configuration files and update the values for your installation + +> > cp config/database_example.yml config/database.yml +> > cp config/secrets_example.yml config/secrets.yml + +* Create an environment variable for your instance's secret (as defined in config/secrets.yml). You should use the following command to generate secrets for each of your environments, storing the production one in the environment variable: + +> > rake secret + +* Run bundler and perform the DB migrations + +> > gem install bundler (if bundler is not yet installed) + +> > bundle install + +> > rake db:migrate + +> > rake db:seed + +* Setup the devise authentication gem + +> > rails generate devise:install (Is this really necessary?) + +* Start the application + +> > rails server + +* Verify that the site is running properly by going to http://localhost:3000 +* Login as the default administrator: 'super_admin@example.com' - 'password1' #### Troubleshooting +##### Installation - OSX: + +``` +An error occurred while installing libv8 (3.11.8.17), and Bundler cannot continue. + +Make sure that `gem install libv8 -v '3.11.8.17'` succeeds before bundling. +``` + +If you are installing on a system that already has v8 installed then you may need to install the libv8 gem manually using your system's current v8 engine. If you're using homebrew to manage your packages you should run 'brew update' and 'brew upgrade' to make sure you have the latest packages + +> > gem uninstall -a libv8 + +> > gem install libv8 -v '<>' -- --with-system-v8 + +> > bundle install + +#### Support +Issues should be reported here on Github https://github.com/DMPRoadmap/roadmap/issues +Please be advised though that we can only provide limited support for your local installations. #### Become a contributor -Fork the repository. +Fork this repository and make your modifications in a new branch. Then create a pull request to our 'development' branch. We will reject any pull request made against the 'master' branch. Once your pull request has been submitted the team will review your request and accept it if appropriate. + +Join the email listserv at roadmap-l (at) listserv.ucop (dot) edu. #### License The DMP Roadmap project uses to the MIT License. diff --git a/README.rdoc b/README.rdoc index 3ca4a88..9a680a0 100644 --- a/README.rdoc +++ b/README.rdoc @@ -1,10 +1,8 @@ -= DMPonline v4 += DMPRoadmap -DMPonline is the DCC's data management planning tool, available at https://dmponline.dcc.ac.uk +Roadmap is a data management planning tool, available at https://github.com/DMPRoadmap/roadmap -Development of the DMPonline by the Digital Curation Centre has been funded by JISC. JISC inspires UK colleges and universities in the innovative use of digital technologies, helping to maintain the UK's position as a global leader in education. www.jisc.ac.uk - -This is just the application code, the accompanying question data available at https://dmponline.dcc.ac.uk is not included. +Development of the Roadmap is provided by the Digital Curation Centre and the University of California Curation Center. The tool has four main functions 1. To help create and maintain different versions of Data Management Plans; @@ -14,15 +12,16 @@ == Documentation & Support -* You can contact us by email, dmponline@dcc.ac.uk, but we can only provide limited support for your installation +* You can contact us by email, roadmap-l@listserv.ucop.edu, but we can only provide limited support for your installation == Bugs & Feature Requests -* Bug Reports & Feature Requests: https://github.com/DigitalCurationCentre/DMPonline_v4/issues +* Bug Reports & Feature Requests: https://github.com/DMPRoadmap/roadmap/issues +* Please prefix your request with either: 'Bug:' or 'Feature:' == Prerequisites -DMPonline is a Ruby on Rails application and you will need to have Ruby 2.0.0p247 or greater installed on your server and a MySQL server v5.0 or greater. +Roadmap is a Ruby on Rails application and you will need to have Ruby 2.0.0p247 or greater installed on your server and a MySQL server v5.0 or greater. Further details on how to install Ruby on Rails applications are available from the Ruby on Rails site, http://rubyonrails.org @@ -34,10 +33,4 @@ == Copyright -Copyright (c) 2013 Digital Curation Centre, University of Edinburgh. - -This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - -You should have received a copy of the GNU Affero General Public License along with this program. If not, see http://www.gnu.org/licenses. +The Roadmap project uses an MIT License. The full text of the license can be found at: https://github.com/DMPRoadmap/roadmap/blob/master/LICENSE.md diff --git a/Rakefile b/Rakefile old mode 100644 new mode 100755 index 04c8372..1813a30 --- a/Rakefile +++ b/Rakefile @@ -1,7 +1,7 @@ #!/usr/bin/env rake # Add your own tasks in files placed in lib/tasks ending in .rake, # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. - +require 'rake/testtask' require File.expand_path('../config/application', __FILE__) DMPonline4::Application.load_tasks @@ -14,4 +14,7 @@ rdoc.title = "DMPonline4 Documentation" rdoc.options << "--all" -end \ No newline at end of file +end + +task default: :test + diff --git a/app/assets/fonts/fontawesome-webfont.woff b/app/assets/fonts/fontawesome-webfont.woff new file mode 100644 index 0000000..6e7483c --- /dev/null +++ b/app/assets/fonts/fontawesome-webfont.woff Binary files differ diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 464ff02..9fe7424 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -12,6 +12,7 @@ // //= require jquery //= require jquery_ujs +//= require twitter/bootstrap //= require bootstrap //= require v1.js //= require select2.min.js @@ -120,7 +121,6 @@ $("#user_organisation_id").change(); }); - //alert dialog for unlink Shibbileth account $("#unlink-institutional-credentials-dialog").on("show", function(){ $('.select2-choice').hide(); diff --git a/app/assets/javascripts/projects.js b/app/assets/javascripts/projects.js index 9f13514..413d8e2 100644 --- a/app/assets/javascripts/projects.js +++ b/app/assets/javascripts/projects.js @@ -131,6 +131,8 @@ function update_guidance_options() { var institution = $("#project_institution_id").select2('val'); var template = $("#project_dmptemplate_id :selected").val(); + var options = null; + $.ajax({ type: 'GET', url: "possible_guidance.json?institution="+institution+"&template="+template, @@ -138,11 +140,15 @@ async: false, //Needs to be synchronous, otherwise end up mixing up answers success: function(data) { options = data; + }, + error: function(err){ + console.log(err); } }); options_container = $("#guidance-control-group"); options_container = options_container.find(".choices-group"); options_container.empty(); + var count = 0; for (var id in options) { options_container.append("
  • "); diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css index 55ee37e..db43a20 100644 --- a/app/assets/stylesheets/application.css +++ b/app/assets/stylesheets/application.css @@ -10,6 +10,7 @@ * * require jquery.ui.all *= require_self + *= require bootstrap_and_overrides *= require bootstrap.css *= require bootstrap_and_overrides.css.less *= require select2.css diff --git a/app/models/user.rb b/app/models/user.rb index 5621a2c..53f59a4 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -3,8 +3,8 @@ # Include default devise modules. Others available are: # :token_authenticatable, :confirmable, # :lockable, :timeoutable and :omniauthable - devise :invitable, :database_authenticatable, :registerable, - :recoverable, :rememberable, :trackable, :validatable, :confirmable, :omniauthable, :omniauth_providers => [:shibboleth] + devise :invitable, :database_authenticatable, :registerable, :recoverable, :rememberable, + :trackable, :validatable, :confirmable, :omniauthable, :omniauth_providers => [:shibboleth] #associations between tables belongs_to :user_type @@ -40,8 +40,11 @@ has_many :plan_sections accepts_nested_attributes_for :roles - attr_accessible :role_ids - attr_accessible :password_confirmation, :encrypted_password, :remember_me, :id, :email, :firstname, :last_login,:login_count, :orcid_id, :password, :shibboleth_id, :user_status_id, :surname, :user_type_id, :organisation_id, :skip_invitation, :other_organisation, :accept_terms, :role_ids, :dmponline3, :api_token + + attr_accessible :password_confirmation, :encrypted_password, :remember_me, :id, :email, + :firstname, :last_login,:login_count, :orcid_id, :password, :shibboleth_id, + :user_status_id, :surname, :user_type_id, :organisation_id, :skip_invitation, + :other_organisation, :accept_terms, :role_ids, :dmponline3 # FIXME: The duplication in the block is to set defaults. It might be better if # they could be set in Settings::PlanList itself, if possible. diff --git a/app/views/projects/index.html.erb b/app/views/projects/index.html.erb index 3ae02ac..b0e2ddd 100644 --- a/app/views/projects/index.html.erb +++ b/app/views/projects/index.html.erb @@ -32,7 +32,6 @@

    <%= raw t("helpers.project.project_text_when_no_project")%>

    - <% end %> diff --git a/app/views/static_pages/about_us.html.erb b/app/views/static_pages/about_us.html.erb index c8188d2..70f2584 100644 --- a/app/views/static_pages/about_us.html.erb +++ b/app/views/static_pages/about_us.html.erb @@ -3,7 +3,7 @@ var hash = window.location.hash; hash && $('ul.nav a[href="' + hash + '"]').tab('show'); - $('.nav-tabs a').click(function (e) { + $('#project-tabs .nav-tabs a').click(function (e) { $(this).tab('show'); var scrollmem = $('body').scrollTop(); window.location.hash = this.hash; diff --git a/app/views/static_pages/help.html.erb b/app/views/static_pages/help.html.erb index b3d76be..9e566c2 100644 --- a/app/views/static_pages/help.html.erb +++ b/app/views/static_pages/help.html.erb @@ -3,7 +3,7 @@ var hash = window.location.hash; hash && $('ul.nav a[href="' + hash + '"]').tab('show'); - $('.nav-tabs a').click(function (e) { + $('#project-tabs .nav-tabs a').click(function (e) { $(this).tab('show'); var scrollmem = $('body').scrollTop(); window.location.hash = this.hash; diff --git a/app/views/static_pages/roadmap.html.erb b/app/views/static_pages/roadmap.html.erb index 94b587d..dbb47db 100644 --- a/app/views/static_pages/roadmap.html.erb +++ b/app/views/static_pages/roadmap.html.erb @@ -3,7 +3,7 @@ var hash = window.location.hash; hash && $('ul.nav a[href="' + hash + '"]').tab('show'); - $('.nav-tabs a').click(function (e) { + $('#project-tabs .nav-tabs a').click(function (e) { $(this).tab('show'); var scrollmem = $('body').scrollTop(); window.location.hash = this.hash; diff --git a/config/application.rb b/config/application.rb index 07dddc9..4c07de0 100644 --- a/config/application.rb +++ b/config/application.rb @@ -82,14 +82,10 @@ #config.shibboleth_login = 'https://localhost/Shibboleth.sso/Login' WickedPdf.config = { - :exe_path => '/usr/local/bin/wkhtmltopdf' - } - - # read secret_key_base from secrets.yml - # TODO Remove this in Rails 4.1 + :exe_path => '/usr/local/bin/wkhtmltopdf' + } + + # TODO: Remove this when we migrate to Rails 4.1+ config.secret_key_base = YAML.load(File.open("#{Rails.root}/config/secrets.yml"))[Rails.env]['secret_key_base'] - - - end end diff --git a/config/database_example.yml b/config/database_example.yml index 1d5100e..5fb17ef 100644 --- a/config/database_example.yml +++ b/config/database_example.yml @@ -1,8 +1,8 @@ development: adapter: mysql2 - database: dmpdev3 - username: mysql - password: password + database: roadmap + username: root + password: encoding: utf8 # Warning: The database defined as "test" will be erased and @@ -10,14 +10,14 @@ # Do not set this db to the same as development or production. test: adapter: mysql2 - database: dmptest3 - username: mysql - password: password + database: roadmap_test + username: root + password: encoding: utf8 production: adapter: mysql2 - database: dmptool3 - username: mysql - password: password + database: roadmap + username: root + password: encoding: utf8 diff --git a/config/initializers/swagger.rb b/config/initializers/swagger.rb index 685cc01..a9dfeaf 100644 --- a/config/initializers/swagger.rb +++ b/config/initializers/swagger.rb @@ -6,7 +6,7 @@ end Swagger::Docs::Config.register_apis({ - '0.0': { + '0.0' => { controller_base_path: '', api_file_path: 'public/apidocs', base_path: 'http://localhost:3000', diff --git a/db/migrate/20130708092900_devise_create_admin_users.rb b/db/migrate/20130708092900_devise_create_admin_users.rb index ed09342..fec1f73 100644 --- a/db/migrate/20130708092900_devise_create_admin_users.rb +++ b/db/migrate/20130708092900_devise_create_admin_users.rb @@ -2,7 +2,8 @@ def migrate(direction) super # Create a default user - AdminUser.create!(:email => 'admin@example.com', :password => 'password', :password_confirmation => 'password') if direction == :up +# briley - 2016-06-06 -- removed obsolete AdminUser creation. Model no longer exists in code base! +# AdminUser.create!(:email => 'admin@example.com', :password => 'password', :password_confirmation => 'password') if direction == :up end def change diff --git a/db/schema.rb b/db/schema.rb index 45e8346..5345ca5 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,15 +11,15 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20160105114044) do +ActiveRecord::Schema.define(version: 20160615095101) do create_table "answers", force: true do |t| t.text "text" t.integer "plan_id" t.integer "user_id" t.integer "question_id" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.datetime "created_at" + t.datetime "updated_at" end create_table "answers_options", id: false, force: true do |t| @@ -33,8 +33,8 @@ t.integer "user_id" t.integer "question_id" t.text "text" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.datetime "created_at" + t.datetime "updated_at" t.boolean "archived" t.integer "plan_id" t.integer "archived_by" @@ -46,8 +46,8 @@ t.boolean "published" t.integer "user_id" t.integer "organisation_id" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.datetime "created_at" + t.datetime "updated_at" t.string "locale" t.boolean "is_default" end @@ -61,8 +61,8 @@ t.integer "plan_id" t.integer "user_id" t.string "format" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.datetime "created_at" + t.datetime "updated_at" end create_table "file_types", force: true do |t| @@ -70,8 +70,8 @@ t.string "icon_name" t.integer "icon_size" t.string "icon_location" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.datetime "created_at" + t.datetime "updated_at" end create_table "file_uploads", force: true do |t| @@ -82,8 +82,8 @@ t.boolean "published" t.string "location" t.integer "file_type_id" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.datetime "created_at" + t.datetime "updated_at" end create_table "friendly_id_slugs", force: true do |t| @@ -100,8 +100,8 @@ create_table "guidance_groups", force: true do |t| t.string "name" t.integer "organisation_id" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.datetime "created_at" + t.datetime "updated_at" t.boolean "optional_subset" t.boolean "published" end @@ -116,8 +116,8 @@ create_table "guidances", force: true do |t| t.text "text" t.integer "guidance_group_id" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.datetime "created_at" + t.datetime "updated_at" t.integer "question_id" t.boolean "published" end @@ -126,8 +126,8 @@ t.integer "organisation_id" t.integer "option_id" t.text "text" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.datetime "created_at" + t.datetime "updated_at" end create_table "options", force: true do |t| @@ -135,15 +135,22 @@ t.string "text" t.integer "number" t.boolean "is_default" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.datetime "created_at" + t.datetime "updated_at" + end + + create_table "org_token_permissions", force: true do |t| + t.integer "organisation_id" + t.integer "token_permission_type_id" + t.datetime "created_at" + t.datetime "updated_at" end create_table "organisation_types", force: true do |t| t.string "name" t.text "description" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.datetime "created_at" + t.datetime "updated_at" end create_table "organisations", force: true do |t| @@ -155,8 +162,8 @@ t.string "domain" t.string "wayfless_entity" t.integer "stylesheet_file_id" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.datetime "created_at" + t.datetime "updated_at" t.integer "parent_id" t.boolean "is_other" t.string "sort_name" @@ -169,8 +176,8 @@ t.text "description" t.integer "number" t.integer "dmptemplate_id" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.datetime "created_at" + t.datetime "updated_at" t.string "slug" end @@ -181,8 +188,8 @@ t.integer "user_id" t.integer "section_id" t.integer "plan_id" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.datetime "created_at" + t.datetime "updated_at" t.datetime "release_time" end @@ -190,8 +197,8 @@ t.boolean "locked" t.integer "project_id" t.integer "version_id" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.datetime "created_at" + t.datetime "updated_at" end create_table "project_groups", force: true do |t| @@ -199,8 +206,8 @@ t.boolean "project_editor" t.integer "user_id" t.integer "project_id" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.datetime "created_at" + t.datetime "updated_at" t.boolean "project_administrator" end @@ -214,8 +221,8 @@ create_table "projects", force: true do |t| t.string "title" t.integer "dmptemplate_id" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.datetime "created_at" + t.datetime "updated_at" t.string "slug" t.integer "organisation_id" t.string "grant_number" @@ -232,8 +239,8 @@ create_table "question_formats", force: true do |t| t.string "title" t.text "description" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.datetime "created_at" + t.datetime "updated_at" end create_table "questions", force: true do |t| @@ -245,8 +252,8 @@ t.integer "dependency_id" t.text "dependency_text" t.integer "section_id" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.datetime "created_at" + t.datetime "updated_at" t.integer "question_format_id" t.boolean "option_comment_display", default: true end @@ -260,8 +267,8 @@ create_table "roles", force: true do |t| t.string "name" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.datetime "created_at" + t.datetime "updated_at" t.boolean "role_in_plans" t.integer "resource_id" t.string "resource_type" @@ -276,8 +283,8 @@ t.integer "number" t.integer "version_id" t.integer "organisation_id" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.datetime "created_at" + t.datetime "updated_at" t.boolean "published" end @@ -286,32 +293,32 @@ t.text "value" t.integer "target_id", null: false t.string "target_type", null: false - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.datetime "created_at" + t.datetime "updated_at" end add_index "settings", ["target_type", "target_id", "var"], name: "index_settings_on_target_type_and_target_id_and_var", unique: true, using: :btree create_table "splash_logs", force: true do |t| t.string "destination" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.datetime "created_at" + t.datetime "updated_at" end create_table "suggested_answers", force: true do |t| t.integer "question_id" t.integer "organisation_id" t.text "text" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.datetime "created_at" + t.datetime "updated_at" t.boolean "is_example" end create_table "themes", force: true do |t| t.string "title" t.text "description" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.datetime "created_at" + t.datetime "updated_at" t.string "locale" end @@ -320,33 +327,48 @@ t.integer "guidance_id" end + create_table "token_permission_types", force: true do |t| + t.string "token_type" + t.text "text_desription" + t.datetime "created_at" + t.datetime "updated_at" + end + + create_table "token_permissions", force: true do |t| + t.string "api_token" + t.datetime "created_at" + t.datetime "updated_at" + t.integer "user_id" + t.integer "token_permission_type_id" + end + create_table "user_org_roles", force: true do |t| t.integer "user_id" t.integer "organisation_id" t.integer "user_role_type_id" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.datetime "created_at" + t.datetime "updated_at" end create_table "user_role_types", force: true do |t| t.string "name" t.text "description" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.datetime "created_at" + t.datetime "updated_at" end create_table "user_statuses", force: true do |t| t.string "name" t.text "description" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.datetime "created_at" + t.datetime "updated_at" end create_table "user_types", force: true do |t| t.string "name" t.text "description" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.datetime "created_at" + t.datetime "updated_at" end create_table "users", force: true do |t| @@ -357,8 +379,8 @@ t.string "shibboleth_id" t.integer "user_type_id" t.integer "user_status_id" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.datetime "created_at" + t.datetime "updated_at" t.string "encrypted_password", default: "" t.string "reset_password_token" t.datetime "reset_password_sent_at" @@ -379,6 +401,9 @@ t.boolean "dmponline3" t.boolean "accept_terms" t.integer "organisation_id" + t.string "api_token" + t.integer "invited_by_id" + t.string "invited_by_type" end add_index "users", ["confirmation_token"], name: "index_users_on_confirmation_token", unique: true, using: :btree @@ -399,8 +424,8 @@ t.boolean "published" t.integer "number" t.integer "phase_id" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.datetime "created_at" + t.datetime "updated_at" end add_index "versions", ["phase_id"], name: "index_versions_on_phase_id", using: :btree diff --git a/db/seeds.rb b/db/seeds.rb index 84049c1..68923b5 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -25,41 +25,62 @@ } organisation_types.each do |org_type, details| - organisation_type = OrganisationType.new - organisation_type.name = details[:name] - organisation_type.save! + if OrganisationType.where(name: details[:name]).empty? + organisation_type = OrganisationType.new + organisation_type.name = details[:name] + organisation_type.save! + end end organisations = { - 'DCC' => { - name: "Digital Curation Centre", - abbreviation: "DCC", - sort_name: "Digital Curation Centre", - organisation_type: "Organisation" + 'Your Organization' => { + name: "My Regional Curation Centre", + abbreviation: "RCC", + sort_name: "MyRegionalCurationCenter", + organisation_type: "Organisation", + description: "An example: Regional Curation Center concerned with research data management (typically the organization hosting this website)", + banner_text: "Example: Your Regional Curation Center", + domain: "example.regionalcurationcenter.org" }, - 'Funder example' => { - name: "Funder full name", - abbreviation: "Funder_example", - sort_name: "Funder sorting name", - organisation_type: "Funder" + 'Global Funding Organization' => { + name: "Global Research Center", + abbreviation: "EGRC", + sort_name: "GlobalResearchCenter", + organisation_type: "Funder", + description: "An example: Research funding agency", + banner_text: "Example: Global Research Center", + domain: "example.globalresearchcenter.org" }, - 'Institution example'=> { - name: "Institution full name", - abbreviation: "Institution_example", - domain: "Institution_url", - sort_name: "Institution sorting name", - organisation_type: "Institution" + 'Regional Funding Organization' => { + name: "Regional Science Federation", + abbreviation: "RegSciFed", + sort_name: "RegionalScienceFederation", + organisation_type: "Funder", + description: "An example: Regional funding agency for scientific research", + banner_text: "Example: Regional Science Federation", + domain: "example.regionalsciencefederation.org" + }, + 'Example Institution'=> { + name: "Capital City College", + abbreviation: "CapColl", + domain: "example.capitalcitycollege.edu", + sort_name: "CapitalCityCollege", + organisation_type: "Institution", + description: "An example: Academic institution", + banner_text: "Example: Capital City College ... go mascots!!" } } organisations.each do |org, details| - organisation = Organisation.new - organisation.name = details[:name] - organisation.abbreviation = details[:abbreviation] - organisation.domain = details[:domain] - organisation.sort_name = details[:sort_name] - organisation.organisation_type = OrganisationType.find_by_name(details[:organisation_type]) - organisation.save! + if Organisation.where(abbreviation: details[:abbreviation]).empty? + organisation = Organisation.new + organisation.name = details[:name] + organisation.abbreviation = details[:abbreviation] + organisation.domain = details[:domain] + organisation.sort_name = details[:sort_name] + organisation.organisation_type = OrganisationType.find_by_name(details[:organisation_type]) + organisation.save! + end end roles = { @@ -68,56 +89,103 @@ }, 'org_admin' => { name: "org_admin" + }, + 'user' => { + name: "user" } } roles.each do |role, details| - role = Role.new - role.name = details[:name] - role.save! + if Role.where(name: details[:name]).empty? + role = Role.new + role.name = details[:name] + role.save! + end end +user_role_types = { + 'admin' => { + name: 'admin' + }, + 'org_admin' => { + name: 'org_admin' + }, + 'user' => { + name: 'user' + } +} + +user_role_types.each do |urt, details| + if UserRoleType.where(name: details[:name]).empty? + UserRoleType.create(name: details[:name]) + end +end users = { 'Super admin' => { email: "super_admin@example.com", - password: "password1", - password_confirmation: "password1", - organisation: "DCC", + password: "password123", + firstname: "RCC Super", + surname: "Admin", + password_confirmation: "password123", + organisation: "RCC", roles: ['admin','org_admin'], accept_terms: true, confirmed_at: Time.zone.now }, - 'Org admin' => { - email: "org_admin@example.com", - password: "password2", - password_confirmation: "password2", - organisation: "Institution_example", + 'Funder admin' => { + email: "funder_admin@example.com", + password: "password123", + password_confirmation: "password123", + firstname: "Funder", + surname: "Admin", + organisation: "RegSciFed", roles: ['org_admin'], accept_terms: true, confirmed_at: Time.zone.now + }, + 'Organizational admin' => { + email: "org_admin@example.com", + password: "password123", + password_confirmation: "password123", + firstname: "Organization", + surname: "Admin", + organisation: "CapColl", + roles: ['org_admin'], + accept_terms: true, + confirmed_at: Time.zone.now + }, + 'Organizational user' => { + email: "org_user@example.com", + password: "password123", + password_confirmation: "password123", + firstname: "Jane", + surname: "Researcher", + organisation: "CapColl", + roles: ['user'], + accept_terms: true, + confirmed_at: Time.zone.now } } - - users.each do |user, details| - user = User.new - user.email = details[:email] - user.password = details[:password] - user.password_confirmation = details[:password_confirmation] - user.confirmed_at = details[:confirmed_at] + +users.each do |user, details| + if User.where(email: details[:email]).empty? + usr = User.new + usr.email = details[:email] + usr.password = details[:password] + usr.password_confirmation = details[:password_confirmation] + usr.confirmed_at = details[:confirmed_at] + usr.organisation_id = Organisation.find_by_abbreviation(details[:organisation]).id +# usr.user_org_roles << UserOrgRole.create(organisation: Organisation.find_by_abbreviation(details[:organisation]), +# user_role_type: UserRoleType.find_by_name('admin')) details[:roles].each do |role| - user.roles << Role.find_by( name: role ) + usr.roles << Role.find_by_name(role) end - user_roles = UserOrgRole.new - user_roles.organisation = Organisation.find_by( abbreviation: details[:organisation]) - user_roles.user = user - user_roles.save! - user.user_org_roles << user_roles - user.accept_terms = details[:accept_terms] - user.save! - - end - + usr.accept_terms = details[:accept_terms] + + usr.save! + end +end themes = { "Theme 1" => { @@ -141,11 +209,13 @@ } themes.each do |t, details| - theme = Theme.new - theme.title = details[:title] - theme.locale = details[:locale] - theme.description = details[:description] - theme.save! + if Theme.where(title: details[:title]).empty? + theme = Theme.new + theme.title = details[:title] + theme.locale = details[:locale] + theme.description = details[:description] + theme.save! + end end question_formats = { @@ -170,135 +240,205 @@ } question_formats.each do |qf, details| - question_format = QuestionFormat.new - question_format.title = details[:title] - question_format.save! + if QuestionFormat.where(title: details[:title]).empty? + question_format = QuestionFormat.new + question_format.title = details[:title] + question_format.save! + end end guidance_groups = { - "Default Guidance group" => { - name: "Default Guidance group name", - organisation: "Institution_example", + "RCC Guidance" => { + name: "My organization guidance (optional generic guidance you provide for users)", + organisation: "RCC", + optional_subset: true + }, + "Global Research Center Guidance" => { + name: "Global Research Center (Funder specific guidance)", + organisation: "EGRC", optional_subset: false }, - "Optional Guidance group" => { - name: "Optional Guidance group name", - organisation: "Funder_example", + "Regional Science Federation Guidance" => { + name: "Regional Science Federation (Funder specific guidance)", + organisation: "RegSciFed", + optional_subset: false + }, + "Institutional Guidance" => { + name: "CapColl - School of Math and Science (optional institutional guidance)", + organisation: "CapColl", optional_subset: true } } guidance_groups.each do |gg, details| - guidance_group = GuidanceGroup.new - guidance_group.name = details[:name] - guidance_group.organisation = Organisation.find_by_abbreviation(details[:organisation]) - guidance_group.optional_subset = details[:optional_subset] - guidance_group.save! + if GuidanceGroup.where(name: details[:name]).empty? + guidance_group = GuidanceGroup.new + guidance_group.name = details[:name] + guidance_group.organisation = Organisation.find_by_abbreviation(details[:organisation]) + guidance_group.optional_subset = details[:optional_subset] + guidance_group.save! + end end guidances = { "Guidance 1" => { text: "Guidance text", - guidance_group: "Default Guidance group name", + guidance_group: "My organization guidance (optional generic guidance you provide for users)", themes: ["Theme 4"] }, "Guidance 2" => { text: "Guidance text", - guidance_group: "Optional Guidance group name", + guidance_group: "Global Research Center (Funder specific guidance)", themes: ["Theme 2"] }, "Guidance 3" => { text: "Guidance text", - guidance_group: "Default Guidance group name", + guidance_group: "Global Research Center (Funder specific guidance)", themes: ["Theme 3"] }, "Guidance 4" => { text: "Guidance text", - guidance_group: "Optional Guidance group name", + guidance_group: "Regional Science Federation (Funder specific guidance)", + themes: ["Theme 1"] + }, + "Guidance 4" => { + text: "Guidance text", + guidance_group: "CapColl - School of Math and Science (optional institutional guidance)", themes: ["Theme 1"] } } guidances.each do |g, details| - guidance = Guidance.new - guidance.text = details[:text] - guidance.guidance_groups << GuidanceGroup.find_by_name(details[:guidance_group]) - details[:themes].each do |theme| - guidance.themes << Theme.find_by_title(theme) + if Guidance.where(text: details[:text]).empty? + guidance = Guidance.new + guidance.text = details[:text] + guidance.guidance_groups << GuidanceGroup.find_by_name(details[:guidance_group]) + details[:themes].each do |theme| + guidance.themes << Theme.find_by_title(theme) + end + guidance.save! end - guidance.save! end templates = { - "DCC" => { - title: "DCC Template", - description: "The default DCC template", + "RCC" => { + title: "Regional Curation Center Template", + description: "The default RCC template", published: true, - organisation: "DCC", + organisation: "RCC", locale: "en", is_default: true }, - "Funder Template" => { - title: "Funder Template", + "Global Research Center" => { + title: "Global Research Center Award", description: "Funder template description", published: true, - organisation: "Funder_example", + organisation: "EGRC", + locale: "en", + is_default: false + }, + "Regional Science Federation" => { + title: "Regional Science Federation Grant - Summary", + description: "Funder template description for phase 1", + published: true, + organisation: "RegSciFed", + locale: "en", + is_default: false + }, + "Regional Science Federation2" => { + title: "Regional Science Federation Grant - Finalized", + description: "Funder template description for phase 2", + published: true, + organisation: "RegSciFed", locale: "en", is_default: false } } templates.each do |t, details| - template = Dmptemplate.new - template.title = details[:title] - template.description = details[:description] - template.published = details[:published] - template.locale = details[:locale] - template.is_default = details[:is_default] - template.organisation = Organisation.find_by_abbreviation(details[:organisation]) - template.save! + org = Organisation.where(abbreviation: details[:organisation]).first + + if Dmptemplate.where(organisation: org).where(title: details[:title]).empty? + template = Dmptemplate.new + template.title = details[:title] + template.description = details[:description] + template.published = details[:published] + template.locale = details[:locale] + template.is_default = details[:is_default] + template.organisation = org + template.save! + end end phases = { - "DCC" => { - title: "DCC Data Management Plan", + "RCC" => { + title: "Regional CurationCenter Data Management Plan", number: 1, - template: "DCC Template" + template: "Regional Curation Center Template" }, - "Funder Template" => { - title: "Funder Technical Plan", + "EGRC Template" => { + title: "Global Research Center Annual Award", number: 1, - template: "Funder Template" + template: "Global Research Center Award" }, + "RegSciFed Template" => { + title: "Regional Science Federation - Preliminary", + number: 1, + template: "Regional Science Federation Grant - Summary" + }, + "RegSciFed Template2" => { + title: "Regional Science Federation - Final", + number: 1, + template: "Regional Science Federation Grant - Finalized" + } } phases.each do |p, details| - phase = Phase.new - phase.title = details[:title] - phase.number = details[:number] - phase.dmptemplate = Dmptemplate.find_by_title(details[:template]) - phase.save! + if Phase.where(title: details[:title]).empty? + phase = Phase.new + phase.title = details[:title] + phase.number = details[:number] + phase.dmptemplate = Dmptemplate.find_by_title(details[:template]) + phase.save! + end end versions = { - "DCC" => { - title: "DCC Template Version 1", + "RCC" => { + title: "Default Template v1", number: 1, - phase: "DCC Template" + phase: "Regional CurationCenter Data Management Plan" }, - "Funder" => { - title: "Funder Data Management Plan (Version 1)", + "EGRC" => { + title: "Annual Award v1", number: 1, - phase: "Funder Technical Plan" + phase: "Global Research Center Annual Award" + }, + "RegSciFed_1" => { + title: "Grant Summary v1", + number: 1, + phase: "Regional Science Federation - Preliminary" + }, + "RegSciFed_2" => { + title: "Grant Finalized Award v1", + number: 1, + phase: "Regional Science Federation - Final" + }, + "RegSciFed_2.1" => { + title: "Grant Finalized v2", + number: 1, + phase: "Regional Science Federation - Final" }, } versions.each do |v, details| - version = Version.new - version.title = details[:title] - version.number = details[:number] - version.phase = Phase.find_by_title(details[:phase]) - version.save! + if Version.where(title: details[:title]).empty? + version = Version.new + version.title = details[:title] + version.number = details[:number] + version.phase = Phase.find_by_title(details[:phase]) + version.save! + end end sections = { @@ -306,50 +446,77 @@ title: "Data Collection", number: 1, description: "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.", - version: "DCC Template Version 1", - organisation: "DCC" + version: "Default Template v1", + organisation: "RCC" }, "Section 2" => { title: "Documentation and Metadata", number: 2, description: "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.", - version: "DCC Template Version 1", - organisation: "DCC" + version: "Default Template v1", + organisation: "RCC" }, - "1: Section" => { - title: "1: Section", + "Section A" => { + title: "Data Overview", number: 1, - version: "Funder Data Management Plan (Version 1)", - organisation: "Funder_example" + version: "Annual Award v1", + organisation: "EGRC" }, - "2: Section" => { - title: "2: Section", + "Section B" => { + title: "Ethics and Legal Compliance", number: 2, - version: "Funder Data Management Plan (Version 1)", - organisation: "Funder_example" + version: "Annual Award v1", + organisation: "EGRC" }, - "3: Section" => { - title: "3: Section", + "Section C" => { + title: "Storage and Backup", number: 3, - version: "Funder Data Management Plan (Version 1)", - organisation: "Funder_example" + version: "Annual Award v1", + organisation: "EGRC" }, - "4: Section" => { - title: "4: Section", + "Section D" => { + title: "Preservation, Sustainability and Use", number: 4, - version: "Funder Data Management Plan (Version 1)", - organisation: "Institution_example" + version: "Annual Award v1", + organisation: "EGRC" + }, + "regSciFed Summary" => { + title: "Data Collection Guidelines", + number: 1, + description: "This is what we plan on collecting and how we're going to store it.", + version: "Grant Summary v1", + organisation: "RegSciFed" + }, + "RegSciFed Final 1" => { + title: "Data Collection and Storage", + number: 1, + version: "Grant Finalized Award v1", + organisation: "RegSciFed" + }, + "RegSciFed Final 1_2" => { + title: "Data Preservation", + number: 2, + version: "Grant Finalized v2", + organisation: "RegSciFed" + }, + "RegSciFed Final 2_2" => { + title: "Ongoing Access", + number: 3, + version: "Grant Finalized v2", + organisation: "RegSciFed" } } sections.each do |s, details| - section = Section.new - section.title = details[:title] - section.number = details[:number] - section.description = details[:description] - section.version = Version.find_by_title(details[:version]) - section.organisation = Organisation.find_by_abbreviation(details[:organisation]) - section.save! + if Section.where(title: details[:title]).empty? + section = Section.new + section.title = details[:title] + section.number = details[:number] + section.description = details[:description] + section.version = Version.find_by_title(details[:version]) + section.organisation = Organisation.find_by_abbreviation(details[:organisation]) + section.save! + end end questions = { @@ -374,6 +541,13 @@ guidance: "

    Questions to consider:

    Guidance:

    Describe the types of documentation that will accompany the data to help secondary users to understand and reuse it. This should at least include basic details that will help people to find the data, including who created or contributed to the data, its title, date of creation and under what conditions it can be accessed.

    Documentation may also include details on the methodology used, analytical and procedural information, definitions of variables, vocabularies, units of measurement, any assumptions made, and the format and file type of the data. Consider how you will capture this information and where it will be recorded. Wherever possible you should identify and use existing community standards.

    ", themes: ["Theme 1", "Theme 4"] }, + "Data Overview" => { + text: "Overview of the Data", + section: "Data Overview", + number: 1, + guidance: "

    Things to consider: