source stringclasses 1
value | repo stringlengths 5 63 | repo_url stringlengths 24 82 | path stringlengths 5 167 | language stringclasses 1
value | license stringclasses 5
values | stars int64 10 51.4k | ref stringclasses 23
values | size_bytes int64 200 258k | text stringlengths 137 258k |
|---|---|---|---|---|---|---|---|---|---|
github | DARIAEngineering/dcaf_case_management | https://github.com/DARIAEngineering/dcaf_case_management | app/controllers/application_controller.rb | Ruby | mit | 92 | main | 3,700 | # Sets a few devise configs and security measures
class ApplicationController < ActionController::Base
set_current_tenant_by_subdomain(:fund, :subdomain)
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery prepend: true, with: :exception
... |
github | DARIAEngineering/dcaf_case_management | https://github.com/DARIAEngineering/dcaf_case_management | app/controllers/configs_controller.rb | Ruby | mit | 92 | main | 839 | class ConfigsController < ApplicationController
before_action :confirm_admin_user
def index
# n+1 join here
Config.autosetup
@configs = Config.all.sort_by(&:config_key)
end
def update
@config = Config.find params[:id]
@config.config_value = format_config_params(config_params)
if @conf... |
github | DARIAEngineering/dcaf_case_management | https://github.com/DARIAEngineering/dcaf_case_management | app/controllers/dashboards_controller.rb | Ruby | mit | 92 | main | 1,574 | # Controller for rendering the home view and patient search.
class DashboardsController < ApplicationController
include LinesHelper
include BudgetBarCalculable
before_action :pick_line_if_not_set, only: [:index, :search]
def index
@shared_patients = eager_loaded_patients.shared_patients(current_line)
... |
github | DARIAEngineering/dcaf_case_management | https://github.com/DARIAEngineering/dcaf_case_management | app/controllers/external_pledges_controller.rb | Ruby | mit | 92 | main | 1,079 | # Create a pledge from a non-fund organization
class ExternalPledgesController < ApplicationController
before_action :find_patient, only: [:create]
before_action :find_pledge, only: [:update, :destroy]
rescue_from ActiveRecord::RecordNotFound,
with: -> { head :not_found }
def create
@pledge =... |
github | DARIAEngineering/dcaf_case_management | https://github.com/DARIAEngineering/dcaf_case_management | app/controllers/calls_controller.rb | Ruby | mit | 92 | main | 1,107 | # Create method for calls, plus triggers for modal behavior
class CallsController < ApplicationController
before_action :find_patient, only: [:create, :destroy]
def create
@call = @patient.calls.new call_params
if call_saved_and_patient_reached @call, params
redirect_to edit_patient_path @patient
... |
github | DARIAEngineering/dcaf_case_management | https://github.com/DARIAEngineering/dcaf_case_management | app/controllers/clinics_controller.rb | Ruby | mit | 92 | main | 1,677 | # Clinic-related functionality.
class ClinicsController < ApplicationController
before_action :confirm_admin_user
before_action :find_clinic, only: [:update, :edit]
rescue_from ActiveRecord::RecordNotFound, with: -> { head :bad_request }
def index
@clinics = Clinic.all.sort_by { |c| [c.name] }
respond_... |
github | DARIAEngineering/dcaf_case_management | https://github.com/DARIAEngineering/dcaf_case_management | app/controllers/users_controller.rb | Ruby | mit | 92 | main | 3,344 | # Additional user methods in parallel with Devise -- all pertaining to call list
class UsersController < ApplicationController
before_action :confirm_admin_user, only: [:new, :index, :update, :edit,
:change_role_to_admin,
:change_... |
github | DARIAEngineering/dcaf_case_management | https://github.com/DARIAEngineering/dcaf_case_management | app/controllers/events_controller.rb | Ruby | mit | 92 | main | 508 | # For render
class EventsController < ApplicationController
include LinesHelper
def index
events = Event.where(line: current_line)
.order(created_at: :desc)
@events = paginate_results(events)
respond_to do |format|
format.html { render partial: 'events/events' }
format.js... |
github | DARIAEngineering/dcaf_case_management | https://github.com/DARIAEngineering/dcaf_case_management | app/controllers/auth_factor_steps_controller.rb | Ruby | mit | 92 | main | 1,881 | # Controls steps for registering a new authentication factor.
class AuthFactorStepsController < ApplicationController
include Wicked::Wizard
steps(*AuthFactor.form_steps)
def show
@auth_factor = AuthFactor.find(session[:auth_factor_id])
render_wizard
end
def update
@auth_factor = AuthFactor.fin... |
github | DARIAEngineering/dcaf_case_management | https://github.com/DARIAEngineering/dcaf_case_management | app/controllers/notes_controller.rb | Ruby | mit | 92 | main | 641 | # Create notes associated with patients.
class NotesController < ApplicationController
before_action :find_object, only: [:create]
def create
@note = @object.notes.new note_params
if @note.save
@notes = @object.reload.notes.order(created_at: :desc)
respond_to do |format|
format.js
... |
github | DARIAEngineering/dcaf_case_management | https://github.com/DARIAEngineering/dcaf_case_management | app/controllers/accountants_controller.rb | Ruby | mit | 92 | main | 1,029 | # Controller pertaining to accountant functions, usually fulfillments.
class AccountantsController < ApplicationController
before_action :confirm_data_access, only: [:index]
before_action :confirm_data_access_async, only: [:search, :edit]
before_action :find_patient, only: [:edit]
def index
@patients = Pat... |
github | DARIAEngineering/dcaf_case_management | https://github.com/DARIAEngineering/dcaf_case_management | app/controllers/multi_factor_authentication_controller.rb | Ruby | mit | 92 | main | 2,862 | # Controls steps for logging in a user with multi factor authentication.
class MultiFactorAuthenticationController < ApplicationController
include Wicked::Wizard
steps :factor_select, :verification
skip_before_action :authenticate_user!, :confirm_user_not_disabled!
def show
case step
when :factor_sel... |
github | DARIAEngineering/dcaf_case_management | https://github.com/DARIAEngineering/dcaf_case_management | app/controllers/call_lists_controller.rb | Ruby | mit | 92 | main | 1,016 | # Controller for managing a user's call list.
class CallListsController < ApplicationController
include LinesHelper
before_action :retrieve_patients, only: [:add_patient, :remove_patient]
rescue_from ActiveRecord::RecordNotFound, with: -> { head :not_found }
def add_patient
current_user.add_patient @patie... |
github | DARIAEngineering/dcaf_case_management | https://github.com/DARIAEngineering/dcaf_case_management | app/controllers/lines_controller.rb | Ruby | mit | 92 | main | 603 | # Single-serving controller for setting current line for a user.
class LinesController < ApplicationController
def new
@lines = ActsAsTenant.current_tenant.lines.sort_by(&:name)
if @lines.count == 0
raise Exceptions::NoLinesForFundError
end
if @lines.count == 1
set_line_session @lines.fir... |
github | DARIAEngineering/dcaf_case_management | https://github.com/DARIAEngineering/dcaf_case_management | app/controllers/auth_factors_controller.rb | Ruby | mit | 92 | main | 691 | class AuthFactorsController < ApplicationController
# Initializes an auth_factor then hands off to the AuthFactorStepsController
# which handles the multi-step registration process.
def new
auth_factor_id = session[:auth_factor_id]
unless auth_factor_id
@auth_factor = AuthFactor.new
@auth_fact... |
github | DARIAEngineering/dcaf_case_management | https://github.com/DARIAEngineering/dcaf_case_management | app/controllers/users/omniauth_callbacks_controller.rb | Ruby | mit | 92 | main | 1,003 | # Controller allowing authentication via google oauth.
class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController
rescue_from ActiveRecord::RecordNotFound,
with: -> { reject_login }
# i18n-tasks-use t('devise.sessions.failure.user.unauthenticated')
# i18n-tasks-use t('devise.se... |
github | DARIAEngineering/dcaf_case_management | https://github.com/DARIAEngineering/dcaf_case_management | app/controllers/users/sessions_controller.rb | Ruby | mit | 92 | main | 966 | # frozen_string_literal: true
class Users::SessionsController < Devise::SessionsController
def new
session.delete(:mfa)
super
end
def create
self.resource = warden.authenticate!(auth_options)
if multi_factor_enabled?
# preserve the stored location
stored_location = stored_location_f... |
github | DARIAEngineering/dcaf_case_management | https://github.com/DARIAEngineering/dcaf_case_management | app/controllers/users/registrations_controller.rb | Ruby | mit | 92 | main | 1,483 | # frozen_string_literal: true
class Users::RegistrationsController < Devise::RegistrationsController
prepend_before_action :confirm_user_not_disabled!
# before_action :configure_sign_up_params, only: [:create]
# before_action :configure_account_update_params, only: [:update]
# GET /users/edit
# def edit
#... |
github | DARIAEngineering/dcaf_case_management | https://github.com/DARIAEngineering/dcaf_case_management | app/controllers/concerns/budget_bar_calculable.rb | Ruby | mit | 92 | main | 387 | module BudgetBarCalculable
extend ActiveSupport::Concern
include BudgetBarHelper
def budget_bar_calculations(line)
expenditures = Patient.pledged_status_summary line
default_cash_ceiling = Config.budget_bar_max
cash_spent = sum_fund_pledges expenditures.values.flatten
{ limit: [default_cash_ceil... |
github | DARIAEngineering/dcaf_case_management | https://github.com/DARIAEngineering/dcaf_case_management | app/helpers/tables_helper.rb | Ruby | mit | 92 | main | 565 | module TablesHelper
def th_autosortable(column_name, type, local_assigns)
# Throw a flag unless sorting by string, int, or float
raise 'Bad datatype' unless %w(string string-ins int float).include? type
content_tag :th, data: { sort: type }, html: { scope: "col" } do
safe_join [column_name, autosort... |
github | DARIAEngineering/dcaf_case_management | https://github.com/DARIAEngineering/dcaf_case_management | app/helpers/dashboards_helper.rb | Ruby | mit | 92 | main | 1,026 | # Convenience methods consumed in the dashboards controller index view
module DashboardsHelper
def date_range(date: Time.zone.now)
if (Config.start_day == :monthly )
month_range(date: date)
else
week_range(date: date)
end
end
def month_range(date: Time.zone.now)
month_start = date.beg... |
github | DARIAEngineering/dcaf_case_management | https://github.com/DARIAEngineering/dcaf_case_management | app/helpers/navbar_helper.rb | Ruby | mit | 92 | main | 632 | module NavbarHelper
def cm_resources_link
maybe_url = Config.find_or_create_by(config_key: 'resources_url').options.first
# redundant UriService just for fallbackhelp
url = UriService.new(maybe_url).uri
content_tag :li do
link_to t('navigation.cm_resources.label'), url.to_s, target: '_blank', ... |
github | DARIAEngineering/dcaf_case_management | https://github.com/DARIAEngineering/dcaf_case_management | app/helpers/practical_supports_helper.rb | Ruby | mit | 92 | main | 2,709 | module PracticalSupportsHelper
# options_plus_current lives in PatientsHelper
include PatientsHelper
def practical_support_options(current_value = nil)
standard_options = [
nil,
[ t('patient.helper.practical_support.travel_to_region'), 'Travel to the region' ],
[ t('patient.helper.practical... |
github | DARIAEngineering/dcaf_case_management | https://github.com/DARIAEngineering/dcaf_case_management | app/helpers/events_helper.rb | Ruby | mit | 92 | main | 909 | # Functions to display events for activity feed
module EventsHelper
def fontawesome_classes(event)
kit = event.icon == 'thumbs-up' ? 'far' : 'fas'
return "#{kit} fa-#{event.icon}"
end
def entry_text(event)
time = event.created_at.display_time.to_s
cm = event.cm_name
event_text = event_string(... |
github | DARIAEngineering/dcaf_case_management | https://github.com/DARIAEngineering/dcaf_case_management | app/helpers/notes_helper.rb | Ruby | mit | 92 | main | 418 | # Functions related to displaying notes
module NotesHelper
def display_note_text_for(note)
return nil if note.try(:full_text).blank?
info = content_tag :p do
content_tag(:strong) do
t('note.most_recent', by: "#{note.created_by&.name}", at: "#{note.created_at.display_timestamp}")
end
en... |
github | DARIAEngineering/dcaf_case_management | https://github.com/DARIAEngineering/dcaf_case_management | app/helpers/patients_helper.rb | Ruby | mit | 92 | main | 10,058 | # Functions primarily related to populating selects on patient edit view.
require 'state_geo_tools'
module PatientsHelper
def weeks_options
(1..40).map { |i| [t('patient.helper.week', count: i), i] }.unshift [nil, nil]
end
def days_options
(0..6).map { |i| [t('patient.helper.day', count: i), i] }.unshift... |
github | DARIAEngineering/dcaf_case_management | https://github.com/DARIAEngineering/dcaf_case_management | app/helpers/clinicfinders_helper.rb | Ruby | mit | 92 | main | 822 | # Fields used in the result table will vary, so...
module ClinicfindersHelper
def parse_clinicfinder_field(clinic, field)
case field
when :location
t 'clinic_locator.result.location', city: clinic.city, state: clinic.state
when :distance
t 'clinic_locator.result.distance', miles: clinic[field]... |
github | DARIAEngineering/dcaf_case_management | https://github.com/DARIAEngineering/dcaf_case_management | app/helpers/lines_helper.rb | Ruby | mit | 92 | main | 714 | # Convenience function for displaying lines around the app.
module LinesHelper
def current_line_display
return if !session[:line_id]
# If multiple lines, link to the switcher
if Line.count > 1
return content_tag :li do
link_to t('navigation.current_line.helper') + ": #{current_line.name}",
... |
github | DARIAEngineering/dcaf_case_management | https://github.com/DARIAEngineering/dcaf_case_management | app/helpers/calls_helper.rb | Ruby | mit | 92 | main | 3,682 | # Functions to display call-related items.
module CallsHelper
def display_voicemail_link_with_warning(patient)
if patient.voicemail_preference == 'no'
no_voicemail_notifier
elsif patient.voicemail_preference == 'yes'
voicemail_ok_notifier + leave_a_voicemail_link(patient)
elsif patient.voicema... |
github | DARIAEngineering/dcaf_case_management | https://github.com/DARIAEngineering/dcaf_case_management | app/helpers/pledges_helper.rb | Ruby | mit | 92 | main | 853 | # Functions related to navigating around the pledge submission modal.
module PledgesHelper
def submit_pledge_button
content_tag :span, class: 'btn btn-primary btn-lg submit-btn btn-block',
aria: { hidden: true },
id: 'submit-pledge-button' do
t('patient.menu.sub... |
github | DARIAEngineering/dcaf_case_management | https://github.com/DARIAEngineering/dcaf_case_management | app/helpers/users_helper.rb | Ruby | mit | 92 | main | 869 | # Functions for cleaner rendering of user panels.
module UsersHelper
def user_role_options
[
['Case manager', 'cm'],
['Data volunteer', 'data_volunteer'],
['Admin', 'admin']
]
end
def user_lock_status(user)
if user.disabled_by_fund?
'Locked by admin'
elsif user.access_lock... |
github | DARIAEngineering/dcaf_case_management | https://github.com/DARIAEngineering/dcaf_case_management | app/helpers/budget_bar_helper.rb | Ruby | mit | 92 | main | 2,611 | # Functions to process data in the budget bar.
module BudgetBarHelper
def progress_bar_color(type)
color = type == :pledged ? 'warning' : 'success'
"bg-#{color}"
end
def progress_bar_width(value, cash_ceiling = Config.budget_bar_max)
"width: #{to_pct(value, cash_ceiling)}%"
end
def budget_bar_ex... |
github | DARIAEngineering/dcaf_case_management | https://github.com/DARIAEngineering/dcaf_case_management | app/helpers/welcome_message_helper.rb | Ruby | mit | 92 | main | 4,482 | # Renders nice message on the login screen!
module WelcomeMessageHelper
def random_welcome_message
welcome_messages.sample
end
private
def welcome_messages
[
"Thank you! - Team CM",
"¡Gracias! - Equipo CM",
"You are making choice a reality for the people you serve.",
"Keep up t... |
github | DARIAEngineering/dcaf_case_management | https://github.com/DARIAEngineering/dcaf_case_management | app/helpers/tooltips_helper.rb | Ruby | mit | 92 | main | 2,176 | # Populate bootstrap tooltip text
module TooltipsHelper
def tooltip_shell(help_text)
content_tag :span, class: 'daria-tooltip tooltip-header-help',
data: { toggle: 'tooltip',
html: true,
placement: 'bottom',
... |
github | DARIAEngineering/dcaf_case_management | https://github.com/DARIAEngineering/dcaf_case_management | app/helpers/footer_helper.rb | Ruby | mit | 92 | main | 328 | # Functions primarily related to populating funds at the footer.
module FooterHelper
def fax_service
fax = Config.find_or_create_by(config_key: 'fax_service').options.try :first
fax_uri = UriService.new(fax)
link_to fax_uri.uri, fax_uri.uri.to_s, target: '_blank', rel: 'noopener nofollow' if fax_uri.uri
... |
github | DARIAEngineering/dcaf_case_management | https://github.com/DARIAEngineering/dcaf_case_management | app/helpers/external_pledges_helper.rb | Ruby | mit | 92 | main | 849 | # Functions to populate dropdowns related to external pledges.
module ExternalPledgesHelper
def external_funds
Config.find_or_create_by(config_key: 'external_pledge_source').options
end
def solidarity_leads
current_fund = [
[current_tenant.name, nil]
]
external_funds.push(*current_fund)
e... |
github | DARIAEngineering/dcaf_case_management | https://github.com/DARIAEngineering/dcaf_case_management | app/helpers/change_log_helper.rb | Ruby | mit | 92 | main | 662 | # Functions for cleanly displaying rows in an audit log.
module ChangeLogHelper
# Separate changelog fields with breaks
def safe_join_fields(shaped_changes)
safe_join changelog_entry_display(shaped_changes), tag('br')
end
private
# Map changelog entries to a html string
def changelog_entry_display(sha... |
github | DARIAEngineering/dcaf_case_management | https://github.com/DARIAEngineering/dcaf_case_management | db/schema.rb | Ruby | mit | 92 | main | 18,335 | # This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
#
# This file is the source Rails uses to define your schema when running `bin/rai... |
github | DARIAEngineering/dcaf_case_management | https://github.com/DARIAEngineering/dcaf_case_management | db/seeds.rb | Ruby | mit | 92 | main | 20,201 | # Set up fixtures and database seeds to simulate a production environment.
raise 'No running seeds in prod' unless [nil, 'Sandbox'].include? ENV['DARIA_FUND']
# Clear out existing DB
ActsAsTenant.without_tenant do
Config.destroy_all
Event.destroy_all
Call.destroy_all
CallListEntry.destroy_all
ExternalPledge.... |
github | DARIAEngineering/dcaf_case_management | https://github.com/DARIAEngineering/dcaf_case_management | db/migrate/20220501053519_remove_pledge_generation_config_from_fund.rb | Ruby | mit | 92 | main | 270 | class RemovePledgeGenerationConfigFromFund < ActiveRecord::Migration[6.1]
def change
remove_column :funds, :pledge_generation_config, :string, comment: 'Optional config of which pledge generation configset to use. If null, pledge generation is shut off'
end
end |
github | DARIAEngineering/dcaf_case_management | https://github.com/DARIAEngineering/dcaf_case_management | db/migrate/20210502050214_create_call_list_entries.rb | Ruby | mit | 92 | main | 386 | class CreateCallListEntries < ActiveRecord::Migration[6.0]
def change
create_table :call_list_entries do |t|
t.references :user, null: false, foreign_key: true
t.references :patient, null: false, foreign_key: true
t.string :line, null: false
t.integer :order_key, null: false
t.time... |
github | DARIAEngineering/dcaf_case_management | https://github.com/DARIAEngineering/dcaf_case_management | db/migrate/20210927013527_create_funds.rb | Ruby | mit | 92 | main | 201 | class CreateFunds < ActiveRecord::Migration[6.1]
def change
create_table :funds do |t|
t.string :name
t.string :subdomain
t.string :domain
t.timestamps
end
end
end |
github | DARIAEngineering/dcaf_case_management | https://github.com/DARIAEngineering/dcaf_case_management | db/migrate/20220508184141_rename_urgent_flag_to_shared.rb | Ruby | mit | 92 | main | 244 | class RenameUrgentFlagToShared < ActiveRecord::Migration[6.1]
def change
rename_column :patients, :urgent_flag, :shared_flag
rename_column :archived_patients, :urgent_flag, :shared_flag
Patient.reset_column_information
end
end |
github | DARIAEngineering/dcaf_case_management | https://github.com/DARIAEngineering/dcaf_case_management | db/migrate/20210524020019_create_archived_patients.rb | Ruby | mit | 92 | main | 1,630 | class CreateArchivedPatients < ActiveRecord::Migration[6.0]
def change
create_table :archived_patients do |t|
t.string :identifier
# Generated from initial patient info
t.string :age_range, default: 'not_specified'
t.boolean :has_alt_contact
# Pulled directly from initial patient
... |
github | DARIAEngineering/dcaf_case_management | https://github.com/DARIAEngineering/dcaf_case_management | db/migrate/20210613035820_add_sessions_table.rb | Ruby | mit | 92 | main | 292 | class AddSessionsTable < ActiveRecord::Migration[6.0]
def change
create_table :sessions do |t|
t.string :session_id, :null => false
t.text :data
t.timestamps
end
add_index :sessions, :session_id, :unique => true
add_index :sessions, :updated_at
end
end |
github | DARIAEngineering/dcaf_case_management | https://github.com/DARIAEngineering/dcaf_case_management | db/migrate/20221031173736_add_unique_session_id_to_users.rb | Ruby | mit | 92 | main | 299 | # Add unique_session_id to users to support devise-security :session_limitable module.
# See https://github.com/devise-security/devise-security#session-limitable
class AddUniqueSessionIdToUsers < ActiveRecord::Migration[7.0]
def change
add_column :users, :unique_session_id, :string
end
end |
github | DARIAEngineering/dcaf_case_management | https://github.com/DARIAEngineering/dcaf_case_management | db/migrate/20210511010317_create_external_pledges.rb | Ruby | mit | 92 | main | 300 | class CreateExternalPledges < ActiveRecord::Migration[6.0]
def change
create_table :external_pledges do |t|
t.string :source, null: false
t.integer :amount
t.boolean :active
t.references :can_pledge, polymorphic: true, null: false
t.timestamps
end
end
end |
github | DARIAEngineering/dcaf_case_management | https://github.com/DARIAEngineering/dcaf_case_management | db/migrate/20211003052040_add_fields_to_fund.rb | Ruby | mit | 92 | main | 581 | class AddFieldsToFund < ActiveRecord::Migration[6.1]
def change
add_column :funds, :full_name, :string, comment: 'Full name of the fund. e.g. DC Abortion Fund'
add_column :funds, :site_domain, :string, comment: "URL of the fund's public-facing website. e.g. www.dcabortionfund.org"
add_column :funds, :phon... |
github | DARIAEngineering/dcaf_case_management | https://github.com/DARIAEngineering/dcaf_case_management | db/migrate/20211010043308_create_lines.rb | Ruby | mit | 92 | main | 222 | class CreateLines < ActiveRecord::Migration[6.1]
def change
create_table :lines do |t|
t.string :name, null: false
t.references :fund, null: false, foreign_key: true
t.timestamps
end
end
end |
github | DARIAEngineering/dcaf_case_management | https://github.com/DARIAEngineering/dcaf_case_management | db/migrate/20210403213315_create_users.rb | Ruby | mit | 92 | main | 389 | class CreateUsers < ActiveRecord::Migration[6.0]
def change
create_table :users do |t|
t.string :name, null: false
t.string :line
t.integer :role, null: false, default: 0
t.boolean :disabled_by_fund, default: false
# Scratch field - temporary BSON ID from Mongo so we can link things... |
github | DARIAEngineering/dcaf_case_management | https://github.com/DARIAEngineering/dcaf_case_management | db/migrate/20201207043840_create_configs.rb | Ruby | mit | 92 | main | 295 | class CreateConfigs < ActiveRecord::Migration[6.0]
def change
create_table :configs do |t|
t.integer :config_key, null: false, unique: true
t.jsonb :config_value, default: { options: [] }, null: false
t.timestamps
end
add_index :configs, :config_key
end
end |
github | DARIAEngineering/dcaf_case_management | https://github.com/DARIAEngineering/dcaf_case_management | db/migrate/20210410151149_create_patients.rb | Ruby | mit | 92 | main | 2,161 | class CreatePatients < ActiveRecord::Migration[6.0]
def change
create_table :patients do |t|
t.string :name, null: false
t.string :primary_phone, null: false
t.string :other_contact
t.string :other_phone
t.string :other_contact_relationship
t.string :identifier
t.string ... |
github | DARIAEngineering/dcaf_case_management | https://github.com/DARIAEngineering/dcaf_case_management | db/migrate/20210403213437_add_devise_to_users.rb | Ruby | mit | 92 | main | 1,742 | # frozen_string_literal: true
class AddDeviseToUsers < ActiveRecord::Migration[6.0]
def self.up
change_table :users do |t|
## Database authenticatable
t.string :email, null: false, default: ""
t.string :encrypted_password, null: false, default: ""
## Recoverable
t.stri... |
github | DARIAEngineering/dcaf_case_management | https://github.com/DARIAEngineering/dcaf_case_management | db/migrate/20210618205056_remove_mongo_id_columns.rb | Ruby | mit | 92 | main | 200 | class RemoveMongoIdColumns < ActiveRecord::Migration[6.0]
def change
%w(archived_patients clinics patients users).each do |model|
remove_column model, :mongo_id, :string
end
end
end |
github | DARIAEngineering/dcaf_case_management | https://github.com/DARIAEngineering/dcaf_case_management | db/migrate/20221226161204_add_extra_fields_to_pledge_config.rb | Ruby | mit | 92 | main | 424 | class AddExtraFieldsToPledgeConfig < ActiveRecord::Migration[7.0]
def change
add_column :pledge_configs, :remote_pledge, :boolean, comment: 'Whether to use the remote pledge generation service'
add_column :pledge_configs, :remote_pledge_extras, :json, default: {}, comment: 'Extra fields required for remote pl... |
github | DARIAEngineering/dcaf_case_management | https://github.com/DARIAEngineering/dcaf_case_management | db/migrate/20210426033002_create_calls.rb | Ruby | mit | 92 | main | 230 | class CreateCalls < ActiveRecord::Migration[6.0]
def change
create_table :calls do |t|
t.integer :status, null: false
t.references :can_call, polymorphic: true, null: false
t.timestamps
end
end
end |
github | DARIAEngineering/dcaf_case_management | https://github.com/DARIAEngineering/dcaf_case_management | db/migrate/20251221192950_add_consent_to_survey_to_patient.rb | Ruby | mit | 92 | main | 206 | class AddConsentToSurveyToPatient < ActiveRecord::Migration[8.1]
def change
add_column :patients, :consent_to_survey, :boolean, comment: 'An indicator that a patient is game to be surveyed'
end
end |
github | DARIAEngineering/dcaf_case_management | https://github.com/DARIAEngineering/dcaf_case_management | db/migrate/20240527174820_add_fields_to_practical_support.rb | Ruby | mit | 92 | main | 377 | class AddFieldsToPracticalSupport < ActiveRecord::Migration[7.1]
def change
add_column :practical_supports, :attachment_url, :string, comment: "A link to a fund's stored receipt for this particular entry"
add_column :practical_supports, :fulfilled, :boolean, comment: 'An indicator that a particular practical ... |
github | DARIAEngineering/dcaf_case_management | https://github.com/DARIAEngineering/dcaf_case_management | db/migrate/20221031171553_create_old_passwords.rb | Ruby | mit | 92 | main | 623 | # Creates old_passwords table to support devise-security's :password_archivable module.
# See https://github.com/devise-security/devise-security#password-archivable
class CreateOldPasswords < ActiveRecord::Migration[7.0]
def change
create_table :old_passwords do |t|
t.string :encrypted_password, null: false... |
github | DARIAEngineering/dcaf_case_management | https://github.com/DARIAEngineering/dcaf_case_management | db/migrate/20210307202735_create_clinics.rb | Ruby | mit | 92 | main | 1,373 | class CreateClinics < ActiveRecord::Migration[6.0]
def change
create_table :clinics do |t|
t.string :name, null: false
t.string :street_address
t.string :city
t.string :state
t.string :zip
t.string :phone
t.string :fax
t.boolean :active, null: false, default: true
... |
github | DARIAEngineering/dcaf_case_management | https://github.com/DARIAEngineering/dcaf_case_management | db/migrate/20210927014027_add_fund_to_models.rb | Ruby | mit | 92 | main | 389 | class AddFundToModels < ActiveRecord::Migration[6.1]
def change
%w(
archived_patients
calls
call_list_entries
clinics
configs
events
external_pledges
fulfillments
notes
patients
practical_supports
users
versions
).each do |model|
... |
github | DARIAEngineering/dcaf_case_management | https://github.com/DARIAEngineering/dcaf_case_management | db/migrate/20201212010730_create_events.rb | Ruby | mit | 92 | main | 358 | class CreateEvents < ActiveRecord::Migration[6.0]
def change
create_table :events do |t|
t.string :cm_name
t.integer :event_type
t.string :line
t.string :patient_name
t.string :patient_id
t.integer :pledge_amount
t.timestamps
end
add_index :events, :created_at
... |
github | DARIAEngineering/dcaf_case_management | https://github.com/DARIAEngineering/dcaf_case_management | db/migrate/20210927014219_allow_multitenant_validation.rb | Ruby | mit | 92 | main | 680 | class AllowMultitenantValidation < ActiveRecord::Migration[6.1]
def change
# This rescopes uniqueness on a few models to be within a particular fund_id.
# For ex, a user can have an account with more than one fund.
remove_index :users, :email, unique: true
add_index :users, [:email, :fund_id], unique:... |
github | DARIAEngineering/dcaf_case_management | https://github.com/DARIAEngineering/dcaf_case_management | db/migrate/20220221152932_create_pledge_configs.rb | Ruby | mit | 92 | main | 388 | class CreatePledgeConfigs < ActiveRecord::Migration[6.1]
def change
create_table :pledge_configs do |t|
t.string :contact_email
t.string :billing_email
t.string :phone
t.string :logo_url
t.integer :logo_height
t.integer :logo_width
t.string :address1
t.string :addre... |
github | DARIAEngineering/dcaf_case_management | https://github.com/DARIAEngineering/dcaf_case_management | db/migrate/20221027160232_add_unique_index_to_tenant_tables.rb | Ruby | mit | 92 | main | 281 | class AddUniqueIndexToTenantTables < ActiveRecord::Migration[7.0]
def change
add_index :clinics, [:name, :fund_id], unique: true
add_index :lines, [:name, :fund_id], unique: true
add_index :call_list_entries, [:patient_id, :user_id, :fund_id], unique: true
end
end |
github | DARIAEngineering/dcaf_case_management | https://github.com/DARIAEngineering/dcaf_case_management | db/migrate/20210626161444_change_fulfillment_date_of_check_to_date.rb | Ruby | mit | 92 | main | 332 | class ChangeFulfillmentDateOfCheckToDate < ActiveRecord::Migration[6.1]
def up
change_column :fulfillments,
:date_of_check,
"date USING case when date_of_check = '' then null else date_of_check::date end"
end
def down
change_column :fulfillments, :date_of_check, :strin... |
github | DARIAEngineering/dcaf_case_management | https://github.com/DARIAEngineering/dcaf_case_management | db/migrate/20220812191635_add_solidarity_lead_to_patient.rb | Ruby | mit | 92 | main | 200 | class AddSolidarityLeadToPatient < ActiveRecord::Migration[7.0]
def change
add_column :patients, :solidarity_lead, :string
add_column :archived_patients, :solidarity_lead, :string
end
end |
github | DARIAEngineering/dcaf_case_management | https://github.com/DARIAEngineering/dcaf_case_management | db/migrate/20211010044300_port_lines.rb | Ruby | mit | 92 | main | 1,190 | class PortLines < ActiveRecord::Migration[6.1]
def up
[:archived_patients, :call_list_entries, :events, :patients].each do |tbl|
rename_column tbl, :line, :line_legacy
add_reference tbl, :line, foreign_key: true
# Populate the new column with Line object refs
model = tbl.to_s.classify.con... |
github | DARIAEngineering/dcaf_case_management | https://github.com/DARIAEngineering/dcaf_case_management | db/migrate/20201120043849_create_versions.rb | Ruby | mit | 92 | main | 1,531 | # This migration creates the `versions` table, the only schema PT requires.
# All other migrations PT provides are optional.
class CreateVersions < ActiveRecord::Migration[6.0]
# The largest text column available in all supported RDBMS is
# 1024^3 - 1 bytes, roughly one gibibyte. We specify a size
# so that MyS... |
github | DARIAEngineering/dcaf_case_management | https://github.com/DARIAEngineering/dcaf_case_management | db/migrate/20210415015227_create_fulfillment.rb | Ruby | mit | 92 | main | 526 | class CreateFulfillment < ActiveRecord::Migration[6.0]
def change
create_table :fulfillments do |t|
t.boolean :fulfilled, null: false, default: false
t.date :procedure_date
t.integer :gestation_at_procedure
t.integer :fund_payout
t.string :check_number
t.string :date_of_check
... |
github | DARIAEngineering/dcaf_case_management | https://github.com/DARIAEngineering/dcaf_case_management | db/migrate/20240818162657_add_waiver_to_patient.rb | Ruby | mit | 92 | main | 372 | class AddWaiverToPatient < ActiveRecord::Migration[7.1]
def change
add_column :patients, :practical_support_waiver, :boolean, comment: 'Optional practical support services waiver, for funds that use them'
add_column :archived_patients, :practical_support_waiver, :boolean, comment: 'Optional practical support ... |
github | DARIAEngineering/dcaf_case_management | https://github.com/DARIAEngineering/dcaf_case_management | db/migrate/20230113192110_create_auth_factors.rb | Ruby | mit | 92 | main | 474 | class CreateAuthFactors < ActiveRecord::Migration[7.0]
def change
create_table :auth_factors do |t|
t.references :user, null: false, foreign_key: true
t.string :name
t.string :channel
t.boolean :enabled, default: false
t.boolean :registration_complete, default: false
t.string :... |
github | DARIAEngineering/dcaf_case_management | https://github.com/DARIAEngineering/dcaf_case_management | db/migrate/20210509191049_create_practical_supports.rb | Ruby | mit | 92 | main | 313 | class CreatePracticalSupports < ActiveRecord::Migration[6.0]
def change
create_table :practical_supports do |t|
t.string :support_type, null: false
t.boolean :confirmed
t.string :source, null: false
t.references :can_support, polymorphic: true
t.timestamps
end
end
end |
github | DARIAEngineering/dcaf_case_management | https://github.com/DARIAEngineering/dcaf_case_management | db/migrate/20240804055320_add_multi_day_appointment_to_patient.rb | Ruby | mit | 92 | main | 217 | class AddMultiDayAppointmentToPatient < ActiveRecord::Migration[7.1]
def change
add_column :patients, :multiday_appointment, :boolean
add_column :archived_patients, :multiday_appointment, :boolean
end
end |
github | DARIAEngineering/dcaf_case_management | https://github.com/DARIAEngineering/dcaf_case_management | test/application_system_test_case.rb | Ruby | mit | 92 | main | 1,133 | require 'test_helper'
require 'integration_helper'
# Hack from https://github.com/teamcapybara/capybara/issues/2800#issuecomment-3172247546
module Selenium
module WebDriver
module Error
class UnknownError
alias old_initialize initialize
def initialize(msg = nil)
if msg&.include?(... |
github | DARIAEngineering/dcaf_case_management | https://github.com/DARIAEngineering/dcaf_case_management | test/omniauth_helper.rb | Ruby | mit | 92 | main | 670 | # in test/helpers/omniauth_helper.rb
module OmniauthMocker
def mock_omniauth(email = 'test@gmail.com')
OmniAuth.config.mock_auth[:google_oauth2] = OmniAuth::AuthHash.new({
'provider' => 'google_oauth2',
'uid' => '111696567596812172783',
'info' => {
'email' => email,
'first_name' ... |
github | DARIAEngineering/dcaf_case_management | https://github.com/DARIAEngineering/dcaf_case_management | test/i18n_test.rb | Ruby | mit | 92 | main | 917 | # frozen_string_literal: true
require 'i18n/tasks'
class I18nTest < ActiveSupport::TestCase
def setup
@i18n = I18n::Tasks::BaseTask.new
@missing_keys = @i18n.missing_keys
@unused_keys = @i18n.unused_keys
end
def test_no_missing_keys
assert_empty @missing_keys,
"Missing #{@missi... |
github | DARIAEngineering/dcaf_case_management | https://github.com/DARIAEngineering/dcaf_case_management | test/integration_helper.rb | Ruby | mit | 92 | main | 1,725 | # Helpers for browser junk
module IntegrationHelper
def t(string)
I18n.t(string)
end
def sign_in(user)
post user_session_path \
'user[email]' => user.email,
'user[password]' => user.password
end
def choose_line(line)
post lines_path, params: { line_id: line.id }
end
def log_in... |
github | DARIAEngineering/dcaf_case_management | https://github.com/DARIAEngineering/dcaf_case_management | test/test_helper.rb | Ruby | mit | 92 | main | 4,411 | # Rails stock
ENV['RAILS_ENV'] ||= 'test'
require_relative "../config/environment"
require 'rails/test_help'
# Custom
require 'omniauth_helper'
require 'integration_helper'
# Convenience methods around config creation, and database cleaning
class ActiveSupport::TestCase
include FactoryBot::Syntax::Methods # instead... |
github | DARIAEngineering/dcaf_case_management | https://github.com/DARIAEngineering/dcaf_case_management | test/models/patient_test.rb | Ruby | mit | 92 | main | 27,640 | require 'test_helper'
class PatientTest < ActiveSupport::TestCase
extend Minitest::OptionalRetry
before do
@user = create :user
@line = create :line
@patient = create :patient, other_phone: '111-222-3333',
other_contact: 'Yolo',
line: @li... |
github | DARIAEngineering/dcaf_case_management | https://github.com/DARIAEngineering/dcaf_case_management | test/models/external_pledge_test.rb | Ruby | mit | 92 | main | 1,603 | require 'test_helper'
class ExternalPledgeTest < ActiveSupport::TestCase
before do
@user = create :user
@patient = create :patient
@patient.external_pledges.create amount: 100,
source: 'BWAH'
@pledge = @patient.external_pledges.first
end
describe 'concerns' d... |
github | DARIAEngineering/dcaf_case_management | https://github.com/DARIAEngineering/dcaf_case_management | test/models/config_test.rb | Ruby | mit | 92 | main | 10,967 | require 'test_helper'
class ConfigTest < ActiveSupport::TestCase
before { @config = create :config }
describe 'callbacks' do
it 'should capitalize words before save' do
c = Config.find_or_create_by(config_key: :start_of_week)
c.config_value= { options: ["wednesday"] }
assert c.valid?
a... |
github | DARIAEngineering/dcaf_case_management | https://github.com/DARIAEngineering/dcaf_case_management | test/models/note_test.rb | Ruby | mit | 92 | main | 899 | require 'test_helper'
class NoteTest < ActiveSupport::TestCase
before do
@user = create :user
with_versioning(@user) do
@patient = create :patient
@patient.notes.create attributes_for(:note)
@note = @patient.notes.first
end
end
describe 'validation' do
it 'should build' do
... |
github | DARIAEngineering/dcaf_case_management | https://github.com/DARIAEngineering/dcaf_case_management | test/models/fulfillment_test.rb | Ruby | mit | 92 | main | 782 | require 'test_helper'
class FulfillmentTest < ActiveSupport::TestCase
before do
@user = create :user
@pt_1 = create :patient, name: 'Susan Smith'
@fulfillment = @pt_1.fulfillment
end
describe 'concerns' do
it 'should respond to history methods' do
assert @fulfillment.respond_to? :versions
... |
github | DARIAEngineering/dcaf_case_management | https://github.com/DARIAEngineering/dcaf_case_management | test/models/archived_patient_test.rb | Ruby | mit | 92 | main | 7,283 | require 'test_helper'
class ArchivedPatientTest < ActiveSupport::TestCase
before do
@user = create :user
@user2 = create :user
@line = create :line
with_versioning(@user) do
@patient = create :patient, other_phone: '111-222-3333',
other_contact: 'Yolo',
... |
github | DARIAEngineering/dcaf_case_management | https://github.com/DARIAEngineering/dcaf_case_management | test/models/auth_factor_test.rb | Ruby | mit | 92 | main | 523 | require 'test_helper'
class AuthFactorTest < ActiveSupport::TestCase
before do
@user = create :user
with_versioning(@user) do
@user.auth_factors.create attributes_for(:auth_factor, :registration_complete)
@auth_factor = @user.auth_factors.first
end
end
describe 'validations' do
it 's... |
github | DARIAEngineering/dcaf_case_management | https://github.com/DARIAEngineering/dcaf_case_management | test/models/call_list_entry_test.rb | Ruby | mit | 92 | main | 923 | require 'test_helper'
class CallListEntryTest < ActiveSupport::TestCase
before do
@call_list_entry = create :call_list_entry
end
describe 'validations' do
it 'should be able to build an object' do
assert @call_list_entry.valid?
end
%i(order_key).each do |field|
it "should enforce pr... |
github | DARIAEngineering/dcaf_case_management | https://github.com/DARIAEngineering/dcaf_case_management | test/models/event_test.rb | Ruby | mit | 92 | main | 2,036 | require 'test_helper'
class EventTest < ActiveSupport::TestCase
before { @event = create :event }
describe 'basic validations' do
it 'should build' do
assert @event.valid?
end
it 'should only allow certain statuses' do
assert_raises ArgumentError do
@event.event_type = :notatype
... |
github | DARIAEngineering/dcaf_case_management | https://github.com/DARIAEngineering/dcaf_case_management | test/models/line_test.rb | Ruby | mit | 92 | main | 670 | require "test_helper"
class LineTest < ActiveSupport::TestCase
before { @line = create :line }
describe 'validations' do
it 'should build' do
assert create(:line).valid?
end
[:name].each do |attrib|
it "should require #{attrib}" do
@line[attrib] = nil
refute @line.valid?
... |
github | DARIAEngineering/dcaf_case_management | https://github.com/DARIAEngineering/dcaf_case_management | test/models/paper_trail_version_test.rb | Ruby | mit | 92 | main | 3,774 | require 'test_helper'
class PaperTrailVersionTest < ActiveSupport::TestCase
before do
@user = create :user
with_versioning(@user) do
@patient = create :patient, name: 'Susie Everyteen',
primary_phone: '111-222-3333',
appointment_date: ... |
github | DARIAEngineering/dcaf_case_management | https://github.com/DARIAEngineering/dcaf_case_management | test/models/call_test.rb | Ruby | mit | 92 | main | 1,116 | require 'test_helper'
class CallTest < ActiveSupport::TestCase
before do
@user = create :user
with_versioning(@user) do
@patient = create :patient
@patient.calls.create attributes_for(:call)
@call = @patient.calls.first
end
end
describe 'basic validations' do
it 'should build' ... |
github | DARIAEngineering/dcaf_case_management | https://github.com/DARIAEngineering/dcaf_case_management | test/models/user_test.rb | Ruby | mit | 92 | main | 9,640 | require 'test_helper'
require 'ostruct'
class UserTest < ActiveSupport::TestCase
# Since this is a devise install, devise is handling
# general stuff like creation timestamps etc.
before { @user = create :user }
describe 'basic validations' do
it 'should be able to build an object' do
assert @user.v... |
github | DARIAEngineering/dcaf_case_management | https://github.com/DARIAEngineering/dcaf_case_management | test/models/pledge_config_test.rb | Ruby | mit | 92 | main | 604 | require "test_helper"
class PledgeConfigTest < ActiveSupport::TestCase
before { @config = create :pledge_config }
describe 'basic validations' do
it 'should build' do
assert create(:pledge_config).valid?
end
[:contact_email, :billing_email, :phone, :address1, :address2].each do |attrib|
i... |
github | DARIAEngineering/dcaf_case_management | https://github.com/DARIAEngineering/dcaf_case_management | test/models/clinic_test.rb | Ruby | mit | 92 | main | 3,813 | require 'test_helper'
require 'ostruct'
class ClinicTest < ActiveSupport::TestCase
before { @clinic = create :clinic }
describe 'validations' do
it 'should build' do
assert @clinic.valid?
end
[:name, :street_address, :city, :state, :zip].each do |attr|
it "requires a #{attr}" do
@... |
github | DARIAEngineering/dcaf_case_management | https://github.com/DARIAEngineering/dcaf_case_management | test/models/practical_support_test.rb | Ruby | mit | 92 | main | 1,735 | require 'test_helper'
class PracticalSupportTest < ActiveSupport::TestCase
before do
@user = create :user
@patient = create :patient
@patient.practical_supports.create support_type: 'Concert Tickets',
source: 'Metallica Abortion Fund'
@patient.practical_supports... |
github | DARIAEngineering/dcaf_case_management | https://github.com/DARIAEngineering/dcaf_case_management | test/models/fund_test.rb | Ruby | mit | 92 | main | 3,551 | require "test_helper"
class FundTest < ActiveSupport::TestCase
before do
@fund = Fund.first # created during setup
end
describe 'basic validations' do
it 'should build' do
assert create(:fund).valid?
end
[:name, :subdomain, :domain, :full_name].each do |attrib|
it "should require #{... |
github | DARIAEngineering/dcaf_case_management | https://github.com/DARIAEngineering/dcaf_case_management | test/models/patient/exportable_test.rb | Ruby | mit | 92 | main | 9,818 | require 'test_helper'
require_relative '../patient_test'
class PatientTest::Exportable < PatientTest
before do
# Perils of subclassing - this restores db to clean
Patient.destroy_all
ArchivedPatient.destroy_all
end
describe 'export concern methods' do
before do
@patient = create :patient
... |
github | DARIAEngineering/dcaf_case_management | https://github.com/DARIAEngineering/dcaf_case_management | test/models/patient/searchable_test.rb | Ruby | mit | 92 | main | 3,128 | require 'test_helper'
require_relative '../patient_test'
class PatientTest::PatientSearchable < PatientTest
describe 'search method' do
before do
@line = create :line, name: 'DC'
@line2 = create :line, name: 'MD'
@pt_1 = create :patient, name: 'Susan Sher',
primar... |
github | DARIAEngineering/dcaf_case_management | https://github.com/DARIAEngineering/dcaf_case_management | test/models/patient/last_menstrual_period_measureable_test.rb | Ruby | mit | 92 | main | 2,823 | require 'test_helper'
require_relative '../patient_test'
class PatientTest::LastMenstrualPeriodMeasureable < PatientTest
describe 'last menstrual period calculation concern' do
before do
@user = create :user
@patient = create :patient, initial_call_date: 2.days.ago,
... |
github | DARIAEngineering/dcaf_case_management | https://github.com/DARIAEngineering/dcaf_case_management | test/models/patient/statusable_test.rb | Ruby | mit | 92 | main | 3,616 | require 'test_helper'
require_relative '../patient_test'
class PatientTest::Statusable < PatientTest
describe 'status concern methods' do
before do
@user = create :user
@patient = create :patient, other_phone: '111-222-3333',
other_contact: 'Yolo'
end
descri... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.