Skip to content

Commit 86cad60

Browse files
committed
feat: Add ability to mark a school as a home school
Fixes #157
1 parent 3d1d1c1 commit 86cad60

File tree

11 files changed

+29
-6
lines changed

11 files changed

+29
-6
lines changed

app/assets/javascripts/manage/lib/setupDataTables.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,14 @@ var setupDataTables = function() {
4242
});
4343

4444
$('.datatable.schools').DataTable({
45-
order: [4, 'desc'],
45+
order: [[5, 'desc'], [4, 'desc']],
4646
columns: [
4747
{ orderable: true, data: 'id', visible: false },
4848
{ orderable: true, data: 'name' },
4949
{ orderable: true, data: 'city' },
5050
{ orderable: true, data: 'state' },
5151
{ orderable: true, data: 'questionnaire_count' },
52+
{ orderable: true, data: 'home_school' },
5253
],
5354
});
5455

app/controllers/manage/dashboard_controller.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def application_activity_data
4949
def user_distribution_data
5050
total_stats_data = {}
5151
total_count = Questionnaire.count
52-
rit_count = Questionnaire.where("school_id = \"2304\"").count
52+
rit_count = Questionnaire.joins(:school).where("schools.is_home = true").count
5353
total_stats_data["Incomplete Applications"] = User.without_questionnaire.count
5454
total_stats_data["Away Applications"] = total_count - rit_count
5555
total_stats_data["Home Applications"] = rit_count
@@ -117,9 +117,9 @@ def activity_chart_data(types, group_type, range, where_filter = nil)
117117
when "Applications"
118118
data = Questionnaire.send("group_by_#{group_type}", :created_at, range: range)
119119
when "Home Applications"
120-
data = Questionnaire.where("school_id = \"2304\"").send("group_by_#{group_type}", :created_at, range: range)
120+
data = Questionnaire.joins(:school).where("schools.is_home = true").send("group_by_#{group_type}", :created_at, range: range)
121121
when "Away Applications"
122-
data = Questionnaire.where("school_id != \"2304\"").send("group_by_#{group_type}", :created_at, range: range)
122+
data = Questionnaire.joins(:school).where("schools.is_home != true").send("group_by_#{group_type}", :created_at, range: range)
123123
when "Confirmations"
124124
data = Questionnaire.where(acc_status: "rsvp_confirmed").send("group_by_#{group_type}", :acc_status_date, range: range)
125125
when "Denials"

app/controllers/manage/schools_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ def perform_merge
7878

7979
def school_params
8080
params.require(:school).permit(
81-
:name, :address, :city, :state
81+
:name, :address, :city, :state, :is_home
8282
)
8383
end
8484

app/datatables/school_datatable.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ def view_columns
88
city: { source: "School.city" },
99
state: { source: "School.state" },
1010
questionnaire_count: { source: "School.questionnaire_count", searchable: false },
11+
home_school: { source: "School.is_home", searchable: false },
1112
}
1213
end
1314

@@ -21,6 +22,7 @@ def data
2122
city: record.city,
2223
state: record.state,
2324
questionnaire_count: record.questionnaire_count,
25+
home_school: record.is_home ? '<span class="badge badge-success">Yes</span>'.html_safe : '<span class="badge badge-secondary">No</span>'.html_safe,
2426
}
2527
end
2628
end

app/views/manage/schools/_form.html.haml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
.form-inputs
99
= f.input :name
10+
= f.input :is_home
1011
= f.input :address
1112
= f.input :city
1213
= f.input :state

app/views/manage/schools/index.html.haml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
%th City
1111
%th State
1212
%th Count
13+
%th Home?
1314
%tbody
1415
%tfoot
1516
%tr
@@ -21,3 +22,4 @@
2122
%input.form-control.form-control-sm{autocomplete: 'off', placeholder: 'City'}
2223
%th
2324
%input.form-control.form-control-sm{autocomplete: 'off', placeholder: 'State'}
25+
%th

app/views/manage/schools/show.html.haml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@
4040
= link_to link, target: '_blank' do
4141
Search in Google Maps
4242
%span.fa.fa-external-link.icon-space-l-half
43+
%dt.col-md-4 Home school
44+
%dd.col-md-8
45+
- if @school.is_home?
46+
%span.badge.badge-success Home school
47+
- else
48+
%span.badge.badge-secondary Not home school
4349

4450
.col-md-6
4551
%h4.pb-0 Duplicate Names

config/locales/en.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ en:
5050
type: Bulk emails are sent once, manually. Automated emails are sent upon a desired trigger/event.
5151
name: A friendly name to recognize this email. Applicants won't see this.
5252
trigger: Sent automatically when a new or updated applicant matches this criteria. Does not send to anyone already matching this criteria.
53+
school:
54+
is_home: The "home" school is separated from all other schools on dashboard metrics.
5355
hackathon_config:
5456
registration_is_open: Specify that registration is open. This does <strong>not</strong> block registration; it only changes messaging around it.
5557
event_is_over: Specify that the event is over
@@ -102,6 +104,8 @@ en:
102104
user:
103105
104106
labels:
107+
school:
108+
is_home: Home school
105109
user:
106110
is_active: Login access
107111
hackathon_config:
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
class AddIsHomeToSchools < ActiveRecord::Migration[5.2]
2+
def change
3+
add_column :schools, :is_home, :boolean, default: false
4+
end
5+
end

db/schema.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#
1111
# It's strongly recommended that you check this file into your version control system.
1212

13-
ActiveRecord::Schema.define(version: 2019_05_28_155025) do
13+
ActiveRecord::Schema.define(version: 2019_05_29_190615) do
1414

1515
create_table "active_storage_attachments", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t|
1616
t.string "name", null: false
@@ -241,6 +241,7 @@
241241
t.datetime "created_at"
242242
t.datetime "updated_at"
243243
t.integer "questionnaire_count", default: 0
244+
t.boolean "is_home", default: false
244245
end
245246

246247
create_table "settings", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t|

0 commit comments

Comments
 (0)