Merge pull request #303 from gopesht/modify_date_helper
Removed conference_date_string_helper, moved date_string helper to application_controller
This commit is contained in:
commit
50e75c6dd4
6 changed files with 34 additions and 40 deletions
|
|
@ -3,6 +3,7 @@ class ApplicationController < ActionController::Base
|
||||||
protect_from_forgery
|
protect_from_forgery
|
||||||
before_filter :get_conferences
|
before_filter :get_conferences
|
||||||
before_filter :store_location
|
before_filter :store_location
|
||||||
|
helper_method :date_string
|
||||||
|
|
||||||
def store_location
|
def store_location
|
||||||
session[:return_to] = request.fullpath if request.get? and controller_name != "user_sessions" and controller_name != "sessions"
|
session[:return_to] = request.fullpath if request.get? and controller_name != "user_sessions" and controller_name != "sessions"
|
||||||
|
|
@ -76,4 +77,32 @@ class ApplicationController < ActionController::Base
|
||||||
def not_found
|
def not_found
|
||||||
raise ActionController::RoutingError.new('Not Found')
|
raise ActionController::RoutingError.new('Not Found')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
##
|
||||||
|
# Returns a string build from the start and end date of the given conference.
|
||||||
|
#
|
||||||
|
# If the conference starts and ends in the same month and year
|
||||||
|
# * %B %d - %d, %Y (January 17 - 21 2014)
|
||||||
|
# If the conference ends in another month but in the same year
|
||||||
|
# * %B %d - %B %d, %Y (January 31 - February 02 2014)
|
||||||
|
# All other cases
|
||||||
|
# * %B %d, %Y - %B %d, %Y (December 30, 2013 - January 02, 2014)
|
||||||
|
def date_string(start_date, end_date)
|
||||||
|
startstr = 'Unknown - '
|
||||||
|
endstr = 'Unknown'
|
||||||
|
# When the conference in the same month
|
||||||
|
if start_date.month == end_date.month && start_date.year == end_date.year
|
||||||
|
startstr = start_date.strftime('%B %d - ')
|
||||||
|
endstr = end_date.strftime('%d, %Y')
|
||||||
|
elsif start_date.month != end_date.month && start_date.year == end_date.year
|
||||||
|
startstr = start_date.strftime('%B %d - ')
|
||||||
|
endstr = end_date.strftime('%B %d, %Y')
|
||||||
|
else
|
||||||
|
startstr = start_date.strftime('%B %d, %Y - ')
|
||||||
|
endstr = end_date.strftime('%B %d, %Y')
|
||||||
|
end
|
||||||
|
|
||||||
|
result = startstr + endstr
|
||||||
|
result
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,37 +0,0 @@
|
||||||
##
|
|
||||||
# This class contains helper for the home views.
|
|
||||||
|
|
||||||
module HomeHelper
|
|
||||||
|
|
||||||
##
|
|
||||||
# Returns a string build from the start and end date of the given conference.
|
|
||||||
#
|
|
||||||
# If the conference starts and ends in the same month and year
|
|
||||||
# * %B %d - %d, %Y (January 17 - 21 2014)
|
|
||||||
# If the conference ends in another month but in the same year
|
|
||||||
# * %B %d - %B %d, %Y (January 31 - February 02 2014)
|
|
||||||
# All other cases
|
|
||||||
# * %B %d, %Y - %B %d, %Y (December 30, 2013 - January 02, 2014)
|
|
||||||
def conference_date_string(conf)
|
|
||||||
date_string(conf.start_date, conf.end_date)
|
|
||||||
end
|
|
||||||
|
|
||||||
def date_string(start_date, end_date)
|
|
||||||
startstr = 'Unknown - '
|
|
||||||
endstr = 'Unknown'
|
|
||||||
# When the conference in the same month
|
|
||||||
if start_date.month == end_date.month && start_date.year == end_date.year
|
|
||||||
startstr = start_date.strftime('%B %d - ')
|
|
||||||
endstr = end_date.strftime('%d, %Y')
|
|
||||||
elsif start_date.month != end_date.month && start_date.year == end_date.year
|
|
||||||
startstr = start_date.strftime('%B %d - ')
|
|
||||||
endstr = end_date.strftime('%B %d, %Y')
|
|
||||||
else
|
|
||||||
startstr = start_date.strftime('%B %d, %Y - ')
|
|
||||||
endstr = end_date.strftime('%B %d, %Y')
|
|
||||||
end
|
|
||||||
|
|
||||||
result = startstr + endstr
|
|
||||||
result
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
@ -11,7 +11,7 @@
|
||||||
- if @conference.start_date && @conference.end_date
|
- if @conference.start_date && @conference.end_date
|
||||||
.row
|
.row
|
||||||
%h3
|
%h3
|
||||||
= conference_date_string(@conference)
|
= date_string(@conference.start_date, @conference.end_date)
|
||||||
|
|
||||||
- unless @conference.description.blank?
|
- unless @conference.description.blank?
|
||||||
.row-fluid
|
.row-fluid
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
= conference.title
|
= conference.title
|
||||||
%small
|
%small
|
||||||
%b
|
%b
|
||||||
= conference_date_string(conference)
|
= date_string(conference.start_date, conference.end_date)
|
||||||
- if conference.venue.name and conference.venue.website and conference.venue.address
|
- if conference.venue.name and conference.venue.website and conference.venue.address
|
||||||
%p
|
%p
|
||||||
%small
|
%small
|
||||||
|
|
@ -32,4 +32,4 @@
|
||||||
- if !current_user.nil? && current_user.proposal_count(conference) > 0
|
- if !current_user.nil? && current_user.proposal_count(conference) > 0
|
||||||
= link_to "View My Proposals", conference_proposal_index_path(conference.short_title), :class =>"btn btn-default"
|
= link_to "View My Proposals", conference_proposal_index_path(conference.short_title), :class =>"btn btn-default"
|
||||||
- elsif conference.cfp_open?
|
- elsif conference.cfp_open?
|
||||||
= link_to "Submit Proposal", conference_proposal_index_path(conference.short_title), :class =>"btn btn-default"
|
= link_to "Submit Proposal", conference_proposal_index_path(conference.short_title), :class =>"btn btn-default"
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
require 'spec_helper'
|
require 'spec_helper'
|
||||||
describe 'conference/show.html.haml' do
|
describe 'conference/show.html.haml' do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
|
allow(view).to receive(:date_string).and_return("January 17 - 21 2014")
|
||||||
@conference = create(:conference, registration_description: 'Lorem Ipsum Dolor',
|
@conference = create(:conference, registration_description: 'Lorem Ipsum Dolor',
|
||||||
registration_start_date: Date.today,
|
registration_start_date: Date.today,
|
||||||
registration_end_date: Date.tomorrow,
|
registration_end_date: Date.tomorrow,
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ require 'spec_helper'
|
||||||
|
|
||||||
describe 'home/index' do
|
describe 'home/index' do
|
||||||
it "renders _conference partial for each conference" do
|
it "renders _conference partial for each conference" do
|
||||||
|
allow(view).to receive(:date_string).and_return("January 17 - 21 2014")
|
||||||
assign(:current, [create(:conference), create(:conference)])
|
assign(:current, [create(:conference), create(:conference)])
|
||||||
render
|
render
|
||||||
expect(view).to render_template(:partial => "_conference_details", :count => 2)
|
expect(view).to render_template(:partial => "_conference_details", :count => 2)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue