Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Small improvements #154

Merged
merged 1 commit into from
Dec 19, 2022
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
4 changes: 2 additions & 2 deletions app/controllers/folio/users/registrations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class Folio::Users::RegistrationsController < Devise::RegistrationsController
include Folio::Users::DeviseControllerBase

def new
fail ActionController::MethodNotAllowed, ""
fail ActionController::MethodNotAllowed, "Registrations are created by inviting user, not directly"
end

def edit
Expand All @@ -20,7 +20,7 @@ def edit
end

def create
fail ActionController::MethodNotAllowed, ""
fail ActionController::MethodNotAllowed, "Registrations are created by inviting user, not directly"

build_resource(sign_up_params)

Expand Down
2 changes: 2 additions & 0 deletions app/models/concerns/folio/belongs_to_site.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ module Folio::BelongsToSite
validate :validate_belongs_to_site

scope :by_atom_setting_site_id, -> (site_id) { where(site_id:) }
scope :by_site, ->(site) { where(site:) }
scope :by_site_id, ->(site_id) { where(site_id:) }
end

class_methods do
Expand Down
7 changes: 7 additions & 0 deletions app/models/folio/site.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,13 @@ def layout_twitter_meta
}
end

def <=>(other)
res = self.title <=> other.title
return res unless res.zero?

self.id <=> other.id
end

def console_form_tabs_base
%i[
header_message
Expand Down
7 changes: 7 additions & 0 deletions app/models/folio/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,13 @@ def to_console_label
end
end

def <=>(other)
res = self.full_name <=> other.full_name
return res unless res.zero?

self.id <=> other.id
end

def remember_me
super.nil? ? "1" : super
end
Expand Down
2 changes: 1 addition & 1 deletion lib/folio.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def self.current_site(request: nil)
if Rails.application.config.folio_site_is_a_singleton
Folio::Site.instance
else
fail "You must implement this yourself"
fail "You must implement :current_site yourself"
end
end

Expand Down
4 changes: 2 additions & 2 deletions lib/folio/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ class Engine < ::Rails::Engine
end

initializer :append_migrations do |app|
unless app.root.to_s.include? root.to_s
unless app.root.to_s.include?(root.to_s + "/")
config.paths["db/migrate"].expanded.each do |expanded_path|
app.config.paths["db/migrate"] << expanded_path
end
Expand All @@ -124,7 +124,7 @@ class Engine < ::Rails::Engine
deprecations << "Missing index_folio_pages_on_by_query index on folio_pages. That is probably caused by using traco title_* attributes. Add a custom one."
end

if !Rails.env.test? && ActiveRecord::Base.connection.exec_query("SELECT id FROM folio_email_templates LIMIT 1;").rows.size == 0
if !Rails.env.test? && ActiveRecord::Base.connection.exec_query("SELECT id FROM folio_email_templates WHERE mailer ='Folio::DeviseMailer' LIMIT 1;").rows.size == 0
mreq marked this conversation as resolved.
Show resolved Hide resolved
deprecations << "There are no email templates present. Seed them via rake folio:email_templates:idp_seed"
end
rescue ActiveRecord::NoDatabaseError, ActiveRecord::ConnectionNotEstablished, ActiveRecord::StatementInvalid
Expand Down