Skip to content

Commit

Permalink
Merge 9c36b38 into 90b966d
Browse files Browse the repository at this point in the history
  • Loading branch information
pcantrell committed Aug 19, 2020
2 parents 90b966d + 9c36b38 commit d73717d
Show file tree
Hide file tree
Showing 22 changed files with 151 additions and 97 deletions.
2 changes: 1 addition & 1 deletion src/app/controllers/categories_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class CategoriesController < ApplicationController
def show
@category = Category.find(params[:id])
@sessions = @category.sessions.for_current_event
@sessions = @category.sessions.for_current_event.includes(:event, :presenters)
end
end
13 changes: 12 additions & 1 deletion src/app/controllers/events_controller.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,19 @@
class EventsController < ApplicationController
def show
@event = Event.includes(:sessions).find(params[:id])
@event = if params[:id] == 'current'
Event.current_event
else
Event.includes(:sessions).find(params[:id])
end

respond_to do |format|
format.html do
@recent_sessions = @event ? @event.sessions.limit(4).recent : []
@random_sessions = @event ? @event.sessions.limit(6).random_order : []

@categories = Category.all.order('id')
end

format.json do
render json: @event.to_json(include: { sessions: { methods: [:starts_at, :room_name, :presenter_names] } })
end
Expand Down
9 changes: 0 additions & 9 deletions src/app/controllers/pages_controller.rb

This file was deleted.

6 changes: 3 additions & 3 deletions src/app/controllers/sessions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ def destroy
end

def index
if params[:event_id].present?
@event = Event.find(params[:event_id])
else
if params[:event_id].blank? || params[:event_id] == 'current'
@event = Event.current_event
else
@event = Event.find(params[:event_id])
end

respond_to do |format|
Expand Down
4 changes: 3 additions & 1 deletion src/app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ def add_sessions_button
end

def toggle_attendance_button(session)
content_tag(:button, "Attending", class: "toggle-attendance", 'data-session-id': session.id)
if session.event.current?
content_tag(:button, "Attending", class: "toggle-attendance", 'data-session-id': session.id)
end
end
end
7 changes: 7 additions & 0 deletions src/app/models/event.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,11 @@ class Event < ActiveRecord::Base
def self.current_event(opts = {})
Event.order(:date).last
end

def current?
if @current.nil?
@current = self == Event.current_event
end
@current
end
end
1 change: 1 addition & 0 deletions src/app/models/session.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class Session < ActiveRecord::Base
scope :with_attendence_count, -> { select('*').joins("LEFT OUTER JOIN (SELECT session_id, count(id) AS attendence_count FROM attendances GROUP BY session_id) AS attendence_aggregation ON attendence_aggregation.session_id = sessions.id") }

scope :for_current_event, -> { where(event_id: Event.current_event.id) }
scope :for_past_events, -> { where.not(event_id: Event.current_event.id).includes(:event).order('events.date desc') }

scope :recent, -> { order('created_at desc') }

Expand Down
3 changes: 2 additions & 1 deletion src/app/views/categories/show.html.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<% title("#{@category.name} Sessions") %>
<% title("#{@category.name} Sessions at #{Event.current_event.name}") %>

<p><%= add_sessions_button %></p>
<% if @sessions.empty? %>
<div>
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<div class="column grid_<%= grid %>">
<h3>Sessions about <%= category.name %></h3>
<ul class="sessionsList">
<%= render category.sessions.for_current_event.random_order.limit(5) %>
<%= render category.sessions.where(event: @event).random_order.limit(5) %>
</ul>
<p class="more_sessions"><%= link_to 'See more...', category_path(category) %></p>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
<ul class="sessionsList">
<%= render @random_sessions %>
</ul>
<p class="more_sessions"><%= link_to 'See all sessions', sessions_path %></p>
<p class="more_sessions"><%= link_to 'See all sessions', event_sessions_path(event_id: @event) %></p>

<h2>Recently Added</h2>
<ul class="sessionsList">
<%= render @recent_sessions %>
</ul>
<p class="more_sessions"><%= link_to 'See all sessions', sessions_path %></p>
<p class="more_sessions"><%= link_to 'See all sessions', event_sessions_path(event_id: @event) %></p>

<div class="row">
<%= render 'category_grid', category: @categories.first, grid: 3 %>
Expand Down
25 changes: 25 additions & 0 deletions src/app/views/events/show.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<% title("#{@event&.name || t('conference')} Session Registration") %>

<div class="row">
<div class="column grid_6" style="margin-left:0px">
<% if @event&.current? %>
<p>Welcome to the <%= t('conference') %> session planning tool.</p>
<% else %>
<p>
<b>This is a past event.</b>
<%= link_to "See sessions for the current #{t('conference')} >", home_page_path %>
</p>
<% end %>
<% if @event %>
<%= render 'sessions' %>
<% else %>
<h2>No event is being held right now</h2>
<% end %>
</div>

<%= render partial: 'events/aside' %>

</div>


18 changes: 0 additions & 18 deletions src/app/views/pages/home.html.erb

This file was deleted.

8 changes: 7 additions & 1 deletion src/app/views/participants/_session.html.erb
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
<li><h3><%= link_to session.title, session %></h3></li>
<li>
<b><%= link_to session.title, session %></b>
<% if session.event_id != Event.current_event.id %>
<br/>
<small><%= link_to session.event.name, event_sessions_path(event_id: session.event_id) %></small>
<% end %>
</li>
18 changes: 14 additions & 4 deletions src/app/views/participants/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,23 @@
<div class="column grid_5">
<h3>Presenting Sessions</h3>

<% if @participant.sessions_presenting.empty? %>
<% current_sessions_presenting = @participant.sessions_presenting.for_current_event %>
<% if current_sessions_presenting.empty? %>
<p>This person isn't presenting any sessions.</p>
<% else %>
<ul class="sessionsList">
<%= render :partial => 'session', :collection => current_sessions_presenting %>
</ul>
<% end %>
<ul class="sessionsList">
<%= render :partial => 'session', :collection => @participant.sessions_presenting.for_current_event %>
</ul>
<% past_sessions_present = @participant.sessions_presenting.for_past_events %>
<% if past_sessions_present.any? %>
<h3>Past Presentations</h3>

<ul class="sessionsList">
<%= render :partial => 'session', :collection => past_sessions_present %>
</ul>
<% end %>
</div>

<div class="column grid_5">
Expand Down
11 changes: 9 additions & 2 deletions src/app/views/sessions/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
<% title('All Sessions') %>
(most recently added first)
<% title("#{@event.name} – All Sessions") %>
<p>(most recently added first)</p>

<% cache [current_participant] + event_schedule_cache_key(@event) do # fragment contains user-specific info %>
<% unless @event.current? %>
<p>
<b>This is a past event.</b>
<%= link_to "See sessions for the current #{t('conference')} >", sessions_path %>
</p>
<% end %>
<div class="row">
<p><%= add_sessions_button %></p>
<div class="column grid_10" style="margin-left:0px">
Expand Down
53 changes: 29 additions & 24 deletions src/app/views/sessions/show.html.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<% title(@session.title) %>
<% content_for :edit do %>
<% edit(@session) do %>
(<%= link_to 'edit', edit_session_path(@session) %>)
<% if @session.event.current? %>
<% edit(@session) do %>
(<%= link_to 'edit', edit_session_path(@session) %>)
<% end %>
<% end %>
<% end %>

Expand All @@ -11,6 +13,8 @@
(<%= link_to 'manage presenters', session_presentations_path(@session) %>)
<% end %>

| at <%= link_to @session.event.name, @session.event %>
<% if @session.timeslot && Settings.show_schedule? %>
|
<b><%= @session.timeslot.date_range.to_s(with_day: false) %></b>
Expand All @@ -20,7 +24,6 @@
|
<%= link_to 'View Schedule', schedule_path(force: 1) %>
<% end %>

</p>

<div class="row">
Expand Down Expand Up @@ -73,27 +76,29 @@
<% end %>
</div>

<div class="column grid_4">

<div id="interested-in-attending">
<% if !@session.attending?(current_participant) %>
<h3>Are you interested in this session?</h3>
<p>This will add your name to the list of interested participants. It will help us gauge interest for scheduling purposes.</p>
<button class="button yellow" id="attend">
<div class="meta">minnebar</div>
<div class="title">Yes! I might attend.</div>
</button>
<% if @session.event.current? %>
<div class="column grid_4">

<div id="interested-in-attending">
<% if !@session.attending?(current_participant) %>
<h3>Are you interested in this session?</h3>
<p>This will add your name to the list of interested participants. It will help us gauge interest for scheduling purposes.</p>
<button class="button yellow" id="attend">
<div class="meta">minnebar</div>
<div class="title">Yes! I might attend.</div>
</button>
<% end %>
</div>

<% if @session.participants.any? %>
<h3>Interested Participants</h3>
<% else %>
<h3 id="no-participants">No participants yet</h3>
<% end %>
</div>

<% if @session.participants.any? %>
<h3>Interested Participants</h3>
<% else %>
<h3 id="no-participants">No participants yet</h3>
<% end %>
<ul class="sessionsList" id="participants">
<%= render :partial => 'participant', :collection => @session.participants %>
</ul>
<ul class="sessionsList" id="participants">
<%= render :partial => 'participant', :collection => @session.participants %>
</ul>

</div>
</div>
<% end %>
</div>
11 changes: 8 additions & 3 deletions src/config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
Sessionizer::Application.routes.draw do
root to: 'schedules#index'

get '/home' => 'pages#home', as: :home_page
get '/home' => 'events#show', id: 'current', as: :home_page

# Session actions available for all events
resources :events do
resources :sessions, :only => [:index]
end

# Session actions available only for the current event
resources :sessions, :only => [:index, :show, :new, :create, :update, :edit, :destroy] do
collection do
get :words
Expand All @@ -12,11 +18,10 @@
resource :attendance, :only => [:create, :destroy]
resources :presentations, :only => [:index, :create]
end
get '/attendances' => 'attendances#index'

get '/attendances' => 'attendances#index'
resources :participants, :except => [:destroy]
resources :categories, only: :show
resources :events, only: :show

match '/login' => 'user_sessions#new', :as => :new_login, :via => 'get'
match '/login' => 'user_sessions#create', :as => :login, :via => 'post'
Expand Down
20 changes: 18 additions & 2 deletions src/spec/controllers/events_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
require 'spec_helper'

describe EventsController do
let(:event) { FactoryGirl.create(:event) }
context "with an event" do
let!(:event) { create(:event, :full_event) }

it "should show the sessions" do
get :show, params: { id: 'current' }
expect(response).to be_successful
expect(assigns[:recent_sessions]).to be_empty
expect(assigns[:categories]).to all(be_kind_of Category)
end

context 'show' do
context 'in JSON format' do
it 'is successful' do
get :show, params: {id: event, format: :json}
Expand All @@ -12,4 +19,13 @@
end
end
end

context "without an event" do
it "should have an empty list of sessions" do
get :show, params: { id: 'current' }
expect(response).to be_successful
expect(assigns[:recent_sessions]).to be_empty
expect(assigns[:categories]).to all(be_kind_of Category)
end
end
end
23 changes: 0 additions & 23 deletions src/spec/controllers/pages_controller_spec.rb

This file was deleted.

0 comments on commit d73717d

Please sign in to comment.