From d426909438bba3e4cab7d33f872b85bcf4c79b07 Mon Sep 17 00:00:00 2001 From: briri Date: Thu, 19 Aug 2021 14:47:00 -0700 Subject: [PATCH 1/7] removed old unused columns and tables and updated code where necessary --- .../feedback_requests_controller.rb | 2 +- app/controllers/orgs_controller.rb | 2 +- app/controllers/plans_controller.rb | 6 +- app/controllers/registrations_controller.rb | 4 +- .../super_admin/orgs_controller.rb | 4 +- .../super_admin/users_controller.rb | 3 +- .../template_options_controller.rb | 2 +- app/javascript/src/orgs/adminEdit.js | 4 +- app/mailers/user_mailer.rb | 17 -- app/models/answer.rb | 1 - app/models/org.rb | 25 +-- app/models/org_identifier.rb | 59 ------ app/models/user.rb | 1 - app/models/user_identifier.rb | 44 ----- app/policies/identifier_policy.rb | 2 - app/presenters/org_selection_presenter.rb | 2 - .../super_admin/orgs/merge_presenter.rb | 6 +- .../org_selection/hash_to_org_service.rb | 3 +- .../org_selection/org_to_hash_service.rb | 2 +- app/views/layouts/_header.html.erb | 2 +- app/views/orgs/_feedback_form.html.erb | 4 +- .../plans/_request_feedback_form.html.erb | 2 +- app/views/plans/index.html.erb | 2 +- .../super_admin/api_clients/_form.html.erb | 2 +- .../feedback_confirmation.html.erb | 1 - db/migrate/20210819160319_db_cleanup_2021.rb | 19 ++ db/schema.rb | 182 +++++++++++++++++- lib/tasks/upgrade.rake | 8 +- lib/tasks/v3.rake | 8 +- spec/controllers/orgs_controller_spec.rb | 4 +- .../registrations_controller_spec.rb | 2 +- spec/factories/answers.rb | 1 - spec/factories/orgs.rb | 6 +- spec/factories/users.rb | 1 - spec/features/feedback_requests_spec.rb | 3 +- spec/features/plans/exports_spec.rb | 2 +- spec/models/org_spec.rb | 23 +-- spec/models/template_spec.rb | 2 +- spec/models/user_spec.rb | 2 +- .../super_admin/orgs/merge_presenter_spec.rb | 22 +-- 40 files changed, 257 insertions(+), 230 deletions(-) delete mode 100644 app/models/org_identifier.rb delete mode 100644 app/models/user_identifier.rb delete mode 100644 app/views/user_mailer/feedback_confirmation.html.erb create mode 100644 db/migrate/20210819160319_db_cleanup_2021.rb diff --git a/app/controllers/feedback_requests_controller.rb b/app/controllers/feedback_requests_controller.rb index 3102f9942d..21ad271218 100644 --- a/app/controllers/feedback_requests_controller.rb +++ b/app/controllers/feedback_requests_controller.rb @@ -31,7 +31,7 @@ def create def request_feedback_flash_notice # Use the generic feedback confirmation message unless the Org has # specified one - text = current_user.org.feedback_email_msg || feedback_confirmation_default_message + text = current_user.org.feedback_msg || feedback_confirmation_default_message feedback_constant_to_text(text, current_user, @plan, current_user.org) end diff --git a/app/controllers/orgs_controller.rb b/app/controllers/orgs_controller.rb index cad171d993..f302afd450 100644 --- a/app/controllers/orgs_controller.rb +++ b/app/controllers/orgs_controller.rb @@ -215,7 +215,7 @@ def org_params .permit(:name, :abbreviation, :logo, :contact_email, :contact_name, :remove_logo, :managed, :feedback_enabled, :org_links, :funder, :institution, :organisation, - :feedback_email_msg, :org_id, :org_name, :org_crosswalk, + :feedback_msg, :org_id, :org_name, :org_crosswalk, identifiers_attributes: %i[identifier_scheme_id value], tracker_attributes: %i[code id]) end diff --git a/app/controllers/plans_controller.rb b/app/controllers/plans_controller.rb index 53874b74fc..33a8327272 100644 --- a/app/controllers/plans_controller.rb +++ b/app/controllers/plans_controller.rb @@ -15,11 +15,11 @@ class PlansController < ApplicationController def index authorize Plan @plans = Plan.includes(:roles, :org).active(current_user).page(1) - if current_user.org.is_other? - @organisationally_or_publicly_visible = [] - else + if current_user.org.managed? @organisationally_or_publicly_visible = Plan.organisationally_or_publicly_visible(current_user).page(1) + else + @organisationally_or_publicly_visible = [] end # TODO: Is this still used? We cannot switch this to use the :plan_params # strong params because any calls that do not include `plan` in the diff --git a/app/controllers/registrations_controller.rb b/app/controllers/registrations_controller.rb index 298525d6b1..c6c9614784 100644 --- a/app/controllers/registrations_controller.rb +++ b/app/controllers/registrations_controller.rb @@ -9,7 +9,7 @@ def edit @prefs = @user.get_preferences(:email) @languages = Language.sorted_by_abbreviation @orgs = Org.order("name") - @other_organisations = Org.where(is_other: true).pluck(:id) + @other_organisations = Org.where(managed: false).pluck(:id) @identifier_schemes = IdentifierScheme.for_users.order(:name) @default_org = current_user.org @@ -141,7 +141,7 @@ def update @prefs = @user.get_preferences(:email) @orgs = Org.order("name") @default_org = current_user.org - @other_organisations = Org.where(is_other: true).pluck(:id) + @other_organisations = Org.where(managed: false).pluck(:id) @identifier_schemes = IdentifierScheme.for_users.order(:name) @languages = Language.sorted_by_abbreviation if params[:skip_personal_details] == "true" diff --git a/app/controllers/super_admin/orgs_controller.rb b/app/controllers/super_admin/orgs_controller.rb index 6cecf152a2..6e2c49634b 100644 --- a/app/controllers/super_admin/orgs_controller.rb +++ b/app/controllers/super_admin/orgs_controller.rb @@ -149,9 +149,7 @@ def merge_commit def org_params params.require(:org).permit(:name, :abbreviation, :logo, :managed, :contact_email, :contact_name, - :remove_logo, :feedback_enabled, - :feedback_email_subject, - :feedback_email_msg, + :remove_logo, :feedback_enabled, :feedback_msg, :org_id, :org_name, :org_crosswalk) end diff --git a/app/controllers/super_admin/users_controller.rb b/app/controllers/super_admin/users_controller.rb index 933ac6e5c5..6bdacee6ba 100644 --- a/app/controllers/super_admin/users_controller.rb +++ b/app/controllers/super_admin/users_controller.rb @@ -119,8 +119,7 @@ def user_params :surname, :org_id, :org_name, :org_crosswalk, :department_id, - :language_id, - :other_organisation) + :language_id) end def merge_accounts diff --git a/app/controllers/template_options_controller.rb b/app/controllers/template_options_controller.rb index 8118cc8b22..373e48c074 100644 --- a/app/controllers/template_options_controller.rb +++ b/app/controllers/template_options_controller.rb @@ -79,7 +79,7 @@ def plan_params end def org_params - %i[id name sort_name url language abbreviation ror fundref weight score] + %i[id name url language abbreviation ror fundref weight score] end end diff --git a/app/javascript/src/orgs/adminEdit.js b/app/javascript/src/orgs/adminEdit.js index ac27b03499..c393c39c27 100644 --- a/app/javascript/src/orgs/adminEdit.js +++ b/app/javascript/src/orgs/adminEdit.js @@ -7,7 +7,7 @@ import { initAutocomplete, scrubOrgSelectionParamsOnSubmit } from '../utils/auto $(() => { const toggleFeedback = () => { - const editor = Tinymce.findEditorById('org_feedback_email_msg'); + const editor = Tinymce.findEditorById('org_feedback_msg'); if (isObject(editor)) { if ($('#org_feedback_enabled_true').is(':checked')) { editor.setMode('code'); @@ -22,7 +22,7 @@ $(() => { }); // Initialises tinymce for any target element with class tinymce_answer - Tinymce.init({ selector: '#org_feedback_email_msg' }); + Tinymce.init({ selector: '#org_feedback_msg' }); toggleFeedback(); if ($('#org-details-org-controls').length > 0) { diff --git a/app/mailers/user_mailer.rb b/app/mailers/user_mailer.rb index f5dd48f29b..86a52ad1dc 100644 --- a/app/mailers/user_mailer.rb +++ b/app/mailers/user_mailer.rb @@ -138,23 +138,6 @@ def feedback_complete(recipient, plan, requestor) end end - def feedback_confirmation(recipient, plan, requestor) - return unless user.org.present? && recipient.active? - - user = requestor - org = user.org - plan = plan - # Use the generic feedback confirmation message unless the Org has specified one - subject = org.feedback_email_subject || feedback_confirmation_default_subject - message = org.feedback_email_msg || feedback_confirmation_default_message - @body = feedback_constant_to_text(message, user, plan, org) - - I18n.with_locale I18n.default_locale do - mail(to: recipient.email, - subject: feedback_constant_to_text(subject, user, plan, org)) - end - end - def plan_visibility(user, plan) return unless user.active? diff --git a/app/models/answer.rb b/app/models/answer.rb index dd03175142..c994391b04 100644 --- a/app/models/answer.rb +++ b/app/models/answer.rb @@ -9,7 +9,6 @@ # text :text # created_at :datetime # updated_at :datetime -# label_id :string # plan_id :integer # question_id :integer # user_id :integer diff --git a/app/models/org.rb b/app/models/org.rb index 6aa1537bde..a03b0b7853 100644 --- a/app/models/org.rb +++ b/app/models/org.rb @@ -8,10 +8,8 @@ # abbreviation :string # contact_email :string # contact_name :string -# feedback_email_msg :text -# feedback_email_subject :string +# feedback_msg :text # feedback_enabled :boolean default(FALSE) -# is_other :boolean default(FALSE), not null # links :text # logo_name :string # logo_uid :string @@ -42,14 +40,10 @@ class Org < ApplicationRecord LOGO_FORMATS = %w[jpeg png gif jpg bmp].freeze HUMANIZED_ATTRIBUTES = { - feedback_email_msg: _("Feedback email message") + feedback_msg: _("Feedback email message") }.freeze - # TODO: we don't allow this to be edited on the frontend, can we remove from DB? - # if not, we'll need to add a rake:task to ensure that each of these is set for each - # org - attribute :feedback_email_subject, :string, default: feedback_confirmation_default_subject - attribute :feedback_email_msg, :text, default: feedback_confirmation_default_message + attribute :feedback_msg, :text, default: feedback_confirmation_default_message attribute :language_id, :integer, default: -> { Language.default&.id } attribute :links, :text, default: { "org": [] } @@ -100,9 +94,6 @@ class Org < ApplicationRecord validates :abbreviation, presence: { message: PRESENCE_MESSAGE } - validates :is_other, inclusion: { in: BOOLEAN_VALUES, - message: INCLUSION_MESSAGE } - validates :language, presence: { message: PRESENCE_MESSAGE } validates :contact_name, presence: { message: PRESENCE_MESSAGE, @@ -117,10 +108,7 @@ class Org < ApplicationRecord validates :feedback_enabled, inclusion: { in: BOOLEAN_VALUES, message: INCLUSION_MESSAGE } - validates :feedback_email_subject, presence: { message: PRESENCE_MESSAGE, - if: :feedback_enabled } - - validates :feedback_email_msg, presence: { message: PRESENCE_MESSAGE, + validates :feedback_msg, presence: { message: PRESENCE_MESSAGE, if: :feedback_enabled } validates :managed, inclusion: { in: BOOLEAN_VALUES, @@ -372,10 +360,7 @@ def merge_attributes!(to_be_merged:) self.contact_email = to_be_merged.contact_email unless contact_email.present? self.contact_name = to_be_merged.contact_name unless contact_name.present? self.feedback_enabled = to_be_merged.feedback_enabled unless feedback_enabled? - self.feedback_email_msg = to_be_merged.feedback_email_msg unless feedback_email_msg.present? - # rubocop:disable Layout/LineLength - self.feedback_email_subject = to_be_merged.feedback_email_subject unless feedback_email_subject.present? - # rubocop:enable Layout/LineLength + self.feedback_msg = to_be_merged.feedback_msg unless feedback_msg.present? end # rubocop:enable Metrics/AbcSize diff --git a/app/models/org_identifier.rb b/app/models/org_identifier.rb deleted file mode 100644 index 287a717c01..0000000000 --- a/app/models/org_identifier.rb +++ /dev/null @@ -1,59 +0,0 @@ -# frozen_string_literal: true - -# == Schema Information -# -# Table name: org_identifiers -# -# id :integer not null, primary key -# attrs :string -# identifier :string -# created_at :datetime -# updated_at :datetime -# identifier_scheme_id :integer -# org_id :integer -# -# Indexes -# -# fk_rails_189ad2e573 (identifier_scheme_id) -# fk_rails_36323c0674 (org_id) -# -# Foreign Keys -# -# fk_rails_... (identifier_scheme_id => identifier_schemes.id) -# fk_rails_... (org_id => orgs.id) -# - -class OrgIdentifier < ApplicationRecord - - # ================ - # = Associations = - # ================ - - belongs_to :org - belongs_to :identifier_scheme - - # =============== - # = Validations = - # =============== - - # Should only be able to have one identifier per scheme! - validates :identifier_scheme_id, uniqueness: { scope: :org_id, - message: UNIQUENESS_MESSAGE } - - validates :identifier, presence: { message: PRESENCE_MESSAGE } - - validates :org, presence: { message: PRESENCE_MESSAGE } - - validates :identifier_scheme, presence: { message: PRESENCE_MESSAGE } - - # ========================= - # = Custom Accessor Logic = - # ========================= - - # ensure attrs is a hash before saving - # TODO: evaluate this approach vs Serialize from condition.rb - def attrs=(hash) - super(hash.is_a?(Hash) ? hash.to_json.to_s : "{}") - end - -end diff --git a/app/models/user.rb b/app/models/user.rb index 5391699faa..7a1f4e8457 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -25,7 +25,6 @@ # last_sign_in_ip :string # ldap_password :string # ldap_username :string -# other_organisation :string # recovery_email :string # remember_created_at :datetime # reset_password_sent_at :datetime diff --git a/app/models/user_identifier.rb b/app/models/user_identifier.rb deleted file mode 100644 index 0ce3d7ea8d..0000000000 --- a/app/models/user_identifier.rb +++ /dev/null @@ -1,44 +0,0 @@ -# frozen_string_literal: true - -# == Schema Information -# -# Table name: user_identifiers -# -# id :integer not null, primary key -# identifier :string -# created_at :datetime -# updated_at :datetime -# identifier_scheme_id :integer -# user_id :integer -# -# Indexes -# -# fk_rails_fe95df7db0 (identifier_scheme_id) -# index_user_identifiers_on_user_id (user_id) -# -# Foreign Keys -# -# fk_rails_... (identifier_scheme_id => identifier_schemes.id) -# fk_rails_... (user_id => users.id) -# - -class UserIdentifier < ApplicationRecord - - # ================ - # = Associations = - # ================ - - belongs_to :user - belongs_to :identifier_scheme - - # =============== - # = Validations = - # =============== - - validates :user, presence: true - - validates :identifier_scheme, presence: { message: PRESENCE_MESSAGE } - - validates :identifier, presence: { message: PRESENCE_MESSAGE } - -end diff --git a/app/policies/identifier_policy.rb b/app/policies/identifier_policy.rb index 03fac6bec1..d9afca3286 100644 --- a/app/policies/identifier_policy.rb +++ b/app/policies/identifier_policy.rb @@ -2,8 +2,6 @@ class IdentifierPolicy < ApplicationPolicy - attr_reader :user_identifier - def initialize(user, users) raise Pundit::NotAuthorizedError, "must be logged in" unless user diff --git a/app/presenters/org_selection_presenter.rb b/app/presenters/org_selection_presenter.rb index 5f725213d8..b31f2e2b31 100644 --- a/app/presenters/org_selection_presenter.rb +++ b/app/presenters/org_selection_presenter.rb @@ -7,7 +7,6 @@ class OrgSelectionPresenter def initialize(orgs:, selection:) @crosswalk = [] - # TODO: Remove this once the is_other Org has been removed @name = selection.present? ? selection.name : "" orgs = [selection] if !orgs.present? || orgs.empty? @@ -19,7 +18,6 @@ def initialize(orgs:, selection:) end end - # Return the Org name unless this is the default is_other Org attr_reader :name def crosswalk diff --git a/app/presenters/super_admin/orgs/merge_presenter.rb b/app/presenters/super_admin/orgs/merge_presenter.rb index e3bc57cf96..0e503408e7 100644 --- a/app/presenters/super_admin/orgs/merge_presenter.rb +++ b/app/presenters/super_admin/orgs/merge_presenter.rb @@ -108,8 +108,7 @@ def org_attributes(org:) { contact_email: org.contact_email, contact_name: org.contact_name, - feedback_email_msg: org.feedback_email_msg, - feedback_email_subject: org.feedback_email_subject, + feedback_msg: org.feedback_msg, feedback_enabled: org.feedback_enabled, managed: org.managed, links: org.links, @@ -135,8 +134,7 @@ def mergeable_columns end if mergeable_column?(column: :feedback_enabled) out[:feedback_enabled] = @from_org.feedback_enabled - out[:feedback_email_subject] = @from_org.feedback_email_subject - out[:feedback_email_msg] = @from_org.feedback_email_msg + out[:feedback_msg] = @from_org.feedback_msg end out end diff --git a/app/services/org_selection/hash_to_org_service.rb b/app/services/org_selection/hash_to_org_service.rb index 29883e7649..f05aa44181 100644 --- a/app/services/org_selection/hash_to_org_service.rb +++ b/app/services/org_selection/hash_to_org_service.rb @@ -14,7 +14,7 @@ module OrgSelection # } # becomes: # An Org with name = "Foo (foo.org)", - # org_identifier (ROR) = "http://example.org/123" + # identifier (ROR) = "http://example.org/123" # class HashToOrgService @@ -95,7 +95,6 @@ def initialize_org(hash:) language: language_from_hash(hash: hash), target_url: hash[:url], institution: true, - is_other: false, abbreviation: abbreviation_from_hash(hash: hash) ) org diff --git a/app/services/org_selection/org_to_hash_service.rb b/app/services/org_selection/org_to_hash_service.rb index 79ccd4dcb2..0f37ee18c9 100644 --- a/app/services/org_selection/org_to_hash_service.rb +++ b/app/services/org_selection/org_to_hash_service.rb @@ -12,7 +12,7 @@ class << self # Convert an Identifiable Model over to hash results like: # An Org with id = 123, name = "Foo (foo.org)", - # org_identifier (ROR) = "http://example.org/123" + # identifier (ROR) = "http://example.org/123" # becomes: # { # id: "123", diff --git a/app/views/layouts/_header.html.erb b/app/views/layouts/_header.html.erb index 293f92465e..088a2f38ea 100644 --- a/app/views/layouts/_header.html.erb +++ b/app/views/layouts/_header.html.erb @@ -3,7 +3,7 @@ <%= render partial: "layouts/navigation" %>
- <% if user_signed_in? && !current_user.org.nil? && (!current_user.org.is_other || current_user.can_super_admin?) %> + <% if user_signed_in? && (!current_user.org.nil? || current_user.can_super_admin?) %> <%= render partial: "layouts/branding" , locals: {max_number_links: Rails.configuration.x.max_number_links_funder} %> <% end %>
diff --git a/app/views/orgs/_feedback_form.html.erb b/app/views/orgs/_feedback_form.html.erb index f0bba98eec..6378091be1 100644 --- a/app/views/orgs/_feedback_form.html.erb +++ b/app/views/orgs/_feedback_form.html.erb @@ -23,8 +23,8 @@
- <%= f.label :feedback_email_msg, _('Message'), class: "control-label" %> - <%= f.text_area :feedback_email_msg, class: "form-control", + <%= f.label :feedback_msg, _('Message'), class: "control-label" %> + <%= f.text_area :feedback_msg, class: "form-control", "aria-required" => true %>
diff --git a/app/views/plans/_request_feedback_form.html.erb b/app/views/plans/_request_feedback_form.html.erb index 0df07c1fc6..0001332f82 100644 --- a/app/views/plans/_request_feedback_form.html.erb +++ b/app/views/plans/_request_feedback_form.html.erb @@ -6,7 +6,7 @@

<%= _('Request expert feedback') %>

<%= _("Click below to give data management staff at #{plan.owner.org.name}, the Plan Owner's org, access to read and comment on your plan.") %>

- <%= sanitize plan.owner.org.feedback_email_msg.to_s % { user_name: current_user.name(false), plan_name: plan.title, organisation_email: current_user.org.contact_email } %> + <%= sanitize plan.owner.org.feedback_msg.to_s % { user_name: current_user.name(false), plan_name: plan.title, organisation_email: current_user.org.contact_email } %>

<%= _('You can continue to edit and download the plan in the interim.') %>

diff --git a/app/views/plans/index.html.erb b/app/views/plans/index.html.erb index 2687edb611..01e70d1272 100644 --- a/app/views/plans/index.html.erb +++ b/app/views/plans/index.html.erb @@ -31,7 +31,7 @@
- <% if @organisationally_or_publicly_visible.any? && !current_user.org.is_other? %> + <% if @organisationally_or_publicly_visible.any? && current_user.org.managed? %>

<%= _('%{org_title} Plans') % { :org_title => current_user.org.name } %>

<%= _('The table below lists the plans that users at your organisation have created and shared within your organisation. This allows you to download a PDF and view their plans as samples or to discover new research data.') %>

<%= paginable_renderise( diff --git a/app/views/super_admin/api_clients/_form.html.erb b/app/views/super_admin/api_clients/_form.html.erb index fbf48eeace..9172349216 100644 --- a/app/views/super_admin/api_clients/_form.html.erb +++ b/app/views/super_admin/api_clients/_form.html.erb @@ -1,7 +1,7 @@ <% url = @api_client.new_record? ? super_admin_api_clients_path : super_admin_api_client_path(@api_client) method = @api_client.new_record? ? :post : :put -orgs = Org.where(is_other: false) +orgs = Org.all %> <%= form_for @api_client, url: url, method: method, diff --git a/app/views/user_mailer/feedback_confirmation.html.erb b/app/views/user_mailer/feedback_confirmation.html.erb deleted file mode 100644 index 8e5d02f2c7..0000000000 --- a/app/views/user_mailer/feedback_confirmation.html.erb +++ /dev/null @@ -1 +0,0 @@ -<%= sanitize @body %> \ No newline at end of file diff --git a/db/migrate/20210819160319_db_cleanup_2021.rb b/db/migrate/20210819160319_db_cleanup_2021.rb new file mode 100644 index 0000000000..f062e7d93b --- /dev/null +++ b/db/migrate/20210819160319_db_cleanup_2021.rb @@ -0,0 +1,19 @@ +class DbCleanup2021 < ActiveRecord::Migration[5.2] + def change + # Removed old columns that are no longer in use + remove_column(:answers, :label_id) if column_exists?(:answers, :label_id) + + remove_column(:orgs, :feedback_email_subject) if column_exists?(:orgs, :feedback_email_subject) + remove_column(:orgs, :is_other) if column_exists?(:orgs, :is_other) + remove_column(:orgs, :sort_name) if column_exists?(:orgs, :sort_name) + + remove column(:users, :other_organization) if column_exists?(:users, :other_organization) + + # Rename the old feedbak email message since we no longer send an email, it's just + # displayed on the page + rename_column(:orgs, :feedback_email_msg, :feedback_msg) if column_exists?(:orgs, :feedback_email_msg) + + # Drop unused tables + drop_table(:org_identifiers) if table_exists?(:org_identifiers) + end +end diff --git a/db/schema.rb b/db/schema.rb index e36701b4ce..796e62ebd6 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2021_07_29_204611) do +ActiveRecord::Schema.define(version: 2021_08_19_160319) do create_table "annotations", id: :integer, force: :cascade do |t| t.integer "question_id" @@ -33,7 +33,6 @@ t.datetime "created_at" t.datetime "updated_at" t.integer "lock_version", default: 0 - t.string "label_id" t.index ["plan_id"], name: "fk_rails_84a6005a3e" t.index ["plan_id"], name: "index_answers_on_plan_id" t.index ["question_id"], name: "fk_rails_3d5ed4418f" @@ -45,6 +44,7 @@ t.integer "answer_id", null: false t.integer "question_option_id", null: false t.index ["answer_id"], name: "index_answers_question_options_on_answer_id" + t.index ["question_option_id"], name: "fk_rails_01ba00b569" end create_table "api_clients", id: :integer, force: :cascade do |t| @@ -52,14 +52,20 @@ t.string "description" t.string "homepage" t.string "contact_name" - t.string "contact_email", null: false + t.string "contact_email" t.string "client_id", null: false t.string "client_secret", null: false t.datetime "last_access" t.datetime "created_at", null: false t.datetime "updated_at", null: false t.integer "org_id" - t.index ["name"], name: "index_api_clients_on_name" + t.text "redirect_uri" + t.string "scopes", default: "", null: false + t.boolean "confidential", default: true + t.boolean "trusted", default: false + t.integer "callback_method" + t.string "callback_uri" + t.index ["name"], name: "index_oauth_applications_on_name" end create_table "conditions", id: :integer, force: :cascade do |t| @@ -84,6 +90,7 @@ t.datetime "created_at" t.datetime "updated_at" t.index ["email"], name: "index_contributors_on_email" + t.index ["name", "id", "org_id"], name: "index_contrib_id_and_org_id" t.index ["org_id"], name: "index_contributors_on_org_id" t.index ["plan_id"], name: "index_contributors_on_plan_id" t.index ["roles"], name: "index_contributors_on_roles" @@ -107,6 +114,21 @@ t.integer "phase_id" end + create_table "external_api_access_tokens", force: :cascade do |t| + t.bigint "user_id", null: false + t.string "external_service_name", null: false + t.string "access_token", null: false + t.string "refresh_token" + t.datetime "expires_at" + t.datetime "revoked_at" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["expires_at"], name: "index_external_api_access_tokens_on_expires_at" + t.index ["external_service_name"], name: "index_external_api_access_tokens_on_external_service_name" + t.index ["user_id", "external_service_name"], name: "index_external_tokens_on_user_and_service" + t.index ["user_id"], name: "index_external_api_access_tokens_on_user_id" + end + create_table "guidance_groups", id: :integer, force: :cascade do |t| t.string "name" t.integer "org_id" @@ -135,6 +157,7 @@ t.string "logo_url" t.string "identifier_prefix" t.integer "context" + t.string "external_service" end create_table "identifiers", id: :integer, force: :cascade do |t| @@ -157,6 +180,37 @@ t.boolean "default_language" end + create_table "licenses", force: :cascade do |t| + t.string "name", null: false + t.string "identifier", null: false + t.string "uri", null: false + t.boolean "osi_approved", default: false + t.boolean "deprecated", default: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["identifier", "osi_approved", "deprecated"], name: "index_license_on_identifier_and_criteria" + t.index ["identifier"], name: "index_licenses_on_identifier" + t.index ["uri"], name: "index_licenses_on_uri" + end + + create_table "metadata_standards", force: :cascade do |t| + t.string "title" + t.text "description" + t.string "rdamsc_id" + t.string "uri" + t.json "locations" + t.json "related_entities" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + + create_table "metadata_standards_research_outputs", force: :cascade do |t| + t.bigint "metadata_standard_id" + t.bigint "research_output_id" + t.index ["metadata_standard_id"], name: "metadata_research_outputs_on_metadata" + t.index ["research_output_id"], name: "metadata_research_outputs_on_ro" + end + create_table "notes", id: :integer, force: :cascade do |t| t.integer "user_id" t.text "text" @@ -191,6 +245,61 @@ t.boolean "enabled", default: true end + create_table "oauth_access_grants", force: :cascade do |t| + t.integer "resource_owner_id", null: false + t.integer "application_id", null: false + t.string "token", null: false + t.integer "expires_in", null: false + t.text "redirect_uri", null: false + t.datetime "created_at", null: false + t.datetime "revoked_at" + t.string "scopes", default: "", null: false + t.index ["application_id"], name: "fk_rails_b4b53e07b8" + t.index ["resource_owner_id"], name: "index_oauth_access_grants_on_resource_owner_id" + t.index ["token"], name: "index_oauth_access_grants_on_token", unique: true + end + + create_table "oauth_access_tokens", force: :cascade do |t| + t.integer "resource_owner_id" + t.integer "application_id", null: false + t.string "token", null: false + t.string "refresh_token" + t.integer "expires_in" + t.datetime "revoked_at" + t.datetime "created_at", null: false + t.string "scopes" + t.string "previous_refresh_token", default: "", null: false + t.index ["application_id"], name: "fk_rails_732cb83ab7" + t.index ["refresh_token"], name: "index_oauth_access_tokens_on_refresh_token", unique: true + t.index ["resource_owner_id"], name: "index_oauth_access_tokens_on_resource_owner_id" + t.index ["token"], name: "index_oauth_access_tokens_on_token", unique: true + end + + create_table "oauth_applications", id: :integer, force: :cascade do |t| + t.string "name", null: false + t.string "description" + t.string "homepage" + t.string "contact_name" + t.string "contact_email" + t.string "uid", null: false + t.string "secret", null: false + t.datetime "last_access" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.integer "org_id" + t.text "redirect_uri" + t.string "scopes", default: "", null: false + t.boolean "confidential", default: true + t.boolean "trusted", default: false + t.bigint "user_id" + t.string "logo_uid" + t.string "logo_name" + t.string "callback_uri" + t.integer "callback_method" + t.index ["name"], name: "index_oauth_applications_on_name" + t.index ["user_id"], name: "index_oauth_applications_on_user_id" + end + create_table "org_token_permissions", id: :integer, force: :cascade do |t| t.integer "org_id" t.integer "token_permission_type_id" @@ -220,6 +329,8 @@ t.text "feedback_email_msg" t.string "contact_name" t.boolean "managed", default: false, null: false + t.string "api_create_plan_email_subject" + t.text "api_create_plan_email_body" t.index ["language_id"], name: "fk_rails_5640112cab" t.index ["region_id"], name: "fk_rails_5a6adf6bab" end @@ -266,8 +377,8 @@ t.index ["funder_id"], name: "index_plans_on_funder_id" t.index ["grant_id"], name: "index_plans_on_grant_id" t.index ["org_id"], name: "index_plans_on_org_id" + t.index ["research_domain_id"], name: "index_plans_on_fos_id" t.index ["template_id"], name: "index_plans_on_template_id" - t.index ["research_domain_id"], name: "index_plans_on_research_domain_id" end create_table "plans_guidance_groups", id: :integer, force: :cascade do |t| @@ -342,6 +453,42 @@ t.integer "super_region_id" end + create_table "related_identifiers", force: :cascade do |t| + t.bigint "identifier_scheme_id" + t.integer "identifier_type", null: false + t.integer "relation_type", null: false + t.bigint "identifiable_id" + t.string "identifiable_type" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.string "value", null: false + t.index ["identifiable_id", "identifiable_type", "relation_type"], name: "index_relateds_on_identifiable_and_relation_type" + t.index ["identifier_scheme_id"], name: "index_related_identifiers_on_identifier_scheme_id" + t.index ["identifier_type"], name: "index_related_identifiers_on_identifier_type" + t.index ["relation_type"], name: "index_related_identifiers_on_relation_type" + end + + create_table "repositories", force: :cascade do |t| + t.string "name", null: false + t.text "description", null: false + t.string "homepage" + t.string "contact" + t.string "uri", null: false + t.json "info" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["homepage"], name: "index_repositories_on_homepage" + t.index ["name"], name: "index_repositories_on_name" + t.index ["uri"], name: "index_repositories_on_uri" + end + + create_table "repositories_research_outputs", force: :cascade do |t| + t.bigint "research_output_id" + t.bigint "repository_id" + t.index ["repository_id"], name: "index_repositories_research_outputs_on_repository_id" + t.index ["research_output_id"], name: "index_repositories_research_outputs_on_research_output_id" + end + create_table "research_domains", force: :cascade do |t| t.string "identifier", null: false t.string "label", null: false @@ -367,6 +514,8 @@ t.bigint "byte_size" t.datetime "created_at", null: false t.datetime "updated_at", null: false + t.bigint "license_id" + t.index ["license_id"], name: "index_research_outputs_on_license_id" t.index ["output_type"], name: "index_research_outputs_on_output_type" t.index ["plan_id"], name: "index_research_outputs_on_plan_id" end @@ -424,6 +573,19 @@ t.boolean "filtered", default: false end + create_table "subscriptions", force: :cascade do |t| + t.bigint "plan_id" + t.integer "subscription_types", null: false + t.string "callback_uri" + t.bigint "subscriber_id" + t.string "subscriber_type" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.datetime "last_notified" + t.index ["plan_id"], name: "index_subscriptions_on_plan_id" + t.index ["subscriber_id", "subscriber_type", "plan_id"], name: "index_subscribers_on_identifiable_and_plan_id" + end + create_table "templates", id: :integer, force: :cascade do |t| t.string "title" t.text "description" @@ -523,9 +685,13 @@ t.index ["user_id"], name: "index_users_perms_on_user_id" end + add_foreign_key "annotations", "orgs" + add_foreign_key "annotations", "questions" 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 "guidance_groups", "orgs" add_foreign_key "guidances", "guidance_groups" @@ -533,6 +699,10 @@ add_foreign_key "notes", "users" add_foreign_key "notification_acknowledgements", "notifications" add_foreign_key "notification_acknowledgements", "users" + add_foreign_key "oauth_access_grants", "oauth_applications", column: "application_id" + add_foreign_key "oauth_access_grants", "users", column: "resource_owner_id" + add_foreign_key "oauth_access_tokens", "oauth_applications", column: "application_id" + add_foreign_key "oauth_access_tokens", "users", column: "resource_owner_id" add_foreign_key "org_token_permissions", "orgs" add_foreign_key "org_token_permissions", "token_permission_types" add_foreign_key "orgs", "languages" @@ -545,6 +715,8 @@ add_foreign_key "question_options", "questions" add_foreign_key "questions", "question_formats" add_foreign_key "questions", "sections" + add_foreign_key "research_domains", "research_domains", column: "parent_id" + add_foreign_key "research_outputs", "licenses" add_foreign_key "roles", "plans" add_foreign_key "roles", "users" add_foreign_key "sections", "phases" diff --git a/lib/tasks/upgrade.rake b/lib/tasks/upgrade.rake index 051b9e3571..4674bf3251 100644 --- a/lib/tasks/upgrade.rake +++ b/lib/tasks/upgrade.rake @@ -1268,8 +1268,12 @@ namespace :upgrade do desc "explicitly set some column-defaults in the database" task column_defaults: :environment do Org.where(links: nil).update_all(links: { "org": [] }) - Org.where(feedback_email_subject: nil).update_all(feedback_email_subject: Org.feedback_confirmation_default_subject) - Org.where(feedback_email_msg: nil).update_all(feedback_email_msg: Org.feedback_confirmation_default_message) + if Org.respond_to?(:feedback_email_subject) + Org.where(feedback_email_subject: nil).update_all(feedback_email_subject: Org.feedback_confirmation_default_subject) + Org.where(feedback_email_msg: nil).update_all(feedback_email_msg: Org.feedback_confirmation_default_message) + else + Org.where(feedback_msg: nil).update_all(feedback_msg: Org.feedback_confirmation_default_message) + end Org.where(language_id: nil).update_all(language_id: Language.default&.id) end diff --git a/lib/tasks/v3.rake b/lib/tasks/v3.rake index 48bd85a7a4..f52555dc34 100644 --- a/lib/tasks/v3.rake +++ b/lib/tasks/v3.rake @@ -40,8 +40,12 @@ namespace :v3 do task ensure_feedback_defaults: :environment do include FeedbacksHelper - Org.where(feedback_email_subject: nil).update_all(feedback_email_subject: feedback_confirmation_default_subject) - Org.where(feedback_email_msg: nil).update_all(feedback_email_msg: feedback_confirmation_default_message) + if Org.respond_to?(:feedback_email_subject) + Org.where(feedback_email_subject: nil).update_all(feedback_email_subject: feedback_confirmation_default_subject) + Org.where(feedback_email_msg: nil).update_all(feedback_email_msg: feedback_confirmation_default_message) + else + Org.where(feedback_msg: nil).update_all(feedback_msg: feedback_confirmation_default_message) + end end # E.G. change 'https://api.crossref.org/funders/100000060' to 'https://doi.org/10.13039/100000060' diff --git a/spec/controllers/orgs_controller_spec.rb b/spec/controllers/orgs_controller_spec.rb index 669818e967..d070636928 100644 --- a/spec/controllers/orgs_controller_spec.rb +++ b/spec/controllers/orgs_controller_spec.rb @@ -32,7 +32,7 @@ funder: [true, false].sample, institution: [true, false].sample, managed: Faker::Number.within(range: 0..1).to_s, feedback_enabled: Faker::Boolean.boolean, - feedback_email_msg: Faker::Lorem.paragraph, + feedback_msg: Faker::Lorem.paragraph, org_id: org_selector_id_field(org: other_org), org_name: other_org.name, org_crosswalk: org_selector_crosswalk_field(org: other_org) } @link_args = org_links_field @@ -64,7 +64,7 @@ expect(flash[:notice].present?).to eql(true) @org.reload expect(@org.feedback_enabled).to eql(@args[:feedback_enabled]) - expect(@org.feedback_email_msg).to eql(@args[:feedback_email_msg]) + expect(@org.feedback_msg).to eql(@args[:feedback_msg]) end it "updates the shibboleth entityID if super_admin and enabled" do @args.delete(:feedback_enabled) diff --git a/spec/controllers/registrations_controller_spec.rb b/spec/controllers/registrations_controller_spec.rb index 281deef10b..6d277d2715 100644 --- a/spec/controllers/registrations_controller_spec.rb +++ b/spec/controllers/registrations_controller_spec.rb @@ -5,7 +5,7 @@ RSpec.describe RegistrationsController, type: :controller do before(:each) do - @org = create(:org, is_other: false) + @org = create(:org) @user = create(:user, org: @org) end diff --git a/spec/factories/answers.rb b/spec/factories/answers.rb index 53af066363..447c549bb1 100644 --- a/spec/factories/answers.rb +++ b/spec/factories/answers.rb @@ -9,7 +9,6 @@ # text :text # created_at :datetime # updated_at :datetime -# label_id :string(255) # plan_id :integer # question_id :integer # user_id :integer diff --git a/spec/factories/orgs.rb b/spec/factories/orgs.rb index c93f8ae0a0..2e4e7aa505 100644 --- a/spec/factories/orgs.rb +++ b/spec/factories/orgs.rb @@ -8,17 +8,14 @@ # abbreviation :string # contact_email :string # contact_name :string -# feedback_email_msg :text -# feedback_email_subject :string +# feedback_msg :text # feedback_enabled :boolean default(FALSE) -# is_other :boolean default(FALSE), not null # links :text # logo_name :string # logo_uid :string # managed :boolean default(FALSE), not null # name :string # org_type :integer default(0), not null -# sort_name :string # target_url :string # created_at :datetime not null # updated_at :datetime not null @@ -41,7 +38,6 @@ feedback_enabled { false } region { Region.first || create(:region) } language { Language.default } - is_other { false } contact_email { Faker::Internet.safe_email } contact_name { Faker::Name.name } managed { true } diff --git a/spec/factories/users.rb b/spec/factories/users.rb index 1a4ebe1748..e290268a46 100644 --- a/spec/factories/users.rb +++ b/spec/factories/users.rb @@ -25,7 +25,6 @@ # last_sign_in_ip :string # ldap_password :string # ldap_username :string -# other_organisation :string # recovery_email :string # remember_created_at :datetime # reset_password_sent_at :datetime diff --git a/spec/features/feedback_requests_spec.rb b/spec/features/feedback_requests_spec.rb index cd2fb0e35d..830375ac69 100644 --- a/spec/features/feedback_requests_spec.rb +++ b/spec/features/feedback_requests_spec.rb @@ -10,8 +10,7 @@ let!(:org) do create(:org, feedback_enabled: true, - feedback_email_subject: Faker::Lorem.sentence, - feedback_email_msg: Faker::Lorem.paragraph) + feedback_msg: Faker::Lorem.paragraph) end let!(:user) { create(:user, org: org) } diff --git a/spec/features/plans/exports_spec.rb b/spec/features/plans/exports_spec.rb index 16169cb70f..a79d3549de 100644 --- a/spec/features/plans/exports_spec.rb +++ b/spec/features/plans/exports_spec.rb @@ -5,7 +5,7 @@ RSpec.describe "PlansExports", type: :feature, js: true do let!(:template) { create(:template, phases: 2) } - let!(:org) { create(:org, managed: true, is_other: false) } + let!(:org) { create(:org, managed: true) } let!(:user) { create(:user, org: org) } let!(:plan) { create(:plan, template: template) } diff --git a/spec/models/org_spec.rb b/spec/models/org_spec.rb index 349e942aa6..69331806fa 100644 --- a/spec/models/org_spec.rb +++ b/spec/models/org_spec.rb @@ -16,10 +16,6 @@ it { is_expected.to validate_presence_of(:abbreviation) } - it { is_expected.to allow_values(true, false).for(:is_other) } - - it { is_expected.not_to allow_value(nil).for(:is_other) } - it { is_expected.to allow_values(0, 1).for(:managed) } it "validates presence of contact_email if feedback_enabled" do @@ -40,12 +36,6 @@ # validates :feedback_enabled, inclusion: { in: BOOLEAN_VALUES, # message: INCLUSION_MESSAGE } # - # validates :feedback_email_subject, presence: { message: PRESENCE_MESSAGE, - # if: :feedback_enabled } - # - # validates :feedback_email_msg, presence: { message: PRESENCE_MESSAGE, - # if: :feedback_enabled } - # end context "associations" do @@ -655,14 +645,12 @@ context "private methods" do describe ":merge_attributes!(to_be_merged:)" do before(:each) do - @org = create(:org, :organisation, is_other: false, managed: false, + @org = create(:org, :organisation, managed: false, feedback_enabled: false, contact_email: nil, - contact_name: nil, feedback_email_msg: nil, - feedback_email_subject: nil) + contact_name: nil, feedback_msg: nil) @to_be_merged = create(:org, :funder, templates: 1, plans: 2, managed: true, - feedback_enabled: true, is_other: true, - sort_name: Faker::Movies::StarWars.planet, + feedback_enabled: true, region: create(:region), language: create(:language)) end @@ -680,18 +668,15 @@ expect(org.contact_email).to eql(original.contact_email) expect(org.contact_name).to eql(original.contact_name) expect(org.feedback_enabled).to eql(original.feedback_enabled) - expect(org.feedback_email_msg).to eql(original.feedback_email_msg) - expect(org.feedback_email_subject).to eql(original.feedback_email_subject) + expect(org.feedback_msg).to eql(original.feedback_msg) end it "does not merge the attributes it should not merge" do original = @to_be_merged.dup org = @org.merge!(to_be_merged: @to_be_merged) expect(org.abbreviation).not_to eql(original.abbreviation) - expect(org.is_other).not_to eql(original.is_other) expect(org.name).not_to eql(original.name) expect(org.organisation?).to eql(true) expect(org.funder?).to eql(false) - expect(org.sort_name).not_to eql(original.sort_name) expect(org.region).not_to eql(original.region) expect(org.language).not_to eql(original.language) end diff --git a/spec/models/template_spec.rb b/spec/models/template_spec.rb index 7173d2e648..6e0ddc67b6 100644 --- a/spec/models/template_spec.rb +++ b/spec/models/template_spec.rb @@ -499,7 +499,7 @@ describe ".latest_customizable" do before do - create(:org, is_other: true) unless Org.where(is_other: true).any? + create(:org) create(:template, :default, :published) end diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index f0ee352712..fa7461fc28 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -296,7 +296,7 @@ it { is_expected.to eql(identifier) } end - context "when user has no user_identifier present" do + context "when user has no identifier" do it { is_expected.not_to eql("") } end end diff --git a/spec/presenters/super_admin/orgs/merge_presenter_spec.rb b/spec/presenters/super_admin/orgs/merge_presenter_spec.rb index ebc6491aa7..0d84541c22 100644 --- a/spec/presenters/super_admin/orgs/merge_presenter_spec.rb +++ b/spec/presenters/super_admin/orgs/merge_presenter_spec.rb @@ -5,15 +5,16 @@ RSpec.describe SuperAdmin::Orgs::MergePresenter do before(:each) do - @to_org = create(:org, :organisation, is_other: false, managed: false, + @to_org = create(:org, :organisation, managed: false, + abbreviation: Faker::Lorem.unique.word, feedback_enabled: false, contact_email: nil, - contact_name: nil, feedback_email_msg: nil, - links: { org: [] }, feedback_email_subject: nil) + contact_name: nil, feedback_msg: nil, + links: { org: [] }) @tpt = create(:token_permission_type) @from_org = create(:org, :funder, templates: 1, plans: 0, managed: true, - feedback_enabled: true, is_other: true, - sort_name: Faker::Movies::StarWars.planet, + feedback_enabled: true, + abbreviation: Faker::Lorem.unique.word, target_url: Faker::Internet.url, contact_name: Faker::Music::PearlJam.musician, contact_email: Faker::Internet.email, @@ -208,7 +209,7 @@ @expected = %i[target_url managed links contact_name contact_email logo_uid logo_name - feedback_enabled feedback_email_msg feedback_email_subject] + feedback_enabled feedback_msg] @results = @presenter.send(:org_attributes, org: @from_org) end it "returns an empty hash if :org is not an Org" do @@ -226,7 +227,7 @@ before(:each) do @expected = %i[target_url managed links contact_name contact_email - feedback_enabled feedback_email_msg feedback_email_subject] + feedback_enabled feedback_msg] @results = @presenter.send(:mergeable_columns) end it "includes the expected columns" do @@ -277,11 +278,8 @@ it "returns true for :feedback_enabled" do expect(@presenter.send(:mergeable_column?, column: :feedback_enabled)).to eql(true) end - it "returns true for :feedback_email_msg" do - expect(@presenter.send(:mergeable_column?, column: :feedback_email_msg)).to eql(true) - end - it "returns true for :feedback_email_subject" do - expect(@presenter.send(:mergeable_column?, column: :feedback_email_subject)).to eql(true) + it "returns true for :feedback_msg" do + expect(@presenter.send(:mergeable_column?, column: :feedback_msg)).to eql(true) end end end From f6f3511dd50d264faa677be4d37e01317a354182 Mon Sep 17 00:00:00 2001 From: briri Date: Thu, 19 Aug 2021 14:55:33 -0700 Subject: [PATCH 2/7] make rubocop happy again --- app/models/org.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/org.rb b/app/models/org.rb index a03b0b7853..24a61666c6 100644 --- a/app/models/org.rb +++ b/app/models/org.rb @@ -109,7 +109,7 @@ class Org < ApplicationRecord message: INCLUSION_MESSAGE } validates :feedback_msg, presence: { message: PRESENCE_MESSAGE, - if: :feedback_enabled } + if: :feedback_enabled } validates :managed, inclusion: { in: BOOLEAN_VALUES, message: INCLUSION_MESSAGE } From 4543fb95c31ac207e963b6643dc1ad5575984a5b Mon Sep 17 00:00:00 2001 From: briri Date: Tue, 24 Aug 2021 08:36:24 -0700 Subject: [PATCH 3/7] reverted changes to users.other_organization and orgs.is_other --- app/controllers/plans_controller.rb | 6 +- app/controllers/registrations_controller.rb | 4 +- .../super_admin/users_controller.rb | 3 +- app/models/user.rb | 3 +- .../org_selection/hash_to_org_service.rb | 1 + app/views/layouts/_header.html.erb | 2 +- app/views/plans/index.html.erb | 2 +- .../super_admin/api_clients/_form.html.erb | 2 +- db/migrate/20210819160319_db_cleanup_2021.rb | 4 +- db/schema.rb | 212 ++---------------- .../registrations_controller_spec.rb | 2 +- spec/factories/orgs.rb | 2 + spec/factories/users.rb | 3 +- spec/features/plans/exports_spec.rb | 2 +- spec/models/org_spec.rb | 6 + spec/models/template_spec.rb | 2 +- .../super_admin/orgs/merge_presenter_spec.rb | 4 +- 17 files changed, 50 insertions(+), 210 deletions(-) diff --git a/app/controllers/plans_controller.rb b/app/controllers/plans_controller.rb index 33a8327272..53874b74fc 100644 --- a/app/controllers/plans_controller.rb +++ b/app/controllers/plans_controller.rb @@ -15,11 +15,11 @@ class PlansController < ApplicationController def index authorize Plan @plans = Plan.includes(:roles, :org).active(current_user).page(1) - if current_user.org.managed? + if current_user.org.is_other? + @organisationally_or_publicly_visible = [] + else @organisationally_or_publicly_visible = Plan.organisationally_or_publicly_visible(current_user).page(1) - else - @organisationally_or_publicly_visible = [] end # TODO: Is this still used? We cannot switch this to use the :plan_params # strong params because any calls that do not include `plan` in the diff --git a/app/controllers/registrations_controller.rb b/app/controllers/registrations_controller.rb index c6c9614784..298525d6b1 100644 --- a/app/controllers/registrations_controller.rb +++ b/app/controllers/registrations_controller.rb @@ -9,7 +9,7 @@ def edit @prefs = @user.get_preferences(:email) @languages = Language.sorted_by_abbreviation @orgs = Org.order("name") - @other_organisations = Org.where(managed: false).pluck(:id) + @other_organisations = Org.where(is_other: true).pluck(:id) @identifier_schemes = IdentifierScheme.for_users.order(:name) @default_org = current_user.org @@ -141,7 +141,7 @@ def update @prefs = @user.get_preferences(:email) @orgs = Org.order("name") @default_org = current_user.org - @other_organisations = Org.where(managed: false).pluck(:id) + @other_organisations = Org.where(is_other: true).pluck(:id) @identifier_schemes = IdentifierScheme.for_users.order(:name) @languages = Language.sorted_by_abbreviation if params[:skip_personal_details] == "true" diff --git a/app/controllers/super_admin/users_controller.rb b/app/controllers/super_admin/users_controller.rb index 6bdacee6ba..933ac6e5c5 100644 --- a/app/controllers/super_admin/users_controller.rb +++ b/app/controllers/super_admin/users_controller.rb @@ -119,7 +119,8 @@ def user_params :surname, :org_id, :org_name, :org_crosswalk, :department_id, - :language_id) + :language_id, + :other_organisation) end def merge_accounts diff --git a/app/models/user.rb b/app/models/user.rb index 7a1f4e8457..f5995c996e 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -23,8 +23,7 @@ # invited_by_type :string # last_sign_in_at :datetime # last_sign_in_ip :string -# ldap_password :string -# ldap_username :string +# other_organisation :string # recovery_email :string # remember_created_at :datetime # reset_password_sent_at :datetime diff --git a/app/services/org_selection/hash_to_org_service.rb b/app/services/org_selection/hash_to_org_service.rb index f05aa44181..ef722429a1 100644 --- a/app/services/org_selection/hash_to_org_service.rb +++ b/app/services/org_selection/hash_to_org_service.rb @@ -95,6 +95,7 @@ def initialize_org(hash:) language: language_from_hash(hash: hash), target_url: hash[:url], institution: true, + is_other: false, abbreviation: abbreviation_from_hash(hash: hash) ) org diff --git a/app/views/layouts/_header.html.erb b/app/views/layouts/_header.html.erb index 088a2f38ea..293f92465e 100644 --- a/app/views/layouts/_header.html.erb +++ b/app/views/layouts/_header.html.erb @@ -3,7 +3,7 @@ <%= render partial: "layouts/navigation" %>
- <% if user_signed_in? && (!current_user.org.nil? || current_user.can_super_admin?) %> + <% if user_signed_in? && !current_user.org.nil? && (!current_user.org.is_other || current_user.can_super_admin?) %> <%= render partial: "layouts/branding" , locals: {max_number_links: Rails.configuration.x.max_number_links_funder} %> <% end %>
diff --git a/app/views/plans/index.html.erb b/app/views/plans/index.html.erb index 01e70d1272..2687edb611 100644 --- a/app/views/plans/index.html.erb +++ b/app/views/plans/index.html.erb @@ -31,7 +31,7 @@
- <% if @organisationally_or_publicly_visible.any? && current_user.org.managed? %> + <% if @organisationally_or_publicly_visible.any? && !current_user.org.is_other? %>

<%= _('%{org_title} Plans') % { :org_title => current_user.org.name } %>

<%= _('The table below lists the plans that users at your organisation have created and shared within your organisation. This allows you to download a PDF and view their plans as samples or to discover new research data.') %>

<%= paginable_renderise( diff --git a/app/views/super_admin/api_clients/_form.html.erb b/app/views/super_admin/api_clients/_form.html.erb index 9172349216..fbf48eeace 100644 --- a/app/views/super_admin/api_clients/_form.html.erb +++ b/app/views/super_admin/api_clients/_form.html.erb @@ -1,7 +1,7 @@ <% url = @api_client.new_record? ? super_admin_api_clients_path : super_admin_api_client_path(@api_client) method = @api_client.new_record? ? :post : :put -orgs = Org.all +orgs = Org.where(is_other: false) %> <%= form_for @api_client, url: url, method: method, diff --git a/db/migrate/20210819160319_db_cleanup_2021.rb b/db/migrate/20210819160319_db_cleanup_2021.rb index f062e7d93b..683d9efa08 100644 --- a/db/migrate/20210819160319_db_cleanup_2021.rb +++ b/db/migrate/20210819160319_db_cleanup_2021.rb @@ -4,16 +4,14 @@ def change remove_column(:answers, :label_id) if column_exists?(:answers, :label_id) remove_column(:orgs, :feedback_email_subject) if column_exists?(:orgs, :feedback_email_subject) - remove_column(:orgs, :is_other) if column_exists?(:orgs, :is_other) remove_column(:orgs, :sort_name) if column_exists?(:orgs, :sort_name) - remove column(:users, :other_organization) if column_exists?(:users, :other_organization) - # Rename the old feedbak email message since we no longer send an email, it's just # displayed on the page rename_column(:orgs, :feedback_email_msg, :feedback_msg) if column_exists?(:orgs, :feedback_email_msg) # Drop unused tables drop_table(:org_identifiers) if table_exists?(:org_identifiers) + drop_table(:user_identifiers) if table_exists?(:user_identifiers) end end diff --git a/db/schema.rb b/db/schema.rb index 796e62ebd6..85d59d7bd4 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -44,7 +44,6 @@ t.integer "answer_id", null: false t.integer "question_option_id", null: false t.index ["answer_id"], name: "index_answers_question_options_on_answer_id" - t.index ["question_option_id"], name: "fk_rails_01ba00b569" end create_table "api_clients", id: :integer, force: :cascade do |t| @@ -52,20 +51,14 @@ t.string "description" t.string "homepage" t.string "contact_name" - t.string "contact_email" + t.string "contact_email", null: false t.string "client_id", null: false t.string "client_secret", null: false t.datetime "last_access" t.datetime "created_at", null: false t.datetime "updated_at", null: false t.integer "org_id" - t.text "redirect_uri" - t.string "scopes", default: "", null: false - t.boolean "confidential", default: true - t.boolean "trusted", default: false - t.integer "callback_method" - t.string "callback_uri" - t.index ["name"], name: "index_oauth_applications_on_name" + t.index ["name"], name: "index_api_clients_on_name" end create_table "conditions", id: :integer, force: :cascade do |t| @@ -90,7 +83,6 @@ t.datetime "created_at" t.datetime "updated_at" t.index ["email"], name: "index_contributors_on_email" - t.index ["name", "id", "org_id"], name: "index_contrib_id_and_org_id" t.index ["org_id"], name: "index_contributors_on_org_id" t.index ["plan_id"], name: "index_contributors_on_plan_id" t.index ["roles"], name: "index_contributors_on_roles" @@ -114,21 +106,6 @@ t.integer "phase_id" end - create_table "external_api_access_tokens", force: :cascade do |t| - t.bigint "user_id", null: false - t.string "external_service_name", null: false - t.string "access_token", null: false - t.string "refresh_token" - t.datetime "expires_at" - t.datetime "revoked_at" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - t.index ["expires_at"], name: "index_external_api_access_tokens_on_expires_at" - t.index ["external_service_name"], name: "index_external_api_access_tokens_on_external_service_name" - t.index ["user_id", "external_service_name"], name: "index_external_tokens_on_user_and_service" - t.index ["user_id"], name: "index_external_api_access_tokens_on_user_id" - end - create_table "guidance_groups", id: :integer, force: :cascade do |t| t.string "name" t.integer "org_id" @@ -157,7 +134,6 @@ t.string "logo_url" t.string "identifier_prefix" t.integer "context" - t.string "external_service" end create_table "identifiers", id: :integer, force: :cascade do |t| @@ -180,35 +156,13 @@ t.boolean "default_language" end - create_table "licenses", force: :cascade do |t| - t.string "name", null: false - t.string "identifier", null: false - t.string "uri", null: false - t.boolean "osi_approved", default: false - t.boolean "deprecated", default: false - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - t.index ["identifier", "osi_approved", "deprecated"], name: "index_license_on_identifier_and_criteria" - t.index ["identifier"], name: "index_licenses_on_identifier" - t.index ["uri"], name: "index_licenses_on_uri" - end - - create_table "metadata_standards", force: :cascade do |t| - t.string "title" - t.text "description" - t.string "rdamsc_id" - t.string "uri" - t.json "locations" - t.json "related_entities" + create_table "mime_types", force: :cascade do |t| + t.string "description", null: false + t.string "category", null: false + t.string "value", null: false t.datetime "created_at", null: false t.datetime "updated_at", null: false - end - - create_table "metadata_standards_research_outputs", force: :cascade do |t| - t.bigint "metadata_standard_id" - t.bigint "research_output_id" - t.index ["metadata_standard_id"], name: "metadata_research_outputs_on_metadata" - t.index ["research_output_id"], name: "metadata_research_outputs_on_ro" + t.index ["value"], name: "index_mime_types_on_value" end create_table "notes", id: :integer, force: :cascade do |t| @@ -245,61 +199,6 @@ t.boolean "enabled", default: true end - create_table "oauth_access_grants", force: :cascade do |t| - t.integer "resource_owner_id", null: false - t.integer "application_id", null: false - t.string "token", null: false - t.integer "expires_in", null: false - t.text "redirect_uri", null: false - t.datetime "created_at", null: false - t.datetime "revoked_at" - t.string "scopes", default: "", null: false - t.index ["application_id"], name: "fk_rails_b4b53e07b8" - t.index ["resource_owner_id"], name: "index_oauth_access_grants_on_resource_owner_id" - t.index ["token"], name: "index_oauth_access_grants_on_token", unique: true - end - - create_table "oauth_access_tokens", force: :cascade do |t| - t.integer "resource_owner_id" - t.integer "application_id", null: false - t.string "token", null: false - t.string "refresh_token" - t.integer "expires_in" - t.datetime "revoked_at" - t.datetime "created_at", null: false - t.string "scopes" - t.string "previous_refresh_token", default: "", null: false - t.index ["application_id"], name: "fk_rails_732cb83ab7" - t.index ["refresh_token"], name: "index_oauth_access_tokens_on_refresh_token", unique: true - t.index ["resource_owner_id"], name: "index_oauth_access_tokens_on_resource_owner_id" - t.index ["token"], name: "index_oauth_access_tokens_on_token", unique: true - end - - create_table "oauth_applications", id: :integer, force: :cascade do |t| - t.string "name", null: false - t.string "description" - t.string "homepage" - t.string "contact_name" - t.string "contact_email" - t.string "uid", null: false - t.string "secret", null: false - t.datetime "last_access" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - t.integer "org_id" - t.text "redirect_uri" - t.string "scopes", default: "", null: false - t.boolean "confidential", default: true - t.boolean "trusted", default: false - t.bigint "user_id" - t.string "logo_uid" - t.string "logo_name" - t.string "callback_uri" - t.integer "callback_method" - t.index ["name"], name: "index_oauth_applications_on_name" - t.index ["user_id"], name: "index_oauth_applications_on_user_id" - end - create_table "org_token_permissions", id: :integer, force: :cascade do |t| t.integer "org_id" t.integer "token_permission_type_id" @@ -316,7 +215,6 @@ t.datetime "created_at", null: false t.datetime "updated_at", null: false t.boolean "is_other", default: false, null: false - t.string "sort_name" t.integer "region_id" t.integer "language_id" t.string "logo_uid" @@ -325,12 +223,9 @@ t.integer "org_type", default: 0, null: false t.text "links" t.boolean "feedback_enabled", default: false - t.string "feedback_email_subject" - t.text "feedback_email_msg" + t.text "feedback_msg" t.string "contact_name" t.boolean "managed", default: false, null: false - t.string "api_create_plan_email_subject" - t.text "api_create_plan_email_body" t.index ["language_id"], name: "fk_rails_5640112cab" t.index ["region_id"], name: "fk_rails_5a6adf6bab" end @@ -359,9 +254,18 @@ t.integer "template_id" t.datetime "created_at" t.datetime "updated_at" + t.string "grant_number" t.string "identifier" t.text "description" + t.string "principal_investigator" + t.string "principal_investigator_identifier" + t.string "data_contact" + t.string "funder_name" t.integer "visibility", default: 3, null: false + t.string "data_contact_email" + t.string "data_contact_phone" + t.string "principal_investigator_email" + t.string "principal_investigator_phone" t.boolean "feedback_requested", default: false t.boolean "complete", default: false t.integer "org_id" @@ -369,15 +273,10 @@ t.integer "grant_id" t.datetime "start_date" t.datetime "end_date" - t.boolean "ethical_issues" - t.text "ethical_issues_description" - t.string "ethical_issues_report" - t.integer "funding_status" - t.bigint "research_domain_id" + t.integer "api_client_id" t.index ["funder_id"], name: "index_plans_on_funder_id" t.index ["grant_id"], name: "index_plans_on_grant_id" t.index ["org_id"], name: "index_plans_on_org_id" - t.index ["research_domain_id"], name: "index_plans_on_fos_id" t.index ["template_id"], name: "index_plans_on_template_id" end @@ -453,51 +352,6 @@ t.integer "super_region_id" end - create_table "related_identifiers", force: :cascade do |t| - t.bigint "identifier_scheme_id" - t.integer "identifier_type", null: false - t.integer "relation_type", null: false - t.bigint "identifiable_id" - t.string "identifiable_type" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - t.string "value", null: false - t.index ["identifiable_id", "identifiable_type", "relation_type"], name: "index_relateds_on_identifiable_and_relation_type" - t.index ["identifier_scheme_id"], name: "index_related_identifiers_on_identifier_scheme_id" - t.index ["identifier_type"], name: "index_related_identifiers_on_identifier_type" - t.index ["relation_type"], name: "index_related_identifiers_on_relation_type" - end - - create_table "repositories", force: :cascade do |t| - t.string "name", null: false - t.text "description", null: false - t.string "homepage" - t.string "contact" - t.string "uri", null: false - t.json "info" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - t.index ["homepage"], name: "index_repositories_on_homepage" - t.index ["name"], name: "index_repositories_on_name" - t.index ["uri"], name: "index_repositories_on_uri" - end - - create_table "repositories_research_outputs", force: :cascade do |t| - t.bigint "research_output_id" - t.bigint "repository_id" - t.index ["repository_id"], name: "index_repositories_research_outputs_on_repository_id" - t.index ["research_output_id"], name: "index_repositories_research_outputs_on_research_output_id" - end - - create_table "research_domains", force: :cascade do |t| - t.string "identifier", null: false - t.string "label", null: false - t.bigint "parent_id" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - t.index ["parent_id"], name: "index_research_domains_on_parent_id" - end - create_table "research_outputs", force: :cascade do |t| t.integer "plan_id" t.integer "output_type", default: 3, null: false @@ -507,15 +361,18 @@ t.integer "display_order" t.boolean "is_default" t.text "description" + t.integer "mime_type_id" t.integer "access", default: 0, null: false t.datetime "release_date" t.boolean "personal_data" t.boolean "sensitive_data" t.bigint "byte_size" + t.text "mandatory_attribution" + t.datetime "coverage_start" + t.datetime "coverage_end" + t.string "coverage_region" t.datetime "created_at", null: false t.datetime "updated_at", null: false - t.bigint "license_id" - t.index ["license_id"], name: "index_research_outputs_on_license_id" t.index ["output_type"], name: "index_research_outputs_on_output_type" t.index ["plan_id"], name: "index_research_outputs_on_plan_id" end @@ -573,19 +430,6 @@ t.boolean "filtered", default: false end - create_table "subscriptions", force: :cascade do |t| - t.bigint "plan_id" - t.integer "subscription_types", null: false - t.string "callback_uri" - t.bigint "subscriber_id" - t.string "subscriber_type" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - t.datetime "last_notified" - t.index ["plan_id"], name: "index_subscriptions_on_plan_id" - t.index ["subscriber_id", "subscriber_type", "plan_id"], name: "index_subscribers_on_identifiable_and_plan_id" - end - create_table "templates", id: :integer, force: :cascade do |t| t.string "title" t.text "description" @@ -685,13 +529,9 @@ t.index ["user_id"], name: "index_users_perms_on_user_id" end - add_foreign_key "annotations", "orgs" - add_foreign_key "annotations", "questions" 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 "guidance_groups", "orgs" add_foreign_key "guidances", "guidance_groups" @@ -699,10 +539,6 @@ add_foreign_key "notes", "users" add_foreign_key "notification_acknowledgements", "notifications" add_foreign_key "notification_acknowledgements", "users" - add_foreign_key "oauth_access_grants", "oauth_applications", column: "application_id" - add_foreign_key "oauth_access_grants", "users", column: "resource_owner_id" - add_foreign_key "oauth_access_tokens", "oauth_applications", column: "application_id" - add_foreign_key "oauth_access_tokens", "users", column: "resource_owner_id" add_foreign_key "org_token_permissions", "orgs" add_foreign_key "org_token_permissions", "token_permission_types" add_foreign_key "orgs", "languages" @@ -715,8 +551,6 @@ add_foreign_key "question_options", "questions" add_foreign_key "questions", "question_formats" add_foreign_key "questions", "sections" - add_foreign_key "research_domains", "research_domains", column: "parent_id" - add_foreign_key "research_outputs", "licenses" add_foreign_key "roles", "plans" add_foreign_key "roles", "users" add_foreign_key "sections", "phases" diff --git a/spec/controllers/registrations_controller_spec.rb b/spec/controllers/registrations_controller_spec.rb index 6d277d2715..281deef10b 100644 --- a/spec/controllers/registrations_controller_spec.rb +++ b/spec/controllers/registrations_controller_spec.rb @@ -5,7 +5,7 @@ RSpec.describe RegistrationsController, type: :controller do before(:each) do - @org = create(:org) + @org = create(:org, is_other: false) @user = create(:user, org: @org) end diff --git a/spec/factories/orgs.rb b/spec/factories/orgs.rb index 2e4e7aa505..d027fb561b 100644 --- a/spec/factories/orgs.rb +++ b/spec/factories/orgs.rb @@ -10,6 +10,7 @@ # contact_name :string # feedback_msg :text # feedback_enabled :boolean default(FALSE) +# is_other :boolean default(FALSE), not null # links :text # logo_name :string # logo_uid :string @@ -40,6 +41,7 @@ language { Language.default } contact_email { Faker::Internet.safe_email } contact_name { Faker::Name.name } + is_other { false } managed { true } trait :institution do institution { true } diff --git a/spec/factories/users.rb b/spec/factories/users.rb index e290268a46..4d4ff58807 100644 --- a/spec/factories/users.rb +++ b/spec/factories/users.rb @@ -23,8 +23,7 @@ # invited_by_type :string # last_sign_in_at :datetime # last_sign_in_ip :string -# ldap_password :string -# ldap_username :string +# other_organisation :string # recovery_email :string # remember_created_at :datetime # reset_password_sent_at :datetime diff --git a/spec/features/plans/exports_spec.rb b/spec/features/plans/exports_spec.rb index a79d3549de..16169cb70f 100644 --- a/spec/features/plans/exports_spec.rb +++ b/spec/features/plans/exports_spec.rb @@ -5,7 +5,7 @@ RSpec.describe "PlansExports", type: :feature, js: true do let!(:template) { create(:template, phases: 2) } - let!(:org) { create(:org, managed: true) } + let!(:org) { create(:org, managed: true, is_other: false) } let!(:user) { create(:user, org: org) } let!(:plan) { create(:plan, template: template) } diff --git a/spec/models/org_spec.rb b/spec/models/org_spec.rb index 69331806fa..cd2a5546f1 100644 --- a/spec/models/org_spec.rb +++ b/spec/models/org_spec.rb @@ -16,6 +16,10 @@ it { is_expected.to validate_presence_of(:abbreviation) } + it { is_expected.to allow_values(true, false).for(:is_other) } + + it { is_expected.not_to allow_value(nil).for(:is_other) } + it { is_expected.to allow_values(0, 1).for(:managed) } it "validates presence of contact_email if feedback_enabled" do @@ -651,6 +655,7 @@ @to_be_merged = create(:org, :funder, templates: 1, plans: 2, managed: true, feedback_enabled: true, + is_other: false, region: create(:region), language: create(:language)) end @@ -674,6 +679,7 @@ original = @to_be_merged.dup org = @org.merge!(to_be_merged: @to_be_merged) expect(org.abbreviation).not_to eql(original.abbreviation) + expect(org.is_other).not_to eql(original.is_other) expect(org.name).not_to eql(original.name) expect(org.organisation?).to eql(true) expect(org.funder?).to eql(false) diff --git a/spec/models/template_spec.rb b/spec/models/template_spec.rb index 6e0ddc67b6..7173d2e648 100644 --- a/spec/models/template_spec.rb +++ b/spec/models/template_spec.rb @@ -499,7 +499,7 @@ describe ".latest_customizable" do before do - create(:org) + create(:org, is_other: true) unless Org.where(is_other: true).any? create(:template, :default, :published) end diff --git a/spec/presenters/super_admin/orgs/merge_presenter_spec.rb b/spec/presenters/super_admin/orgs/merge_presenter_spec.rb index 0d84541c22..be130e9933 100644 --- a/spec/presenters/super_admin/orgs/merge_presenter_spec.rb +++ b/spec/presenters/super_admin/orgs/merge_presenter_spec.rb @@ -5,7 +5,7 @@ RSpec.describe SuperAdmin::Orgs::MergePresenter do before(:each) do - @to_org = create(:org, :organisation, managed: false, + @to_org = create(:org, :organisation, is_other: false, managed: false, abbreviation: Faker::Lorem.unique.word, feedback_enabled: false, contact_email: nil, contact_name: nil, feedback_msg: nil, @@ -13,7 +13,7 @@ @tpt = create(:token_permission_type) @from_org = create(:org, :funder, templates: 1, plans: 0, managed: true, - feedback_enabled: true, + feedback_enabled: true, is_other: true, abbreviation: Faker::Lorem.unique.word, target_url: Faker::Internet.url, contact_name: Faker::Music::PearlJam.musician, From 32d02ba6907b54f57a26053925b696f6e917733c Mon Sep 17 00:00:00 2001 From: briri Date: Tue, 24 Aug 2021 08:50:40 -0700 Subject: [PATCH 4/7] fixed issue with db schema --- db/schema.rb | 39 +++++++++++++++------------------------ 1 file changed, 15 insertions(+), 24 deletions(-) diff --git a/db/schema.rb b/db/schema.rb index 85d59d7bd4..ab5a3608e3 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -156,15 +156,6 @@ t.boolean "default_language" end - create_table "mime_types", force: :cascade do |t| - t.string "description", null: false - t.string "category", null: false - t.string "value", null: false - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - t.index ["value"], name: "index_mime_types_on_value" - end - create_table "notes", id: :integer, force: :cascade do |t| t.integer "user_id" t.text "text" @@ -254,18 +245,9 @@ t.integer "template_id" t.datetime "created_at" t.datetime "updated_at" - t.string "grant_number" t.string "identifier" t.text "description" - t.string "principal_investigator" - t.string "principal_investigator_identifier" - t.string "data_contact" - t.string "funder_name" t.integer "visibility", default: 3, null: false - t.string "data_contact_email" - t.string "data_contact_phone" - t.string "principal_investigator_email" - t.string "principal_investigator_phone" t.boolean "feedback_requested", default: false t.boolean "complete", default: false t.integer "org_id" @@ -273,11 +255,16 @@ t.integer "grant_id" t.datetime "start_date" t.datetime "end_date" - t.integer "api_client_id" + t.boolean "ethical_issues" + t.text "ethical_issues_description" + t.string "ethical_issues_report" + t.integer "funding_status" + t.bigint "research_domain_id" t.index ["funder_id"], name: "index_plans_on_funder_id" t.index ["grant_id"], name: "index_plans_on_grant_id" t.index ["org_id"], name: "index_plans_on_org_id" t.index ["template_id"], name: "index_plans_on_template_id" + t.index ["research_domain_id"], name: "index_plans_on_research_domain_id" end create_table "plans_guidance_groups", id: :integer, force: :cascade do |t| @@ -352,6 +339,15 @@ t.integer "super_region_id" end + create_table "research_domains", force: :cascade do |t| + t.string "identifier", null: false + t.string "label", null: false + t.bigint "parent_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["parent_id"], name: "index_research_domains_on_parent_id" + end + create_table "research_outputs", force: :cascade do |t| t.integer "plan_id" t.integer "output_type", default: 3, null: false @@ -361,16 +357,11 @@ t.integer "display_order" t.boolean "is_default" t.text "description" - t.integer "mime_type_id" t.integer "access", default: 0, null: false t.datetime "release_date" t.boolean "personal_data" t.boolean "sensitive_data" t.bigint "byte_size" - t.text "mandatory_attribution" - t.datetime "coverage_start" - t.datetime "coverage_end" - t.string "coverage_region" t.datetime "created_at", null: false t.datetime "updated_at", null: false t.index ["output_type"], name: "index_research_outputs_on_output_type" From 646cb7bbd17630aae1e5cf85e0f6ce72a685ce5f Mon Sep 17 00:00:00 2001 From: briri Date: Tue, 24 Aug 2021 10:59:03 -0700 Subject: [PATCH 5/7] fixed issue with reverting to is_other --- app/models/org.rb | 3 +++ spec/factories/orgs.rb | 2 +- spec/models/org_spec.rb | 5 ++--- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/app/models/org.rb b/app/models/org.rb index 24a61666c6..6c674d99a8 100644 --- a/app/models/org.rb +++ b/app/models/org.rb @@ -94,6 +94,9 @@ class Org < ApplicationRecord validates :abbreviation, presence: { message: PRESENCE_MESSAGE } + validates :is_other, presence: { in: BOOLEAN_VALUES, + message: PRESENCE_MESSAGE } + validates :language, presence: { message: PRESENCE_MESSAGE } validates :contact_name, presence: { message: PRESENCE_MESSAGE, diff --git a/spec/factories/orgs.rb b/spec/factories/orgs.rb index d027fb561b..d8ac259607 100644 --- a/spec/factories/orgs.rb +++ b/spec/factories/orgs.rb @@ -39,9 +39,9 @@ feedback_enabled { false } region { Region.first || create(:region) } language { Language.default } + is_other { false } contact_email { Faker::Internet.safe_email } contact_name { Faker::Name.name } - is_other { false } managed { true } trait :institution do institution { true } diff --git a/spec/models/org_spec.rb b/spec/models/org_spec.rb index cd2a5546f1..d6899d7632 100644 --- a/spec/models/org_spec.rb +++ b/spec/models/org_spec.rb @@ -649,13 +649,13 @@ context "private methods" do describe ":merge_attributes!(to_be_merged:)" do before(:each) do - @org = create(:org, :organisation, managed: false, + @org = create(:org, :organisation,is_other: false, managed: false, feedback_enabled: false, contact_email: nil, contact_name: nil, feedback_msg: nil) @to_be_merged = create(:org, :funder, templates: 1, plans: 2, managed: true, feedback_enabled: true, - is_other: false, + is_other: true, region: create(:region), language: create(:language)) end @@ -679,7 +679,6 @@ original = @to_be_merged.dup org = @org.merge!(to_be_merged: @to_be_merged) expect(org.abbreviation).not_to eql(original.abbreviation) - expect(org.is_other).not_to eql(original.is_other) expect(org.name).not_to eql(original.name) expect(org.organisation?).to eql(true) expect(org.funder?).to eql(false) From 345f66ac5f957300568b70a1d8151ed36358ec43 Mon Sep 17 00:00:00 2001 From: briri Date: Tue, 24 Aug 2021 11:00:35 -0700 Subject: [PATCH 6/7] fixed issue with reverting to is_other --- app/models/org.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/models/org.rb b/app/models/org.rb index 6c674d99a8..368884b969 100644 --- a/app/models/org.rb +++ b/app/models/org.rb @@ -10,6 +10,7 @@ # contact_name :string # feedback_msg :text # feedback_enabled :boolean default(FALSE) +# is_other :boolean default(FALSE), not null # links :text # logo_name :string # logo_uid :string @@ -94,7 +95,7 @@ class Org < ApplicationRecord validates :abbreviation, presence: { message: PRESENCE_MESSAGE } - validates :is_other, presence: { in: BOOLEAN_VALUES, + validates :is_other, inclusion: { in: BOOLEAN_VALUES, message: PRESENCE_MESSAGE } validates :language, presence: { message: PRESENCE_MESSAGE } From d2be8c9a69ba24f02ebfdf26eb8b037279de54c1 Mon Sep 17 00:00:00 2001 From: briri Date: Tue, 24 Aug 2021 13:00:39 -0700 Subject: [PATCH 7/7] rubocop :/ --- app/models/org.rb | 2 +- spec/models/org_spec.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/org.rb b/app/models/org.rb index 368884b969..de2526de38 100644 --- a/app/models/org.rb +++ b/app/models/org.rb @@ -96,7 +96,7 @@ class Org < ApplicationRecord validates :abbreviation, presence: { message: PRESENCE_MESSAGE } validates :is_other, inclusion: { in: BOOLEAN_VALUES, - message: PRESENCE_MESSAGE } + message: PRESENCE_MESSAGE } validates :language, presence: { message: PRESENCE_MESSAGE } diff --git a/spec/models/org_spec.rb b/spec/models/org_spec.rb index d6899d7632..f22eb20722 100644 --- a/spec/models/org_spec.rb +++ b/spec/models/org_spec.rb @@ -649,7 +649,7 @@ context "private methods" do describe ":merge_attributes!(to_be_merged:)" do before(:each) do - @org = create(:org, :organisation,is_other: false, managed: false, + @org = create(:org, :organisation, is_other: false, managed: false, feedback_enabled: false, contact_email: nil, contact_name: nil, feedback_msg: nil)