Skip to content

Commit

Permalink
1. remove cruft. 2. js string fix. 3. add kaminari to gemfile -- this…
Browse files Browse the repository at this point in the history
… will replace will_paginate

JS fix, cleanup.

Clean up vestiges of 'protect_simple_description', which was removed. Add tests and solidify models (add associations, etc.).

abstract 'Internet ID' to configurable string. Cleanup, readme.

Don't introduce Kaminari -- will_paginate is in maintenance mode, but elastic-search rails still uses it internally so stick with it for now. Change a couple uses of 'paginate()' on ES-backed models to 'page()' from the elasticsearch-rails interface.
  • Loading branch information
machinehum committed Oct 31, 2023
1 parent 6377591 commit 56cff4b
Show file tree
Hide file tree
Showing 41 changed files with 153 additions and 347 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ RUN apt-get update -qq && apt-get install -y \
RUN mkdir /app
WORKDIR /app
COPY Gemfile /app/Gemfile
#COPY Gemfile.lock /app/Gemfile.lock
COPY Gemfile.lock /app/Gemfile.lock
RUN bundle install
COPY . /app

Expand Down
4 changes: 2 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ GEM
multi_xml (0.6.0)
multipart-post (2.3.0)
mutex_m (0.1.2)
net-imap (0.4.2)
net-imap (0.4.3)
date
net-protocol
net-ldap (0.18.0)
Expand Down Expand Up @@ -282,7 +282,7 @@ GEM
rake (>= 12.2)
thor (~> 1.0, >= 1.2.2)
zeitwerk (~> 2.6)
rake (13.0.6)
rake (13.1.0)
rb-fsevent (0.11.2)
rb-inotify (0.10.1)
ffi (~> 1.0)
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ Contact the StudyFinder team at studyfinder@umn.edu if you:
- Have any questions about StudyFinder, or
- Want to learn more about updates or enhancements of the tool.

## Upgrade notes for 2.1

The main page carousel/video feature was an accessibility and usability issue, and has been replaced with a three-wide panel of "featured studies". These can be configured in the admin panel, where the carousel configuration formerly was.

## Development

The easiest way to get started with a development environment is to use `docker-compose`:
Expand Down
2 changes: 1 addition & 1 deletion app/assets/javascripts/views/modals.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ $('#contact-study-team-modal').on('show.bs.modal', function (event) {
var trialId = button.data('trial-id');
var modal = $(this);
// pass some trial attributes from the search results into the modal
modal.find('.study-email').text(studyEmail).attr('href', 'mailto:' + studyEmail + "?bcc=sfinder+study-team-emails@umn.edu");
modal.find('.study-email').text(studyEmail).attr('href', 'mailto:' + studyEmail + "?bcc=" + STUDY_CONTACT_BCC);
modal.find('#contact-study-team-modal-submit').data('trial_id', trialId).data('button', button);

if(window.studyTeamWidget !== undefined) {
Expand Down
8 changes: 4 additions & 4 deletions app/controllers/admin/trials_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,12 @@ def recent_as

def index
if params[:q].blank?
@trials = Trial.includes(:trial_interventions, :conditions).paginate(page: params[:page]).where(visible: true)
@trials = Trial.includes(:trial_interventions, :conditions).page(page_param).where(visible: true)
if SystemInfo.trial_approval
@trials = @trials.where(approved: true)
end
else
@trials = Trial.includes(:trial_interventions, :conditions).match_all_admin({ q: params[:q].downcase }).page(params[:page]).records
@trials = Trial.includes(:trial_interventions, :conditions).match_all_admin({ q: params[:q].downcase }).page(page_param).records
end

add_breadcrumb 'Trials Administration'
Expand Down Expand Up @@ -114,9 +114,9 @@ def update

def all_under_review
if params[:q].blank?
@trials = Trial.includes(:trial_locations).paginate(page: params[:page]).where(approved: false).where(visible: true).order(created_at: :desc)
@trials = Trial.includes(:trial_locations).page(page_param).where(approved: false).where(visible: true).order(created_at: :desc)
else
@trials = Trial.includes(:trial_locations).match_all_under_review_admin({ q: params[:q].downcase }).page(params[:page]).records
@trials = Trial.includes(:trial_locations).match_all_under_review_admin({ q: params[:q].downcase }).page(page_param).records
end

add_breadcrumb 'Trials Administration', :admin_trials_path
Expand Down
4 changes: 4 additions & 0 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ def authorize_researcher
end
helper_method :authorize_researcher

def page_param
params[:page].to_i > 0 ? params[:page].to_i : 1
end

private
def system
@system_info = SystemInfo.current
Expand Down
5 changes: 4 additions & 1 deletion app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@ def highlight(record, key)
else
record['_source'][key]
end

end

def username_string
ENV['username_string']
end

end
6 changes: 3 additions & 3 deletions app/lib/modules/ldap.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ class Ldap

###################
# 1. Authenicate with our departmental LDAP account
# 2. If successful, look up the user by x500 in LDAP
# 2. If successful, look up the user by username in LDAP
# 3. If found, authenticate with their LDAP username string and the password they entered into our login form
# 4. If successful, check if the user exists in Study Finder
# 5. If not found, create them
# 6. If found, log them into the Study Finder
###################

def authenticate(x500, password)
def authenticate(username, password)
# initialize our return hash with some defaults
_return = Hash.new
_return[:ldap_user] = nil
Expand All @@ -35,7 +35,7 @@ def authenticate(x500, password)
if departmental_ldap.bind

# now search for the user logging in
filter = Net::LDAP::Filter.eq( "uid", x500 ) # is this correct?
filter = Net::LDAP::Filter.eq( "uid", username ) # is this correct?
user_search = departmental_ldap.search( base: ENV['base'], filter: filter ).first

# departmental_ldap.search( :base => ENV['base'], :filter => filter ) do |entry|
Expand Down
3 changes: 3 additions & 0 deletions app/models/subgroup.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
class Subgroup < ApplicationRecord
self.table_name = 'study_finder_subgroups'

belongs_to :group, optional: true
has_many :trial_subgroups
has_many :trials, through: :trial_subgroups

validates_presence_of :name

Expand Down
8 changes: 8 additions & 0 deletions app/models/system_info.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,12 @@ def self.ga_version
self.first.try(:google_analytics_version)
end

def self.default_email
self.first.try(:default_email)
end

def self.study_contact_bcc
self.first.try(:study_contact_bcc)
end

end
9 changes: 4 additions & 5 deletions app/models/trial.rb
Original file line number Diff line number Diff line change
Expand Up @@ -564,11 +564,10 @@ def self.filters(search)
end

if search.has_key?('category')
ret << { term: { category_ids: search[:category] } }
ret << { term: { category_ids: search['category'] } }
end

if search.has_key?('subcat')
ret << { term: { subcategory_ids: search[:subcat] } }
ret << { term: { subcategory_ids: search['subcat'] } }
end

if (search.has_key?('gender')) and (search[:gender] == 'Male' or search[:gender] == 'Female')
Expand Down Expand Up @@ -603,11 +602,11 @@ def self.range_filters(search)
end

if search.has_key?('adults')
ret << { range: { max_age: { gte: 19 } } }
ret << { range: { max_age: { gte: 18 } } }
end

if search.has_key?('seniors')
ret << { range: { max_age: { gte: 66 } } }
ret << { range: { max_age: { gte: 65 } } }
end

ret
Expand Down
2 changes: 1 addition & 1 deletion app/views/admin/approvals/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

<table class="table table-bordered table-trials">
<tr>
<th>Internet ID</th>
<th><%= username_string %></th>
<th>Trial System ID</th>
<th>Trial Brief Title</th>
<th>Date</th>
Expand Down
6 changes: 4 additions & 2 deletions app/views/admin/system/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
<i>An address to be BCCd when a user sends a message to a study team contact address. This may be used by staff to collect and monitor contact requests.</i>
</small>

<!-- <%= f.input :secret_key, hint: 'Secret key will be required by researchers to add or update trials.' %> -->
<%= f.input :secret_key, hint: 'Secret key will be required by researchers to add or update trials.' %>
<label>Display "Healthy Volunteers" Filter</label>
<small>
<i>Turning on will enable the Healthy Volunteer filter for studies.</i>
Expand Down Expand Up @@ -179,10 +179,12 @@
if(window.localStorage.getItem('utm_source')) {
campaignElement.value = window.localStorage.getItem('utm_source');
}
var formElement = document.getElementById('edit_study_finder_system_info_1');
var formElement = document.getElementById('edit_system_info_1');
formElement.addEventListener('submit', function (evt) {
evt.preventDefault();
window.localStorage.setItem('utm_source', campaignElement.value);
this.submit();
}, false);
});

</script>
2 changes: 1 addition & 1 deletion app/views/admin/users/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<h3 class="float-left">Users</h3>
<div class="float-right header-button"><%= link_to 'Add User', new_admin_user_path, class: 'btn btn-school'%></div>
</div>
<p class="description">This section is where the administrator can add/edit other admin users within StudyFinder. To add a new user click the "Add User" button above. You will need their unique email and internet_id. Once a user has been added, they will be able to access the entire admininstration area, so only grant these privileges to administrative staff.</p>
<p class="description">This section is where the administrator can add/edit other admin users within StudyFinder. To add a new user click the "Add User" button above. You will need their unique email and <%= username_string %>. Once a user has been added, they will be able to access the entire admininstration area, so only grant these privileges to administrative staff.</p>

<table class="table table-bordered table-trials">
<tr>
Expand Down
2 changes: 2 additions & 0 deletions app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
</head>
<body>
<script>
const DEFAULT_EMAIL = '<%= SystemInfo.default_email %>';
const STUDY_CONTACT_BCC = '<%= SystemInfo.study_contact_bcc %>';
const GA_VERSION = <%= SystemInfo.ga_version %>;
</script>
<div class="container main-content">
Expand Down
2 changes: 1 addition & 1 deletion app/views/sessions/new.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<%= simple_form_for @user, url: sessions_path do |f| %>
<div class="form-inputs">
<%= f.input :internet_id, required: false, autofocus: true, label: 'Internet ID' %>
<%= f.input :internet_id, required: false, autofocus: true, label: username_string %>
<%= f.input :password, required: false %>
</div>

Expand Down
2 changes: 1 addition & 1 deletion app/views/shared/_flash.html.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<% flash.each do |type, message| %>
<% unless message.empty? %>
<div class="alert <%= bootstrap_class_for(type) %> fade show">
<i class="fa <%= bootstrap_icon_for(type) %>"></i>
<i class="fa-solid <%= bootstrap_icon_for(type) %>"></i>
<% if message.kind_of? Array %>
<ul>
<% message.each do |m| %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/studies/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
<hr/>

<% if @trials.empty? %>
<div class="alert"><i class="fa fa-warning"></i> There were no trials that matched your search for <strong><%= @search_query %></strong></div>
<div class="alert"><i class="fa-solid fa-warning"></i> There were no trials that matched your search for <strong><%= @search_query %></strong></div>
<% end %>

<% @trials.each_with_index do |t, i| %>
Expand Down
25 changes: 11 additions & 14 deletions app/views/themed/_home_lower_right.html.erb
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
<h2 class="mt-3">Join a national registry!</h2>
<div class="row5">
<div class="col-md-12">
<%= link_to "https://researchmatch.org?rm=<%= @system_info.research_match_campaign" do %>
<%= image_tag "rsm-large.jpg", class: 'img-fluid', style: 'width: 50%;' %>
<% end %>
</div>
<div >

<!-- <a href="https://researchmatch.org?rm=<%= @system_info.research_match_campaign %>" target:"_blank">
<h3 class="hyperlink-header">ResearchMatch</h3>
</a> -->
<p>ResearchMatch.org connects volunteers with research studies across the country. Volunteers of any age, race, ethnicity, or health status are invited to join. Log on, register, and receive emails when studies might be a good fit for you.</p>
</div>
</div>
<div class="row5">
<div class="col-md-12">
<%= link_to "https://researchmatch.org?rm=<%= @system_info.research_match_campaign" do %>
<%= image_tag "rsm-large.jpg", class: 'img-fluid', style: 'width: 50%;' %>
<% end %>
</div>
<div >

<p>ResearchMatch.org connects volunteers with research studies across the country. Volunteers of any age, race, ethnicity, or health status are invited to join. Log on, register, and receive emails when studies might be a good fit for you.</p>
</div>
</div>
3 changes: 2 additions & 1 deletion config/application.example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ departmental_pw: 'PASSWORD'
theme: 'umn'
ELASTICSEARCH_URL: 'elastic.umn.edu'
wkhtmltopdf_binary_path: 'PATH'
DEFAULT_URL_HOST: 'yourstudyfinder.example.com' # Used in email links/URLs
DEFAULT_URL_HOST: 'yourstudyfinder.example.com' # Used in email links/URLs
username_string: 'Internet ID' # What a login 'username' is called at your institution. Appears in various templates.
11 changes: 1 addition & 10 deletions config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,6 @@

module StudyFinder
class Application < Rails::Application
# Initialize configuration defaults for originally generated Rails version.
#config.load_defaults 5.0

# Configuration for the application, engines, and railties goes here.
#
# These settings can be overridden in specific environments using the files
# in config/environments, which are processed later.
#
# config.time_zone = "Central Time (US & Canada)"
# config.eager_load_paths << Rails.root.join("extras")
config.load_defaults 7.0
end
end
4 changes: 2 additions & 2 deletions config/deploy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
lock "3.17.1"

set :application, "study_finder"
set :repo_url, "https://github.umn.edu/hst/study_finder_umn.git"
set :deploy_to, "/var/www/webapps/study_finder"
set :repo_url, "https://your-repo.com/study_finder_umn.git"
set :deploy_to, "/your/deploy/dir/study_finder"
set :default_env, { path: "/opt/ruby31/bin:$PATH" }
set :passenger_restart_with_touch, true
set :branch, ENV.fetch("GIT_BRANCH", "master").sub(/^origin\//, "")
Expand Down
2 changes: 1 addition & 1 deletion config/deploy/production.rb
Original file line number Diff line number Diff line change
@@ -1 +1 @@
server "walleye0.ahc.umn.edu", user: "webcluster2", roles: %w{app db web}
server "prod-server", user: "deploy-user", roles: %w{app db web}
2 changes: 1 addition & 1 deletion config/deploy/staging.rb
Original file line number Diff line number Diff line change
@@ -1 +1 @@
server "goldfish0.ahc.umn.edu", user: "webcluster2", roles: %w{app db web}
server "staging-server", user: "deploy-user", roles: %w{app db web}
2 changes: 1 addition & 1 deletion config/initializers/assets.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Be sure to restart your server when you modify this file.

# Version of your assets, change this if you want to expire all your assets.
Rails.application.config.assets.version = '1.7'
Rails.application.config.assets.version = '2.1'

# Add additional assets to the asset load path.
# Rails.application.config.assets.paths << Emoji.images_path
Expand Down

This file was deleted.

1 change: 0 additions & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,6 @@
t.boolean "trial_approval", default: false, null: false
t.boolean "alert_on_empty_system_id", default: false, null: false
t.string "study_contact_bcc"
t.boolean "protect_simple_description", default: false, null: false
t.boolean "healthy_volunteers_filter", default: true, null: false
t.boolean "gender_filter", default: true, null: false
t.integer "google_analytics_version"
Expand Down
4 changes: 2 additions & 2 deletions db/seeds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<p>To help potential participants better navigate and connect with University research opportunities, we encourage you to periodically review your studies and update the description and contact information, as appropriate.</p><p>Please also be aware that people may email you via StudyFinder to inquire about a study. We urge you to work directly with these potential participants, and to contact the StudyFinder team with any questions.</p><h3>How to update your study</h3><p>You can update select study information on this website or directly in the source data (<a href=\"http://clinicaltrials.gov\">ClinicalTrials.gov</a> and/or OnCore).</p><p>To update your study on StudyFinder: </p>
<ul>
<li>Click on the maroon \"Look up/Edit Study Information\" button toward the bottom of this page.</li>
<li>Log in using your x500.</li>
<li>Log in using your Internet ID.</li>
<li>Look up your study information by entering the System ID, which is either Study NCT ID from <a href=\"http://clinicaltrials.gov\">ClinicalTrials.gov</a>, or Protocol ID from OnCore.</li>
<li>Ensure the primary contact is a suitable person for potential participants to reach out to via email.</li>
<li>Save your changes by entering the secret key, and clicking the \"Update Trial\" button at the bottom of the page.</li>
Expand Down Expand Up @@ -102,7 +102,7 @@
# Trials
# ============================================

# Rake::Task['studyfinder:ctgov:load'].invoke
Rake::Task['studyfinder:ctgov:load'].invoke

# ============================================
# Trial attribute settings
Expand Down
Loading

0 comments on commit 56cff4b

Please sign in to comment.