Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/controllers/feedback_requests_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion app/controllers/orgs_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 1 addition & 3 deletions app/controllers/super_admin/orgs_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion app/controllers/template_options_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions app/javascript/src/orgs/adminEdit.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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) {
Expand Down
17 changes: 0 additions & 17 deletions app/mailers/user_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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?

Expand Down
1 change: 0 additions & 1 deletion app/models/answer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
# text :text
# created_at :datetime
# updated_at :datetime
# label_id :string
# plan_id :integer
# question_id :integer
# user_id :integer
Expand Down
27 changes: 8 additions & 19 deletions app/models/org.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@
# 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
# is_other :boolean default(FALSE), not null
# links :text
# logo_name :string
# logo_uid :string
Expand Down Expand Up @@ -42,14 +41,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": [] }

Expand Down Expand Up @@ -101,7 +96,7 @@ class Org < ApplicationRecord
validates :abbreviation, presence: { message: PRESENCE_MESSAGE }

validates :is_other, inclusion: { in: BOOLEAN_VALUES,
message: INCLUSION_MESSAGE }
message: PRESENCE_MESSAGE }

validates :language, presence: { message: PRESENCE_MESSAGE }

Expand All @@ -117,11 +112,8 @@ 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,
if: :feedback_enabled }
validates :feedback_msg, presence: { message: PRESENCE_MESSAGE,
if: :feedback_enabled }

validates :managed, inclusion: { in: BOOLEAN_VALUES,
message: INCLUSION_MESSAGE }
Expand Down Expand Up @@ -372,10 +364,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

Expand Down
59 changes: 0 additions & 59 deletions app/models/org_identifier.rb

This file was deleted.

4 changes: 1 addition & 3 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +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
# other_organisation :string
# recovery_email :string
# remember_created_at :datetime
# reset_password_sent_at :datetime
Expand Down
44 changes: 0 additions & 44 deletions app/models/user_identifier.rb

This file was deleted.

2 changes: 0 additions & 2 deletions app/policies/identifier_policy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

class IdentifierPolicy < ApplicationPolicy

attr_reader :user_identifier

def initialize(user, users)
raise Pundit::NotAuthorizedError, "must be logged in" unless user

Expand Down
2 changes: 0 additions & 2 deletions app/presenters/org_selection_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand All @@ -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
Expand Down
6 changes: 2 additions & 4 deletions app/presenters/super_admin/orgs/merge_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion app/services/org_selection/hash_to_org_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion app/services/org_selection/org_to_hash_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions app/views/orgs/_feedback_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
</h3>
<div class="row">
<div class="form-group col-xs-8" data-html="true">
<%= 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 %>
</div>
<div class="form-group col-xs-4">
Expand Down
2 changes: 1 addition & 1 deletion app/views/plans/_request_feedback_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<h2><%= _('Request expert feedback') %></h2>
<p><%= _("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.") %></p>
<div class="well well-sm">
<%= 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 } %>
</div>
<p><%= _('You can continue to edit and download the plan in the interim.') %></p>
<div class="form-group col-xs-8">
Expand Down
1 change: 0 additions & 1 deletion app/views/user_mailer/feedback_confirmation.html.erb

This file was deleted.

17 changes: 17 additions & 0 deletions db/migrate/20210819160319_db_cleanup_2021.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
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, :sort_name) if column_exists?(:orgs, :sort_name)

# 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
Loading