Skip to content

Commit

Permalink
abstract 'Internet ID' to configurable string. Cleanup, readme.
Browse files Browse the repository at this point in the history
  • Loading branch information
machinehum committed Oct 30, 2023
1 parent a1c938f commit e909546
Show file tree
Hide file tree
Showing 19 changed files with 43 additions and 50 deletions.
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
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
4 changes: 2 additions & 2 deletions app/models/trial.rb
Original file line number Diff line number Diff line change
Expand Up @@ -603,11 +603,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
2 changes: 1 addition & 1 deletion 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
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: 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
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.
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
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
2 changes: 1 addition & 1 deletion lib/tasks/ctgov.rake
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace :studyfinder do
# ==============================================================================================

task :load, [:days_previous] => [:environment] do |t, args|
Retrieve x amount of trials days previous from today.
# Retrieve x amount of trials days previous from today.
args.with_defaults(days_previous: 4)

puts "Processing ClinicalTrials.gov data"
Expand Down
10 changes: 5 additions & 5 deletions spec/mailers/study_mailer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@
)

@mail = StudyMailer.contact_team(
'jim@aol.com',
'Jason Kadrmas',
'kadrm002@umn.edu',
'123-453-2345',
'This is a test',
Faker::Internet.email,
Faker::Name.full_name,
Faker::Internet.email,
Faker::PhoneNumber.phone_number,
Faker::HitchhikersGuideToTheGalaxy.marvin_quote,
@trial.system_id,
@trial.brief_title,
@system_info)
Expand Down
33 changes: 9 additions & 24 deletions spec/models/trial_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -132,24 +132,6 @@ def display_title
expect(duplicated_system_id.errors[:system_id]).to include('has already been taken')
end

it "does not allow non-alphanumeric white space character to be present for system_id" do
white_space_system_id = Trial.new(system_id: "123abc ")
expect(white_space_system_id).not_to be_valid
expect(white_space_system_id.errors[:system_id]).to eq(['only allows alphanumeric characters'])
end

it "does not allow non-alphanumeric tab character to be present for system_id" do
white_space_system_id = Trial.new(system_id: "123abc\t")
expect(white_space_system_id).not_to be_valid
expect(white_space_system_id.errors[:system_id]).to eq(['only allows alphanumeric characters'])
end

it "does not allow non-alphanumeric white space comma character to be present for system_id" do
white_space_system_id = Trial.new(system_id: "123abc, something else ")
expect(white_space_system_id).not_to be_valid
expect(white_space_system_id.errors[:system_id]).to eq(['only allows alphanumeric characters'])
end

it "returns the float 0.0 when minimum_age is N/A" do
age_value = 'N/A'
trial_with_age = Trial.new(minimum_age: age_value)
Expand Down Expand Up @@ -189,14 +171,16 @@ def display_title

it 'returns only records less than 18 for maximum age' do
Trial.__elasticsearch__.delete_index!
Trial.create(system_id: "123", maximum_age: "17", visible: true, approved: true)
Trial.create(system_id: "456", maximum_age: "18", visible: true, approved: true)
Trial.create(system_id: "789", maximum_age: "N/A", visible: true, approved: true)
Trial.create(system_id: "011", maximum_age: nil, visible: true, approved: true)
Trial.create(system_id: "123", minimum_age: nil, maximum_age: "17", visible: true, approved: true)
Trial.create(system_id: "as7f6", minimum_age: nil, maximum_age: "18", visible: true, approved: true)
Trial.create(system_id: "dsfg89", minimum_age: "17", maximum_age: "25", visible: true, approved: true)
Trial.create(system_id: "jh987", minimum_age: "18", maximum_age: "30", visible: true, approved: true)
Trial.create(system_id: "789", minimum_age: "18", maximum_age: "N/A", visible: true, approved: true)
Trial.create(system_id: "011", minimum_age: "18", maximum_age: nil, visible: true, approved: true)
Trial.__elasticsearch__.refresh_index!
search_results = Trial.execute_search({"q"=> "", "children"=> ""}).results.map(&:max_age)
expect(search_results.count).to eq(1)
expect(search_results).to eq([17.0])
expect(search_results.count).to eq(3)
expect(search_results.sort).to eq([17.0,18.0,25.0])
end

it 'returns only records greater than or equal to 18' do
Expand All @@ -206,6 +190,7 @@ def display_title
Trial.create(system_id: "789", maximum_age: "N/A", visible: true, approved: true)
Trial.create(system_id: "011", maximum_age: nil, visible: true, approved: true)
Trial.__elasticsearch__.refresh_index!

search_results = Trial.execute_search("q"=> "", "adults"=> "1").results.map(&:max_age)
expect(search_results.count).to eq(3)
expect(search_results).to include(1000.0, 1000.0, 18.0)
Expand Down

0 comments on commit e909546

Please sign in to comment.