Skip to content

Commit

Permalink
integrated sendgrid and scholars cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
biwek committed Dec 7, 2020
1 parent 5fcc983 commit 9486bdf
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 6 deletions.
1 change: 1 addition & 0 deletions app/controllers/scholars_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ def scholars_scope
.preload(:organisation,
:web_urls,
:created_by,
:scholar_transitions,
discipline: :self_and_ancestors)
.order(updated_at: :desc)
.page(params[:page])
Expand Down
2 changes: 1 addition & 1 deletion app/views/scholars/_scholar.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<%= link_to web_url.title, web_url.url, target: "_blank" %>
<% end %>
</div>
<% if policy(scholar).update? %>
<% if current_user_is_admin %>
<div class="my-1 small">
Added by: <%= scholar.created_by&.email %>
</div>
Expand Down
3 changes: 2 additions & 1 deletion app/views/scholars/_scholars.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@
<% end %>

<div class="row">
<%= render scholars.shuffle %>
<%= render partial: "scholar", collection: scholars.shuffle,
locals: {current_user_is_admin: policy(Scholar).update?} %>
</div>
2 changes: 1 addition & 1 deletion app/views/scholars/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<%= render "search" %>

<% if current_user %>
<% if policy(Scholar).update? %>
<ul class="nav nav-tabs my-3">
<li class="nav-item">
<%= link_to t(".nav.approved"), scholars_path, class: "nav-link #{scholar_subnav_active(:approved)}" %>
Expand Down
3 changes: 3 additions & 0 deletions config/environments/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@
# Set this to true and configure the email server for immediate delivery to raise delivery errors.
# config.action_mailer.raise_delivery_errors = false

config.action_mailer.delivery_method = :smtp
config.action_mailer.default_url_options = {host: "https://abhinavnepal.com"}

# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
# the I18n.default_locale when a translation cannot be found).
config.i18n.fallbacks = true
Expand Down
12 changes: 12 additions & 0 deletions config/initializers/sendgrid.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# use mailcatcher to test locally
if ENV["STAGE"] == "prod"
ActionMailer::Base.smtp_settings = {
user_name: "apikey",
password: ENV["SENDGRID_API_KEY"],
domain: "abhinavnepal.com",
address: "smtp.sendgrid.net",
port: 587,
authentication: :plain,
enable_starttls_auto: true
}
end
2 changes: 1 addition & 1 deletion config/initializers/sidekiq.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
shared_config = {
url: ENV['JOB_WORKER_URL'],
url: ENV["JOB_WORKER_URL"],
namespace: "sidekiq:abhinavnepal:#{ENV['STAGE'] || 'dev'}"
}

Expand Down
6 changes: 4 additions & 2 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
require "sidekiq-scheduler/web"

Rails.application.routes.draw do
mount Sidekiq::Web => "/sidekiq"

devise_for :users
root "scholars#index"

Expand All @@ -15,4 +13,8 @@
# pages
get "about" => "pages#about"
get "privacy" => "pages#privacy"

authenticate :user, ->(u) { u.has_role? :admin } do
mount Sidekiq::Web => "/sidekiq"
end
end

0 comments on commit 9486bdf

Please sign in to comment.