Skip to content
Open
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
36 changes: 18 additions & 18 deletions app/controllers/monthly_reports_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ def monthly

build_month_and_year
find_form_builder
load_agencies
load_organizations
@workshop_log_summary_page = show_feature?(:new_workshop_log)

if (@report = current_user.submitted_monthly_report(@date,
@form_builder.windows_type,
@agency_id))
@organization_id))
redirect_to(action: :edit, id: @report,
month: @month, year: @year,
form_builder_id: @form_builder.id, agency_id: @agency_id)
form_builder_id: @form_builder.id, organization_id: @organization_id)
else
render_form
render :new
Expand All @@ -40,8 +40,8 @@ def create
else
@form_builder = FormBuilder.find(@report.owner_id)
build_month_and_year
load_agencies
@agency_id = report_params["organization_id"]
load_organizations
@organization_id = report_params["organization_id"]

flash[:alert] = "There was a problem submitting your form: " +
"#{@report.errors.full_messages.join(" ")}"
Expand All @@ -66,13 +66,13 @@ def edit
@report = Report.find(params[:id])

authorize! @report
@agencies = current_user.organizations.
@organizations = current_user.organizations.
where(windows_type_id: @report.windows_type_id)
@month = @report.date.month
@year = @report.date.year

find_workshop_logs
find_combined_workshop_logs(@agency_id)
find_combined_workshop_logs(@organization_id)
end

def update
Expand All @@ -91,8 +91,8 @@ def update
flash[:notice] = "Thanks for reporting on a update report. "
redirect_to root_path
else
@agencies = current_user.organizations.
where(windows_type_id: @report.windows_type_id)
@organizations = current_user.organizations.
where(windows_type_id: @report.windows_type_id)

flash[:alert] = "ERROR!!!!!!!!!!!!!!"
render :edit
Expand All @@ -118,9 +118,9 @@ def show

private

def load_agencies
@agencies = current_user.organizations.
where(windows_type_id: @form_builder.windows_type_id).uniq
def load_organizations
@organizations = current_user.organizations.
where(windows_type_id: @form_builder.windows_type_id).uniq
end

def render_form
Expand All @@ -133,7 +133,7 @@ def render_form
find_form_builder
build_report_form_fields
find_workshop_logs
find_combined_workshop_logs(@agency_id)
find_combined_workshop_logs(@organization_id)
end

def find_form_builder
Expand All @@ -142,12 +142,12 @@ def find_form_builder
else
@form_builder = FormBuilder
.monthly
.find_by(windows_type_id: @agency.windows_type_id)
.find_by(windows_type_id: @organization.windows_type_id)
.decorate
end

agency = params[:agency_id] ? Organization.find(params[:agency_id]) : current_user.organizations.where(windows_type_id: @form_builder.windows_type).first
@agency_id = agency.id unless agency.nil?
organization = params[:organization_id] ? Organization.find(params[:organization_id]) : current_user.organizations.where(windows_type_id: @form_builder.windows_type).first
@organization_id = organization.id unless organization.nil?
end

def build_report
Expand Down Expand Up @@ -208,10 +208,10 @@ def find_workshop_logs
@total_first_time = logs.reduce(0) { |sum, l| sum = sum + l.num_first_time }
end

def find_combined_workshop_logs(agency_id)
def find_combined_workshop_logs(organization_id)
combined_windows_type = WindowsType.where(short_name: "COMBINED").first
@combined_workshop_logs = current_user.organization_workshop_logs(
@report.date, combined_windows_type, agency_id)
@report.date, combined_windows_type, organization_id)
end

def build_month_and_year
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/organizations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ def set_organization
def organization_params
params.require(:organization).permit(
:name, :description, :start_date, :end_date, :mission_vision_values,
:agency_type, :agency_type_other, :internal_id, :logo, :notes, :email, :website_url,
:organization_type, :organization_type_other, :internal_id, :logo, :notes, :email, :website_url,
:organization_status_id, :location_id, :windows_type_id,
:profile_show_sectors, :profile_show_email, :profile_show_phone,
:profile_show_website, :profile_show_description, :profile_show_workshops,
Expand Down
20 changes: 10 additions & 10 deletions app/controllers/reports_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def share_story

@report.owner_type = "FormBuilder"
@report.owner_id = 7
@agencies = current_user.organizations
@organizations = current_user.organizations
end

def render_form
Expand All @@ -48,8 +48,8 @@ def edit
build_month_and_year
find_form_builder
@report = current_user.submitted_monthly_report(@date, @form_builder.windows_type)
@agencies = current_user.organizations.
where(windows_type_id: @report.windows_type_id)
@organizations = current_user.organizations.
where(windows_type_id: @report.windows_type_id)
@month = @report.date.month
@year = @report.date.year

Expand All @@ -62,8 +62,8 @@ def edit_story
.order(title: :asc)

@report = Report.find(params[:id])
@agencies = current_user.organizations.
where(windows_type_id: @report.windows_type_id)
@organizations = current_user.organizations.
where(windows_type_id: @report.windows_type_id)
end

def update_story
Expand All @@ -81,8 +81,8 @@ def update_story
flash[:notice] = "Thanks for reporting on a update report. "
redirect_to root_path
else
@agencies = current_user.organizations.
where(windows_type_id: @report.windows_type_id)
@organizations = current_user.organizations.
where(windows_type_id: @report.windows_type_id)

flash[:alert] = "ERROR!!!!!!!!!!!!!!"
render :edit
Expand All @@ -107,8 +107,8 @@ def update
flash[:notice] = "Thanks for reporting on a update report. "
redirect_to root_path
else
@agencies = current_user.organizations.
where(windows_type_id: @report.windows_type_id)
@organizations = current_user.organizations.
where(windows_type_id: @report.windows_type_id)

flash[:alert] = "ERROR!!!!!!!!!!!!!!"
render :edit
Expand Down Expand Up @@ -186,7 +186,7 @@ def find_form_builder
else
@form_builder = FormBuilder
.monthly
.find_by(windows_type_id: @agency.windows_type_id)
.find_by(windows_type_id: @organization.windows_type_id)
.decorate
end
end
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ def user_params
:email, :comment, :person_id, :inactive, :locked, :primary_address, :time_zone, :super_user,

##### legacy to remove later
:agency_id, :legacy, :legacy_id, :subscribecode, :first_name, :last_name, # legacy to remove later
:legacy, :legacy_id, :subscribecode, :first_name, :last_name, # legacy to remove later
:address, :address2, :city, :city2, :state, :state2, :zip, :zip2, # legacy to remove later
:phone, :phone2, :phone3, :birthday, :best_time_to_call, :notes, # legacy to remove later
#####
Expand Down
6 changes: 3 additions & 3 deletions app/controllers/workshop_log_creation_wizard_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class WorkshopLogCreationWizardController < ApplicationController
def show
authorize! :workshop_log_creation_wizard, to: :show?
@user = current_user
@agencies = current_user.organizations
@organizations = current_user.organizations
windows_type_id = params[:windows_type_id] || WindowsType.where(short_name: "COMBINED")
@windows_type = WindowsType.find(windows_type_id) if windows_type_id
send(step)
Expand All @@ -17,7 +17,7 @@ def show
def update
authorize! :workshop_log_creation_wizard, to: :update?
@user = current_user
@agencies = current_user.organizations
@organizations = current_user.organizations
windows_type_id = params["workshop"]["workshop_logs_attributes"].values[0]["windows_type_id"]
@windows_type = WindowsType.find(windows_type_id)
send("update_#{step}")
Expand All @@ -37,7 +37,7 @@ def fill_out_form
# build_workshop_age_ranges
build_report_form_field_answers
build_workshop_quote
@agencies = @agencies.where(windows_type: @workshop.windows_type) if @workshop.windows_type
@organizations = @organizations.where(windows_type: @workshop.windows_type) if @workshop.windows_type
end

def load_previous_report
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/workshop_logs_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ def set_form_variables
.or(Organization.where(id: @workshop_log.organization_id))
.distinct
.order(:name)
organization = params[:agency_id].present? ? Organization.where(id: params[:agency_id]).last : @organizations.first
organization = params[:organization_id].present? ? Organization.where(id: params[:organization_id]).last : @organizations.first
@organization_id = organization.id if organization
end

Expand Down
2 changes: 1 addition & 1 deletion app/controllers/workshops_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def summary

combined_windows_type = WindowsType.where(short_name: "COMBINED").first
@combined_workshop_logs = current_user.organization_workshop_logs(
@report.date, combined_windows_type, current_user.agency_id
@report.date, combined_windows_type, current_user.organization_id
)
authorize! @combined_workshop_logs
end
Expand Down
22 changes: 11 additions & 11 deletions app/services/event_registration_services/public_registration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ def call
create_mailing_address(person) if field_value("mailing_city").present?
create_phone_contact(person) if field_value("phone").present?

organization = find_organization if field_value("agency_name").present?
organization = find_organization if field_value("organization_name").present?
create_affiliation(person, organization) if organization
create_agency_address(organization) if organization && field_value("agency_city").present?
create_organization_address(organization) if organization && field_value("organization_city").present?

assign_tags(person, organization)

Expand Down Expand Up @@ -159,7 +159,7 @@ def create_phone_contact(person)
end

def find_organization
name = field_value("agency_name")&.strip
name = field_value("organization_name")&.strip
return nil if name.blank?

Organization.find_by(name: name)
Expand All @@ -170,14 +170,14 @@ def create_affiliation(person, organization)
person: person,
organization: organization
) do |aff|
aff.title = field_value("agency_position")
aff.title = field_value("organization_position")
aff.start_date = Date.current
end
end

def create_agency_address(organization)
new_city = field_value("agency_city")&.strip
new_state = field_value("agency_state")&.strip
def create_organization_address(organization)
new_city = field_value("organization_city")&.strip
new_state = field_value("organization_state")&.strip

existing = organization.addresses.find_by(
"LOWER(city) = ? AND LOWER(COALESCE(state, '')) = ?",
Expand All @@ -186,8 +186,8 @@ def create_agency_address(organization)

if existing
existing.update!(
street_address: field_value("agency_street"),
zip_code: field_value("agency_zip"),
street_address: field_value("organization_street"),
zip_code: field_value("organization_zip"),
primary: true,
inactive: false
)
Expand All @@ -197,10 +197,10 @@ def create_agency_address(organization)
organization.addresses.where(primary: true).update_all(primary: false, inactive: true)

organization.addresses.create!(
street_address: field_value("agency_street"),
street_address: field_value("organization_street"),
city: new_city,
state: new_state,
zip_code: field_value("agency_zip"),
zip_code: field_value("organization_zip"),
locality: "Unknown",
address_type: "work",
primary: true
Expand Down
30 changes: 15 additions & 15 deletions app/services/extended_event_registration_form_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -106,28 +106,28 @@ def build_contact_fields(form, position)
key: "phone_type", group: "contact", required: true,
options: %w[Mobile Home Work])

position = add_header(form, position, "Agency / Organization Information", group: "contact")
position = add_field(form, position, "Agency / Organization Name", :free_form_input_one_line,
key: "agency_name", group: "contact", required: false)
position = add_header(form, position, "Organization Information", group: "contact")
position = add_field(form, position, "Organization Name", :free_form_input_one_line,
key: "organization_name", group: "contact", required: false)
position = add_field(form, position, "Position / Title", :free_form_input_one_line,
key: "agency_position", group: "contact", required: false)
position = add_field(form, position, "Agency Street Address", :free_form_input_one_line,
key: "agency_street", group: "contact", required: false)
position = add_field(form, position, "Agency City", :free_form_input_one_line,
key: "agency_city", group: "contact", required: false)
position = add_field(form, position, "Agency State / Province", :free_form_input_one_line,
key: "agency_state", group: "contact", required: false)
position = add_field(form, position, "Agency Zip / Postal Code", :free_form_input_one_line,
key: "agency_zip", group: "contact", required: false)
position = add_field(form, position, "Agency Type", :multiple_choice_radio,
key: "agency_type", group: "contact", required: false,
key: "organization_position", group: "contact", required: false)
position = add_field(form, position, "Organization Street Address", :free_form_input_one_line,
key: "organization_street", group: "contact", required: false)
position = add_field(form, position, "Organization City", :free_form_input_one_line,
key: "organization_city", group: "contact", required: false)
position = add_field(form, position, "Organization State / Province", :free_form_input_one_line,
key: "organization_state", group: "contact", required: false)
position = add_field(form, position, "Organization Zip / Postal Code", :free_form_input_one_line,
key: "organization_zip", group: "contact", required: false)
position = add_field(form, position, "Organization Type", :multiple_choice_radio,
key: "organization_type", group: "contact", required: false,
options: [
"Domestic Violence", "Homeless Shelter", "Hospital",
"Mental Health", "School", "After-School Program",
"Community Center", "Other"
])
position = add_field(form, position, "Agency Website", :free_form_input_one_line,
key: "agency_website", group: "contact", required: false)
key: "organization_website", group: "contact", required: false)

position
end
Expand Down
2 changes: 1 addition & 1 deletion app/services/scholarship_application_form_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def build_fields!(form)
position = add_header(form, position, "Scholarship Application", group: "scholarship")

position = add_field(form, position,
"I / my agency cannot afford the full training cost and need a scholarship to attend.",
"I / my organization cannot afford the full training cost and need a scholarship to attend.",
:multiple_choice_checkbox,
key: "scholarship_eligibility", group: "scholarship", required: true,
options: [ "Yes" ])
Expand Down
2 changes: 1 addition & 1 deletion app/services/short_event_registration_form_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def build_scholarship_fields(form, position)
position = add_header(form, position, "Scholarship Application", group: "scholarship")

position = add_field(form, position,
"I / my agency cannot afford the full training cost and need a scholarship to attend.",
"I / my organization cannot afford the full training cost and need a scholarship to attend.",
:multiple_choice_checkbox,
key: "scholarship_eligibility", group: "scholarship", required: true,
options: [ "Yes" ])
Expand Down
8 changes: 4 additions & 4 deletions app/views/contact_us/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -147,12 +147,12 @@
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-1">
Agency / Organization *
Organization *
</label>
<input type="text"
name="contact_us[agency]"
name="contact_us[organization]"
required
data-error-message="Agency / Organization is required"
data-error-message="Organization is required"
class="w-full rounded border border-gray-300 bg-white px-4 py-2.5 text-gray-800 shadow-sm focus:border-blue-500 focus:ring-2 focus:ring-blue-100 focus:outline-none transition">
<p class="field-error hidden mt-1 text-xs text-red-600"></p>
</div>
Expand All @@ -161,7 +161,7 @@
<input type="hidden" name="contact_us[first_name]" value="<%= @user.person&.first_name %>">
<input type="hidden" name="contact_us[last_name]" value="<%= @user.person&.last_name %>">
<input type="hidden" name="contact_us[from]" value="<%= @user.email %>">
<input type="hidden" name="contact_us[agency]" value="<%= @user.person&.primary_organization&.name || '' %>">
<input type="hidden" name="contact_us[organization]" value="<%= @user.person&.primary_organization&.name || '' %>">
<% end %>
<!-- Honeypot -->
<div class="absolute opacity-0 top-0 left-0 h-0 w-0 -z-10" aria-hidden="true">
Expand Down
4 changes: 2 additions & 2 deletions app/views/contact_us_mailer/hello.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
<% end %>
</p>

<% if @contact_us[:agency].present? %>
<% if @contact_us[:organization].present? %>
<p>
<strong>Organization:</strong> <%= @contact_us[:agency] %>
<strong>Organization:</strong> <%= @contact_us[:organization] %>
</p>
<% end %>

Expand Down
Loading