Skip to content

Commit cacbfeb

Browse files
Copilotmaebeale
andcommitted
Changes before error encountered
Co-authored-by: maebeale <7607813+maebeale@users.noreply.github.com>
1 parent 8b3239e commit cacbfeb

File tree

4 files changed

+33
-33
lines changed

4 files changed

+33
-33
lines changed

app/controllers/monthly_reports_controller.rb

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def create
3838
@form_builder = FormBuilder.find(@report.owner_id)
3939
build_month_and_year
4040
load_agencies
41-
@agency_id = report_params["project_id"]
41+
@agency_id = report_params["organization_id"]
4242

4343
flash[:alert] = "There was a problem submitting your form: " +
4444
"#{@report.errors.full_messages.join(" ")}"
@@ -61,7 +61,7 @@ def edit
6161
build_month_and_year
6262
find_form_builder
6363
@report = Report.find(params[:id])
64-
@agencies = current_user.projects.
64+
@agencies = current_user.organizations.
6565
where(windows_type_id: @report.windows_type_id)
6666
@month = @report.date.month
6767
@year = @report.date.year
@@ -85,7 +85,7 @@ def update
8585
flash[:notice] = "Thanks for reporting on a update report. "
8686
redirect_to root_path
8787
else
88-
@agencies = current_user.projects.
88+
@agencies = current_user.organizations.
8989
where(windows_type_id: @report.windows_type_id)
9090

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

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

118118
def load_agencies
119-
@agencies = current_user.projects.
119+
@agencies = current_user.organizations.
120120
where(windows_type_id: @form_builder.windows_type_id).uniq
121121
end
122122

@@ -143,7 +143,7 @@ def find_form_builder
143143
.decorate
144144
end
145145

146-
agency = params[:agency_id] ? Project.find(params[:agency_id]) : current_user.projects.where(windows_type_id: @form_builder.windows_type).first
146+
agency = params[:agency_id] ? Organization.find(params[:agency_id]) : current_user.organizations.where(windows_type_id: @form_builder.windows_type).first
147147
@agency_id = agency.id unless agency.nil?
148148
end
149149

@@ -196,7 +196,7 @@ def build_report_form_fields
196196
end
197197

198198
def find_workshop_logs
199-
@workshop_logs = current_user.project_monthly_workshop_logs(
199+
@workshop_logs = current_user.organization_monthly_workshop_logs(
200200
@report.date, @report.windows_type
201201
)
202202

@@ -207,7 +207,7 @@ def find_workshop_logs
207207

208208
def find_combined_workshop_logs(agency_id)
209209
combined_windows_type = WindowsType.where(short_name: "COMBINED").first
210-
@combined_workshop_logs = current_user.project_workshop_logs(
210+
@combined_workshop_logs = current_user.organization_workshop_logs(
211211
@report.date, combined_windows_type, agency_id)
212212
end
213213

@@ -225,7 +225,7 @@ def report_params
225225
end
226226

227227
params.require(:report).permit(
228-
:type, :project_id, :date, :owner_id, :workshop_id,
228+
:type, :organization_id, :date, :owner_id, :workshop_id,
229229
:owner_type, :windows_type_id, :other_description,
230230
media_files_attributes: [ :file ],
231231
report_form_field_answers_attributes:

app/controllers/reports_controller.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def share_story
2727

2828
@report.owner_type = "FormBuilder"
2929
@report.owner_id = 7
30-
@agencies = current_user.projects
30+
@agencies = current_user.organizations
3131
end
3232

3333
def render_form
@@ -46,7 +46,7 @@ def edit
4646
build_month_and_year
4747
find_form_builder
4848
@report = current_user.submitted_monthly_report(@date, @form_builder.windows_type)
49-
@agencies = current_user.projects.
49+
@agencies = current_user.organizations.
5050
where(windows_type_id: @report.windows_type_id)
5151
@month = @report.date.month
5252
@year = @report.date.year
@@ -60,7 +60,7 @@ def edit_story
6060
.order(title: :asc)
6161

6262
@report = Report.find(params[:id])
63-
@agencies = current_user.projects.
63+
@agencies = current_user.organizations.
6464
where(windows_type_id: @report.windows_type_id)
6565
end
6666

@@ -159,7 +159,7 @@ def create_story
159159
@report.windows_type_id = Workshop.find(@report.workshop_id).windows_type_id
160160
else
161161
@report.workshop_id = nil
162-
@report.windows_type_id = @report.project.windows_type_id
162+
@report.windows_type_id = @report.organization.windows_type_id
163163
end
164164

165165
if @report.save
@@ -233,7 +233,7 @@ def build_report_form_fields
233233
end
234234

235235
def find_workshop_logs
236-
@workshop_logs = current_user.project_monthly_workshop_logs(
236+
@workshop_logs = current_user.organization_monthly_workshop_logs(
237237
@report.date, @report.windows_type
238238
)
239239

@@ -256,7 +256,7 @@ def report_params
256256
end
257257

258258
params.require(:report).permit(
259-
:image, :form_file, :type, :project_id, :date, :workshop_name, :owner_id, :workshop_id,
259+
:image, :form_file, :type, :organization_id, :date, :workshop_name, :owner_id, :workshop_id,
260260
:owner_type, :windows_type_id, report_form_field_answers_attributes:
261261
[ :form_field_id, :answer_option_id, :answer, :_create ],
262262
media_files_attributes: [ :file ],

app/controllers/workshop_logs_controller.rb

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ def index
99
WorkshopLog.all
1010
else
1111
WorkshopLog.where(created_by_id: current_user.id)
12-
.or(WorkshopLog.project_id(current_user.project_ids))
12+
.or(WorkshopLog.organization_id(current_user.organization_ids))
1313
end
1414
@workshop_logs_unpaginated = permitted_logs.includes(:workshop, :user, :windows_type)
1515
.search(params)
@@ -83,7 +83,7 @@ def show
8383
@answers = @workshop_log.report_form_field_answers
8484

8585
if @workshop_log
86-
if current_user.super_user? || (@workshop_log.project && current_user.project_ids.include?(@workshop_log.project.id))
86+
if current_user.super_user? || (@workshop_log.organization && current_user.organization_ids.include?(@workshop_log.organization.id))
8787
render :show
8888
else
8989
redirect_to root_path, error: "You do not have permission to view this page."
@@ -104,7 +104,7 @@ def edit
104104
def validate_new
105105
@date = Date.new(params[:year].to_i, params[:month].to_i)
106106
@windows_type = WindowsType.find(params[:windows_type])
107-
@report = current_user.submitted_monthly_report(@date, @windows_type, params[:project_id])
107+
@report = current_user.submitted_monthly_report(@date, @windows_type, params[:organization_id])
108108

109109
render json: { validate: @report.nil? }.to_json
110110
end
@@ -125,10 +125,10 @@ def set_index_variables # needs to not be private
125125
.distinct
126126
.order(:last_name, :first_name)
127127
@projects = if current_user.super_user?
128-
# Project.where(id: @workshop_logs_unpaginated.pluck(:project_id)).order(:name)
129-
Project.active.order(:name)
128+
# Organization.where(id: @workshop_logs_unpaginated.pluck(:organization_id)).order(:name)
129+
Organization.active.order(:name)
130130
else
131-
current_user.projects.order(:name)
131+
current_user.organizations.order(:name)
132132
end
133133
@workshops = Workshop.where(id: @workshop_logs_unpaginated.select(:workshop_id).distinct)
134134
.order(:title)
@@ -182,11 +182,11 @@ def set_form_variables
182182
end
183183

184184
@agencies =
185-
Project.where(id: current_user.projects.select(:id))
186-
.or(Project.where(id: @workshop_log.project_id))
187-
.distinct
188-
.order(:name)
189-
agency = params[:agency_id].present? ? Project.where(id: params[:agency_id]).last : @agencies.first
185+
Organization.where(id: current_user.organizations.select(:id))
186+
.or(Organization.where(id: @workshop_log.organization_id))
187+
.distinct
188+
.order(:name)
189+
agency = params[:agency_id].present? ? Organization.where(id: params[:agency_id]).last : @agencies.first
190190
@agency_id = agency.id if agency
191191
end
192192

@@ -210,7 +210,7 @@ def set_workshop
210210
def workshop_log_params
211211
params.require(:workshop_log).permit(
212212
:children_ongoing, :children_first_time, :teens_ongoing, :teens_first_time,
213-
:adults_ongoing, :adults_first_time, :owner_id, :owner_type, :user_id, :project_id, :date,
213+
:adults_ongoing, :adults_first_time, :owner_id, :owner_type, :user_id, :organization_id, :date,
214214
:workshop_name, :workshop_id, :windows_type_id, :other_description, # :user,
215215
quotable_item_quotes_attributes: [
216216
:id, :quotable_type, :quotable_id, :_destroy,

app/models/user.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -123,11 +123,11 @@ def recent_activity(activity_limit = 10)
123123
recent.sort_by { |item| item.try(:updated_at) || item.created_at }.reverse.first(activity_limit * 8)
124124
end
125125

126-
def project_monthly_workshop_logs(date, *windows_type)
126+
def organization_monthly_workshop_logs(date, *windows_type)
127127
where = windows_type.map { |wt| "windows_type_id = ?" }
128128

129-
logs = projects.map do |project|
130-
project.workshop_logs.where(where.join(" OR "), *windows_type)
129+
logs = organizations.map do |organization|
130+
organization.workshop_logs.where(where.join(" OR "), *windows_type)
131131
end.flatten
132132
logs = logs.select do |log|
133133
log.date && log.date.month == date.month.to_i &&
@@ -136,9 +136,9 @@ def project_monthly_workshop_logs(date, *windows_type)
136136
logs.uniq.group_by { |log| log.date }
137137
end
138138

139-
def project_workshop_logs(date, windows_type, project_id)
140-
if project_id
141-
logs = workshop_logs.where(project_id: project_id, windows_type_id: windows_type.id)
139+
def organization_workshop_logs(date, windows_type, organization_id)
140+
if organization_id
141+
logs = workshop_logs.where(organization_id: organization_id, windows_type_id: windows_type.id)
142142
logs = logs.select do |log|
143143
log.date && log.date.month == date.month.to_i &&
144144
log.date.year == date.year.to_i

0 commit comments

Comments
 (0)