mirror of
https://github.com/openSUSE/osem.git
synced 2026-08-13 19:54:02 +00:00
Removed conference_date_string_helper, moved date_string to application_controller
Deleted home_helper.rb
This commit is contained in:
parent
85e9fdc643
commit
c68c6394bc
6 changed files with 34 additions and 40 deletions
|
|
@ -3,6 +3,7 @@ class ApplicationController < ActionController::Base
|
|||
protect_from_forgery
|
||||
before_filter :get_conferences
|
||||
before_filter :store_location
|
||||
helper_method :date_string
|
||||
|
||||
def store_location
|
||||
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
|
||||
raise ActionController::RoutingError.new('Not Found')
|
||||
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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
.row
|
||||
%h3
|
||||
= conference_date_string(@conference)
|
||||
= date_string(@conference.start_date, @conference.end_date)
|
||||
|
||||
- unless @conference.description.blank?
|
||||
.row-fluid
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
= conference.title
|
||||
%small
|
||||
%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
|
||||
%p
|
||||
%small
|
||||
|
|
@ -32,4 +32,4 @@
|
|||
- 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"
|
||||
- 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'
|
||||
describe 'conference/show.html.haml' do
|
||||
before(:each) do
|
||||
allow(view).to receive(:date_string).and_return("January 17 - 21 2014")
|
||||
@conference = create(:conference, registration_description: 'Lorem Ipsum Dolor',
|
||||
registration_start_date: Date.today,
|
||||
registration_end_date: Date.tomorrow,
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ require 'spec_helper'
|
|||
|
||||
describe 'home/index' 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)])
|
||||
render
|
||||
expect(view).to render_template(:partial => "_conference_details", :count => 2)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue