Skip to content

Commit

Permalink
Visiting /organizations shows a map of the last event for every chapter
Browse files Browse the repository at this point in the history
  • Loading branch information
tjgrathwell committed Feb 20, 2016
1 parent 9a99904 commit e383386
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 10 deletions.
8 changes: 4 additions & 4 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ GEM
tzinfo (~> 1.1)
addressable (2.4.0)
arel (6.0.3)
autoprefixer-rails (6.3.2)
autoprefixer-rails (6.3.3)
execjs
json
awesome_print (1.6.1)
Expand Down Expand Up @@ -176,7 +176,7 @@ GEM
multi_xml (0.5.5)
multipart-post (2.0.0)
nested_form (0.3.2)
newrelic_rpm (3.14.3.313)
newrelic_rpm (3.15.0.314)
nokogiri (1.6.7.2)
mini_portile2 (~> 2.0.0.rc2)
nokogumbo (1.4.7)
Expand Down Expand Up @@ -270,7 +270,7 @@ GEM
railties (>= 4.2.0, < 5.1)
rspec-collection_matchers (1.1.2)
rspec-expectations (>= 2.99.0.beta1)
rspec-core (3.4.2)
rspec-core (3.4.3)
rspec-support (~> 3.4.0)
rspec-expectations (3.4.0)
diff-lcs (>= 1.2.0, < 2.0)
Expand Down Expand Up @@ -327,7 +327,7 @@ GEM
uniform_notifier (1.9.0)
warden (1.2.6)
rack (>= 1.0)
webmock (1.22.6)
webmock (1.24.0)
addressable (>= 2.3.6)
crack (>= 0.3.2)
hashdiff
Expand Down
4 changes: 4 additions & 0 deletions app/assets/stylesheets/_base.scss
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,10 @@ ul.bulleted {
height: 300px;
}

.gmaps4rails_bigger_map {
height: 550px;
}

.location-display .gmaps4rails_map {
width: 100%;
}
Expand Down
15 changes: 15 additions & 0 deletions app/controllers/organizations_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
class OrganizationsController < ApplicationController
def index
skip_authorization
@organizations = Organization.all
chapter_last_event_ids = Event
.published
.select('max(id) as event_id, chapter_id')
.group(:chapter_id)
.map(&:event_id)
@chapter_locations = Event
.includes(:location)
.where(id: chapter_last_event_ids)
.map(&:location)
end
end
12 changes: 7 additions & 5 deletions app/models/event.rb
Original file line number Diff line number Diff line change
Expand Up @@ -363,11 +363,13 @@ def levels
end

def set_defaults
self.details ||= Event::DEFAULT_DETAILS['default_details.html']
self.student_details ||= Event::DEFAULT_DETAILS['default_student_details.html']
self.volunteer_details ||= Event::DEFAULT_DETAILS['default_volunteer_details.html']
self.survey_greeting ||= Event::DEFAULT_DETAILS['default_survey_greeting.html']
self.allowed_operating_system_ids ||= OperatingSystem.all.map(&:id)
if self.has_attribute?(:details)
self.details ||= Event::DEFAULT_DETAILS['default_details.html']
self.student_details ||= Event::DEFAULT_DETAILS['default_student_details.html']
self.volunteer_details ||= Event::DEFAULT_DETAILS['default_volunteer_details.html']
self.survey_greeting ||= Event::DEFAULT_DETAILS['default_survey_greeting.html']
self.allowed_operating_system_ids ||= OperatingSystem.all.map(&:id)
end
end

def association_for_role(role, waitlisted: false)
Expand Down
1 change: 1 addition & 0 deletions app/views/organizations/index.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<%= render "shared/map", locations: @chapter_locations, map_class: 'gmaps4rails_bigger_map' %>
2 changes: 1 addition & 1 deletion app/views/shared/_map.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div class="gmaps4rails_map" id="gmaps4rails_map"></div>
<div class="<%= local_assigns[:map_class] || 'gmaps4rails_map' %>" id="gmaps4rails_map"></div>
<%
markers = Gmaps4rails.build_markers(locations) do |location, marker|
marker.lat location.latitude
Expand Down
4 changes: 4 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,21 @@
resources :locations do
patch :archive, on: :member
end

resources :chapters do
resources :leaders, only: [:index, :create, :destroy], controller: 'chapters/leaders' do
get :potential, on: :collection
end
end

resources :regions do
resources :leaders, only: [:index, :create, :destroy], controller: 'regions/leaders' do
get :potential, on: :collection
end
end

resources :organizations, only: [:index]

resources :events do
resources :organizers, only: [:index, :create, :destroy] do
get :potential, on: :collection
Expand Down

0 comments on commit e383386

Please sign in to comment.