Skip to content

Commit

Permalink
Merge branch 'DMPRoadmap-master' into development
Browse files Browse the repository at this point in the history
  • Loading branch information
briri committed Jul 15, 2020
2 parents f75d5d9 + 337e992 commit 98c4871
Show file tree
Hide file tree
Showing 13 changed files with 176 additions and 160 deletions.
58 changes: 29 additions & 29 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ GEM
api-pagination (4.8.2)
arel (6.0.4)
ast (2.4.1)
autoprefixer-rails (9.7.6)
autoprefixer-rails (9.8.5)
execjs
bcrypt (3.1.13)
better_errors (2.7.1)
Expand Down Expand Up @@ -81,11 +81,11 @@ GEM
i18n
rake (>= 10.0.0)
sshkit (>= 1.9.0)
capistrano-bundler (1.6.0)
capistrano-bundler (2.0.1)
capistrano (~> 3.1)
capistrano-rails (1.5.0)
capistrano-rails (1.6.1)
capistrano (~> 3.1)
capistrano-bundler (~> 1.1)
capistrano-bundler (>= 1.1, < 3)
capybara (3.32.2)
addressable
mini_mime (>= 0.1.3)
Expand Down Expand Up @@ -122,12 +122,12 @@ GEM
devise_invitable (1.7.5)
actionmailer (>= 4.1.0)
devise (>= 4.0.0)
diff-lcs (1.3)
diff-lcs (1.4.4)
docile (1.3.2)
dotenv (2.7.5)
dotenv-rails (2.7.5)
dotenv (= 2.7.5)
railties (>= 3.2, < 6.1)
dotenv (2.7.6)
dotenv-rails (2.7.6)
dotenv (= 2.7.6)
railties (>= 3.2)
dragonfly (1.2.0)
addressable (~> 2.3)
multi_json (~> 1.0)
Expand All @@ -138,7 +138,7 @@ GEM
erubi (1.9.0)
erubis (2.7.0)
eventmachine (1.2.7)
excon (0.74.0)
excon (0.75.0)
execjs (2.7.0)
factory_bot (5.2.0)
activesupport (>= 4.2.0)
Expand All @@ -152,7 +152,7 @@ GEM
fast_gettext (2.0.3)
ffi (1.13.1)
flag_shih_tzu (0.3.23)
fog-aws (3.6.5)
fog-aws (3.6.6)
fog-core (~> 2.1)
fog-json (~> 1.1)
fog-xml (~> 0.1)
Expand Down Expand Up @@ -216,7 +216,7 @@ GEM
jbuilder (2.6.4)
activesupport (>= 3.0.0)
multi_json (>= 1.2)
json (2.3.0)
json (2.3.1)
jwt (2.2.1)
kaminari (1.2.1)
activesupport (>= 4.1.0)
Expand All @@ -239,10 +239,10 @@ GEM
rb-fsevent (~> 0.10, >= 0.10.3)
rb-inotify (~> 0.9, >= 0.9.10)
locale (2.1.3)
loofah (2.5.0)
loofah (2.6.0)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
lumberjack (1.2.5)
lumberjack (1.2.6)
mail (2.7.1)
mini_mime (>= 0.1.1)
method_source (1.0.0)
Expand All @@ -251,11 +251,11 @@ GEM
mime-types-data (3.2020.0512)
mini_mime (1.0.2)
mini_portile2 (2.4.0)
mini_racer (0.2.14)
mini_racer (0.2.15)
libv8 (> 7.3)
minitest (5.14.1)
mocha (1.11.2)
multi_json (1.14.1)
multi_json (1.15.0)
multi_xml (0.6.0)
multipart-post (2.1.1)
mysql2 (0.4.10)
Expand All @@ -264,7 +264,7 @@ GEM
net-ssh (>= 2.6.5, < 7.0.0)
net-ssh (6.1.0)
nio4r (2.5.2)
nokogiri (1.10.9)
nokogiri (1.10.10)
mini_portile2 (~> 2.4.0)
notiffany (0.1.3)
nenv (~> 0.1)
Expand All @@ -291,9 +291,9 @@ GEM
omniauth (>= 1.0.0)
options (2.3.2)
orm_adapter (0.5.0)
parallel (1.19.1)
parser (2.7.1.3)
ast (~> 2.4.0)
parallel (1.19.2)
parser (2.7.1.4)
ast (~> 2.4.1)
pg (0.19.0)
po_to_json (1.0.1)
json (>= 1.6.0)
Expand Down Expand Up @@ -358,7 +358,7 @@ GEM
actionpack (>= 4.2.0, < 6.0)
railties (>= 4.2.0, < 6.0)
rexml (3.2.4)
rollbar (2.25.1)
rollbar (2.26.0)
rspec (3.9.0)
rspec-core (~> 3.9.0)
rspec-expectations (~> 3.9.0)
Expand All @@ -382,23 +382,23 @@ GEM
rspec-mocks (~> 3.9)
rspec-support (~> 3.9)
rspec-support (3.9.3)
rubocop (0.85.1)
rubocop (0.88.0)
parallel (~> 1.10)
parser (>= 2.7.0.1)
parser (>= 2.7.1.1)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.7)
rexml
rubocop-ast (>= 0.0.3)
rubocop-ast (>= 0.1.0, < 1.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 1.4.0, < 2.0)
rubocop-ast (0.0.3)
rubocop-ast (0.1.0)
parser (>= 2.7.0.1)
rubocop-dmp_roadmap (1.1.2)
rubocop (>= 0.58.2)
rubocop-rails_config (>= 0.2.2)
rubocop-rspec (>= 1.27.0)
rubocop-performance (1.6.1)
rubocop (>= 0.71.0)
rubocop-performance (1.7.0)
rubocop (>= 0.82.0)
rubocop-rails (2.6.0)
activesupport (>= 4.2.0)
rack (>= 1.1)
Expand All @@ -408,8 +408,8 @@ GEM
rubocop (~> 0.77)
rubocop-performance (~> 1.3)
rubocop-rails (~> 2.0)
rubocop-rspec (1.40.0)
rubocop (>= 0.68.1)
rubocop-rspec (1.42.0)
rubocop (>= 0.87.0)
ruby-progressbar (1.10.1)
ruby_dig (0.0.2)
rubyzip (1.3.0)
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ See the [Translations Guide](https://github.com/DMPRoadmap/roadmap/wiki/Translat

#### Pre-requisites
Roadmap is a Ruby on Rails application and you will need to have:
* Ruby >= 2.4.4
* Rails >= 4.2
* Ruby = 2.4.0 - 2.4.4
* Rails = 4.2
* MySQL >= 5.0 OR PostgreSQL

## Installation
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/api/v0/departments_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def assign_users_to(department_id)
end

reassign.department_id = department_id
reasign.save!
reassign.save!
end
end

Expand Down
4 changes: 3 additions & 1 deletion app/controllers/registrations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,9 @@ def create

build_resource(attrs)

if verify_recaptcha(model: resource) && resource.save
# Determine if reCAPTCHA is enabled and if so verify it
use_recaptcha = Rails.configuration.branding[:application][:use_recaptcha] || false
if (!use_recaptcha || verify_recaptcha(model: resource)) && resource.save
if resource.active_for_authentication?
set_flash_message :notice, :signed_up if is_navigational_format?
sign_up(resource_name, resource)
Expand Down
5 changes: 2 additions & 3 deletions app/controllers/users/omniauth_callbacks_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def handle_omniauth(scheme)
# if user.nil?
# session["devise.#{scheme.name.downcase}_data"] = request.env["omniauth.auth"]
# redirect_to new_user_registration_url
#

# # Otherwise sign them in
# else
# # Until ORCID becomes supported as a login method
Expand All @@ -62,7 +62,7 @@ def handle_omniauth(scheme)
# redirect_to new_user_registration_url
# end
# end
#

# # The user is already logged in and just registering the uid with us
# else
# # If the user could not be found by that uid then attach it to their record
Expand Down Expand Up @@ -93,7 +93,6 @@ def handle_omniauth(scheme)
# # Redirect to the User Profile page
# redirect_to edit_user_registration_path
# end

# --------------------------------------------------------
# End DMPTool customization
# --------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion app/javascript/views/shared/create_account_form.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { initAutocomplete } from '../../utils/autoComplete';
import { togglisePasswords } from '../../utils/passwordHelper';

$(() => {
const options = { selector: '#create_account_form' };
const options = { selector: '#create-account-form' };
initAutocomplete('#create-account-org-controls .autocomplete');
togglisePasswords(options);
});
3 changes: 3 additions & 0 deletions app/models/contributor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ class Contributor < ActiveRecord::Base
validates :roles, numericality: { greater_than: 0,
message: _("You must specify at least one role.") }

validates :roles, numericality: { greater_than: 0,
message: _("You must specify at least one role.") }

validate :name_or_email_presence

ONTOLOGY_NAME = "CRediT - Contributor Roles Taxonomy"
Expand Down
2 changes: 1 addition & 1 deletion app/models/org.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class Org < ActiveRecord::Base
belongs_to :region

has_one :tracker, dependent: :destroy
accepts_nested_attributes_for :tracker
accepts_nested_attributes_for :tracker
validates_associated :tracker

has_many :guidance_groups, dependent: :destroy
Expand Down
9 changes: 6 additions & 3 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
# ------------------------------------------
# End DMPTool Customization
# ------------------------------------------

# ------------------------------------------
# Start DMPTool customizations
# ------------------------------------------
Expand Down Expand Up @@ -79,6 +79,9 @@
get "public_templates" => 'public_pages#template_index'
get "template_export/:id" => 'public_pages#template_export', as: 'template_export'

# AJAX call used to search for Orgs based on user input into autocompletes
post "orgs" => "orgs#search", as: "orgs_search"

# ------------------------------------------
# Start DMPTool customizations
# ------------------------------------------
Expand All @@ -98,8 +101,8 @@
# End DMPTool customizations
# ------------------------------------------

# AJAX call used to search for Orgs based on user input into autocompletes
post "orgs" => "orgs#search", as: "orgs_search"
#post 'contact_form' => 'contacts', as: 'localized_contact_creation'
#get 'contact_form' => 'contacts#new', as: 'localized_contact_form'

resources :orgs, :path => 'org/admin', only: [] do
member do
Expand Down
7 changes: 7 additions & 0 deletions db/migrate/20200625092600_add_indexes_to_plans.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class AddIndexesToPlans < ActiveRecord::Migration
def change
add_index :plans, :org_id
add_index :plans, :funder_id
add_index :plans, :grant_id
end
end
21 changes: 12 additions & 9 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 20200601121822) do
ActiveRecord::Schema.define(version: 20200625092600) do

create_table "annotations", force: :cascade do |t|
t.integer "question_id", limit: 4
Expand Down Expand Up @@ -198,9 +198,9 @@
t.boolean "dismissable"
t.date "starts_at"
t.date "expires_at"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.boolean "enabled", default: true
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.boolean "enabled", default: true
end

create_table "org_identifiers", force: :cascade do |t|
Expand Down Expand Up @@ -247,9 +247,6 @@
t.boolean "managed", default: false, null: false
end

add_index "orgs", ["language_id"], name: "fk_rails_5640112cab", using: :btree
add_index "orgs", ["region_id"], name: "fk_rails_5a6adf6bab", using: :btree

create_table "perms", force: :cascade do |t|
t.string "name", limit: 255
t.datetime "created_at", null: false
Expand Down Expand Up @@ -294,10 +291,14 @@
t.integer "grant_id", limit: 4
t.datetime "start_date"
t.datetime "end_date"
t.integer "api_client_id"
end

add_index "plans", ["org_id"], name: "fk_rails_eda8ce4bca", using: :btree
add_index "plans", ["template_id"], name: "index_plans_on_template_id", using: :btree
add_index "plans", ["org_id"], name: "index_plans_on_org_id", using: :btree
add_index "plans", ["funder_id"], name: "index_plans_on_funder_id", using: :btree
add_index "plans", ["grant_id"], name: "index_plans_on_grant_id", using: :btree

create_table "plans_guidance_groups", force: :cascade do |t|
t.integer "guidance_group_id", limit: 4
Expand Down Expand Up @@ -533,9 +534,7 @@
t.datetime "last_api_access"
end

add_index "users", ["department_id"], name: "fk_rails_f29bf9cdf2", using: :btree
add_index "users", ["email"], name: "index_users_on_email", using: :btree
add_index "users", ["language_id"], name: "fk_rails_45f4f12508", using: :btree
add_index "users", ["org_id"], name: "index_users_on_org_id", using: :btree

create_table "users_perms", id: false, force: :cascade do |t|
Expand All @@ -551,7 +550,11 @@
add_foreign_key "answers", "plans"
add_foreign_key "answers", "questions"
add_foreign_key "answers", "users"
add_foreign_key "answers_question_options", "answers"
add_foreign_key "answers_question_options", "question_options"
add_foreign_key "conditions", "questions"
add_foreign_key "contributors", "plans"
add_foreign_key "contributors", "orgs"
add_foreign_key "guidance_groups", "orgs"
add_foreign_key "guidances", "guidance_groups"
add_foreign_key "notes", "answers"
Expand Down
13 changes: 8 additions & 5 deletions lib/tasks/upgrade.rake
Original file line number Diff line number Diff line change
Expand Up @@ -988,12 +988,15 @@ namespace :upgrade do
desc "Attempts to migrate other_organisation entries to Orgs"
task migrate_other_organisation_to_org: :environment do
is_other = Org.find_by(is_other: true)
p "No is_other Org defined, so no orgs need to be created!" unless is_other.present?
return false unless is_other.present?
users = is_other.present? ? User.where(org: is_other) : []

if is_other.present?
p "Processing #{users.length} users attached to '#{is_other.name}' #{is_other.id}"
p "this may take more than 15 minutes depending on how many users are in your database"
else
p "No is_other Org defined, so no orgs need to be created!"
end

users = User.where(org: is_other)
p "Processing #{users.length} users attached to '#{is_other.name}' #{is_other.id}"
p "this may take more than 15 minutes depending on how many users are in your database"
# Unfortunately can't use the Parallel gem here because we can have collisions
# when creating Orgs
users.each do |user|
Expand Down
Loading

0 comments on commit 98c4871

Please sign in to comment.