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
4 changes: 2 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ GEM
bigdecimal (4.0.1)
bootsnap (1.21.1)
msgpack (~> 1.2)
brakeman (8.0.1)
brakeman (8.0.2)
racc
builder (3.3.0)
bullet (8.1.0)
Expand Down Expand Up @@ -668,7 +668,7 @@ CHECKSUMS
bigdecimal (4.0.1) sha256=8b07d3d065a9f921c80ceaea7c9d4ae596697295b584c296fe599dd0ad01c4a7
binding_of_caller (1.0.1)
bootsnap (1.21.1) sha256=9373acfe732da35846623c337d3481af8ce77c7b3a927fb50e9aa92b46dbc4c4
brakeman (8.0.1) sha256=c68ce0ac35a6295027c4eab8b4ac597d2a0bfc82f0d62dcd334bbf944d352f70
brakeman (8.0.2) sha256=7b02065ce8b1de93949cefd3f2ad78e8eb370e644b95c8556a32a912a782426a
builder (3.3.0) sha256=497918d2f9dca528fdca4b88d84e4ef4387256d984b8154e9d5d3fe5a9c8835f
bullet (8.1.0) sha256=604b7e2636ec2137dcab3ba61a56248c39a0004a0c9405d58bad0686d23b98ff
bundler-audit (0.9.3) sha256=81c8766c71e47d0d28a0f98c7eed028539f21a6ea3cd8f685eb6f42333c9b4e9
Expand Down
10 changes: 5 additions & 5 deletions app/controllers/admin/analytics_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def index
@most_viewed_stories = decorate_with_counts(most_viewed_for_model(Story, time_scope), :view_count)
@most_viewed_quotes = decorate_with_counts(most_viewed_for_model(Quote, time_scope), :view_count)
@most_viewed_tutorials = decorate_with_counts(most_viewed_for_model(Tutorial, time_scope), :view_count)
@most_viewed_projects = decorate_with_counts(most_viewed_for_model(Project, time_scope), :view_count)
@most_viewed_organizations = decorate_with_counts(most_viewed_for_model(Organization, time_scope), :view_count)
@most_viewed_events = decorate_with_counts(most_viewed_for_model(Event, time_scope), :view_count)
@most_viewed_facilitators = decorate_with_counts(most_viewed_for_model(Facilitator, time_scope), :view_count)

Expand All @@ -25,7 +25,7 @@ def index
# @most_printed_workshop_variations = decorate_with_counts(most_printed_for_model(WorkshopVariation, time_scope), :print_count)
# @most_printed_quotes = decorate_with_counts(most_printed_for_model(Quote, time_scope), :print_count)
# @most_printed_tutorials = decorate_with_counts(most_printed_for_model(Tutorial, time_scope), :print_count)
# @most_printed_projects = decorate_with_counts(most_printed_for_model(Project, time_scope), :print_count)
# @most_printed_organizations = decorate_with_counts(most_printed_for_model(Organization, time_scope), :print_count)
# @most_printed_events = decorate_with_counts(most_printed_for_model(Event, time_scope), :print_count)

@most_downloaded_resources = decorate_with_counts(most_downloaded_for_model(Resource, time_scope), :download_count)
Expand Down Expand Up @@ -67,9 +67,9 @@ def index
views: view_count_for_model(Tutorial, time_scope),
prints: print_count_for_model(Tutorial, time_scope)
},
projects: {
views: view_count_for_model(Project, time_scope),
prints: print_count_for_model(Project, time_scope)
organizations: {
views: view_count_for_model(Organization, time_scope),
prints: print_count_for_model(Organization, time_scope)
},
facilitators: {
views: view_count_for_model(Facilitator, time_scope)
Expand Down
6 changes: 3 additions & 3 deletions app/controllers/community_news_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ def index
per_page = params[:number_of_items_per_page].presence || 12
unfiltered = current_user.super_user? ? CommunityNews.all : CommunityNews.published
filtered = unfiltered.search_by_params(params)
@community_news = filtered&.includes([ :bookmarks, :primary_asset, :author, :project, author: :facilitator ])
@community_news = filtered&.includes([ :bookmarks, :primary_asset, :author, :organization, author: :facilitator ])
&.paginate(page: params[:page], per_page: per_page)&.decorate

@count_display = if filtered.count == unfiltered.count
Expand Down Expand Up @@ -79,7 +79,7 @@ def destroy

# Optional hooks for setting variables for forms or index
def set_form_variables
@organizations = Project.pluck(:name, :id).sort_by(&:first)
@organizations = Organization.pluck(:name, :id).sort_by(&:first)
@authors = User.active.or(User.where(id: @community_news.author_id))
.map { |u| [ u.full_name, u.id ] }.sort_by(&:first)
end
Expand All @@ -95,7 +95,7 @@ def community_news_params
params.require(:community_news).permit(
:title, :rhino_body, :published, :featured, :public, :public_featured,
:reference_url, :youtube_url,
:project_id,
:organization_id,
:author_id, :created_by_id, :updated_by_id
)
end
Expand Down
16 changes: 8 additions & 8 deletions app/controllers/facilitators_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ def index
facilitators = Facilitator
.searchable
.search_by_params(params.to_unsafe_h)
.includes(:user, :avatar_attachment, :sectorable_items, user: [ :avatar_attachment, :projects ]).references(:user)
.includes(:user, :avatar_attachment, :sectorable_items, user: [ :avatar_attachment, :organizations ]).references(:user)
.order(:first_name, :last_name)
@count_display = facilitators.size
@facilitators = facilitators.paginate(page: params[:page], per_page: per_page)
Expand Down Expand Up @@ -82,14 +82,14 @@ def set_form_variables
# @facilitator.build_user if @facilitator.user.blank? # Build a fresh one if missing

if @facilitator.user
@facilitator.user.project_users.first || @facilitator.user.project_users.build
@facilitator.user.organization_users.first || @facilitator.user.organization_users.build
end
projects = if current_user.super_user?
Project.active
organizations = if current_user.super_user?
Organization.active
else
current_user.projects
current_user.organizations
end
@projects_array = projects.order(:name).pluck(:name, :id)
@organizations_array = organizations.order(:name).pluck(:name, :id)
end


Expand Down Expand Up @@ -177,9 +177,9 @@ def facilitator_params
:state2,
:zip2,
:notes,
project_users_attributes: [
organization_users_attributes: [
:id,
:project_id,
:organization_id,
:position,
:title,
:inactive,
Expand Down
18 changes: 9 additions & 9 deletions app/controllers/monthly_reports_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def create
@form_builder = FormBuilder.find(@report.owner_id)
build_month_and_year
load_agencies
@agency_id = report_params["project_id"]
@agency_id = report_params["organization_id"]

flash[:alert] = "There was a problem submitting your form: " +
"#{@report.errors.full_messages.join(" ")}"
Expand All @@ -61,7 +61,7 @@ def edit
build_month_and_year
find_form_builder
@report = Report.find(params[:id])
@agencies = current_user.projects.
@agencies = current_user.organizations.
where(windows_type_id: @report.windows_type_id)
@month = @report.date.month
@year = @report.date.year
Expand All @@ -85,7 +85,7 @@ def update
flash[:notice] = "Thanks for reporting on a update report. "
redirect_to root_path
else
@agencies = current_user.projects.
@agencies = current_user.organizations.
where(windows_type_id: @report.windows_type_id)

flash[:alert] = "ERROR!!!!!!!!!!!!!!"
Expand All @@ -102,7 +102,7 @@ def show
@answers = @monthly_report.report_form_field_answers

if @monthly_report
if current_user.super_user? || (@monthly_report.project && current_user.project_ids.include?(@monthly_report.project.id))
if current_user.super_user? || (@monthly_report.organization && current_user.organization_ids.include?(@monthly_report.organization.id))
render :show
else
redirect_to root_path, error: "You do not have permission to view this page."
Expand All @@ -116,7 +116,7 @@ def show
private

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

Expand All @@ -143,7 +143,7 @@ def find_form_builder
.decorate
end

agency = params[:agency_id] ? Project.find(params[:agency_id]) : current_user.projects.where(windows_type_id: @form_builder.windows_type).first
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?
end

Expand Down Expand Up @@ -196,7 +196,7 @@ def build_report_form_fields
end

def find_workshop_logs
@workshop_logs = current_user.project_monthly_workshop_logs(
@workshop_logs = current_user.organization_monthly_workshop_logs(
@report.date, @report.windows_type
)

Expand All @@ -207,7 +207,7 @@ def find_workshop_logs

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

Expand All @@ -225,7 +225,7 @@ def report_params
end

params.require(:report).permit(
:type, :project_id, :date, :owner_id, :workshop_id,
:type, :organization_id, :date, :owner_id, :workshop_id,
:owner_type, :windows_type_id, :other_description,
media_files_attributes: [ :file ],
report_form_field_answers_attributes:
Expand Down
68 changes: 68 additions & 0 deletions app/controllers/organization_statuses_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
class OrganizationStatusesController < Admin::BaseController
before_action :set_organization_status, only: [ :show, :edit, :update, :destroy ]

def index
per_page = params[:number_of_items_per_page].presence || 25
unfiltered = OrganizationStatus.all
@count_display = unfiltered.count
@organization_statuses = unfiltered.paginate(page: params[:page], per_page: per_page).decorate
end

def show
@organization_status = @organization_status.decorate
end

def new
@organization_status = OrganizationStatus.new.decorate
set_form_variables
end

def edit
@organization_status = @organization_status.decorate
set_form_variables
end

def create
@organization_status = OrganizationStatus.new(organization_status_params)

if @organization_status.save
redirect_to organization_statuses_path, notice: "Organization status was successfully created."
else
@organization_status = OrganizationStatus.new.decorate
set_form_variables
render :new, status: :unprocessable_content
end
end

def update
if @organization_status.update(organization_status_params)
redirect_to organization_statuses_path, notice: "Organization status was successfully updated.", status: :see_other
else
@organization_status = OrganizationStatus.new.decorate
set_form_variables
render :edit, status: :unprocessable_content
end
end

def destroy
@organization_status.destroy!
redirect_to organization_statuses_path, notice: "Organization status was successfully destroyed."
end

# Optional hooks for setting variables for forms or index
def set_form_variables
end

private

def set_organization_status
@organization_status = OrganizationStatus.find(params[:id])
end

# Strong parameters
def organization_status_params
params.require(:organization_status).permit(
:name
)
end
end
13 changes: 13 additions & 0 deletions app/controllers/organization_users_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
class OrganizationUsersController < ApplicationController
def destroy
organization_user = OrganizationUser.find(params[:id])
user = organization_user.user

if organization_user.destroy
flash[:notice] = "Organization user has been deleted."
else
flash[:alert] = "Unable to delete organization user. Please contact AWBW."
end
redirect_to generate_facilitator_user_path(user)
end
end
Loading