noosfero | 3 new commits pushed to repository
Bráulio Bhavamitra
gitlab at gitlab.com
Mon Mar 9 19:32:50 BRT 2015
Bráulio Bhavamitra pushed to refs/heads/master at <a href="https://gitlab.com/noosfero/noosfero">Noosfero / noosfero</a>
Commits:
<a href="https://gitlab.com/noosfero/noosfero/commit/ce6338053dd6cd2060eef580b6a6204f5b63cb2c">ce633805</a> by Braulio Bhavamitra
event: fix lead
- - - - -
<a href="https://gitlab.com/noosfero/noosfero/commit/ad280692e77ded7abd7b41bc6f4b4966d978742a">ad280692</a> by Braulio Bhavamitra
sample-data: use require_relative
- - - - -
<a href="https://gitlab.com/noosfero/noosfero/commit/70811f900ec4a15107c6e6b5a66323b52b0f5ad8">70811f90</a> by Braulio Bhavamitra
dates_helper: don't use constant for translation
- - - - -
Changes:
=====================================
app/helpers/dates_helper.rb
=====================================
--- a/app/helpers/dates_helper.rb
+++ b/app/helpers/dates_helper.rb
@@ -2,13 +2,15 @@ require 'noosfero/i18n'
module DatesHelper
- MONTHS = I18n.t('date.month_names')
+ def months
+ I18n.t('date.month_names')
+ end
def month_name(n, abbreviated = false)
if abbreviated
I18n.t('date.abbr_month_names')[n]
else
- MONTHS[n]
+ months[n]
end
end
@@ -37,7 +39,7 @@ module DatesHelper
end
end
- # formats a datetime for displaying.
+ # formats a datetime for displaying.
def show_time(time)
if time
_('%{day} %{month} %{year}, %{hour}:%{minutes}') % { :year => time.year, :month => month_name(time.month), :day => time.day, :hour => time.hour, :minutes => time.strftime("%M") }
@@ -138,7 +140,7 @@ module DatesHelper
else
order = [:day, :month, :year]
end
- date_select(object, method, html_options.merge(options.merge(:include_blank => true, :order => order, :use_month_names => MONTHS)))
+ date_select(object, method, html_options.merge(options.merge(:include_blank => true, :order => order, :use_month_names => months)))
end
end
=====================================
app/models/event.rb
=====================================
--- a/app/models/event.rb
+++ b/app/models/event.rb
@@ -145,11 +145,9 @@ class Event < Article
((self.end_date || self.start_date) - self.start_date).to_i
end
+ alias_method :article_lead, :lead
def lead
- content_tag('div',
- show_period(start_date, end_date),
- :class => 'event-dates'
- ) + super
+ self.class.action_view.render 'content_viewer/event_lead', event: self
end
def event?
=====================================
app/views/content_viewer/_event_lead.html.erb
=====================================
--- /dev/null
+++ b/app/views/content_viewer/_event_lead.html.erb
@@ -0,0 +1,7 @@
+
+<div class="event-dates">
+ <%= show_period event.start_date, event.end_date %>
+</div>
+
+<%= event.article_lead %>
+
=====================================
lib/noosfero/core_ext/active_record.rb
=====================================
--- a/lib/noosfero/core_ext/active_record.rb
+++ b/lib/noosfero/core_ext/active_record.rb
@@ -6,6 +6,22 @@ class ActiveRecord::Base
ActiveRecord::Base.connection.adapter_name == 'PostgreSQL'
end
+ # an ActionView instance for rendering views on models
+ def self.action_view
+ @action_view ||= begin
+ view_paths = ActionController::Base.view_paths
+ action_view = ActionView::Base.new view_paths
+ # for using Noosfero helpers inside render calls
+ action_view.extend ApplicationHelper
+ action_view
+ end
+ end
+
+ # default value needed for the above ActionView
+ def to_partial_path
+ self.class.name.underscore
+ end
+
alias :meta_cache_key :cache_key
def cache_key
key = [Noosfero::VERSION, meta_cache_key]
=====================================
script/sample-data
=====================================
--- a/script/sample-data
+++ b/script/sample-data
@@ -1,5 +1,5 @@
#!/usr/bin/env ruby
-require File.dirname(__FILE__) + '/../config/environment'
+require_relative '../config/environment'
include Noosfero::SampleDataHelper
id = ARGV.first || ''
=====================================
test/unit/dates_helper_test.rb
=====================================
--- a/test/unit/dates_helper_test.rb
+++ b/test/unit/dates_helper_test.rb
@@ -99,20 +99,20 @@ class DatesHelperTest < ActiveSupport::TestCase
should 'provide an intertionalized date selector pass month names' do
expects(:language).returns('en')
- expects(:date_select).with(:object, :method, { :include_blank => true, :order => [:month, :day, :year], :use_month_names => MONTHS }).returns("KKKKKKKK")
+ expects(:date_select).with(:object, :method, { :include_blank => true, :order => [:month, :day, :year], :use_month_names => months }).returns("KKKKKKKK")
assert_equal 'KKKKKKKK', pick_date(:object, :method)
end
should 'order date in english like month day year' do
expects(:language).returns('en')
- expects(:date_select).with(:object, :method, { :include_blank => true, :order => [:month, :day, :year], :use_month_names => MONTHS }).returns("KKKKKKKK")
+ expects(:date_select).with(:object, :method, { :include_blank => true, :order => [:month, :day, :year], :use_month_names => months }).returns("KKKKKKKK")
assert_equal 'KKKKKKKK', pick_date(:object, :method)
end
should 'order date in other languages like day month year' do
expects(:language).returns('pt_BR')
- expects(:date_select).with(:object, :method, { :include_blank => true, :order => [:day, :month, :year], :use_month_names => MONTHS }).returns("KKKKKKKK")
+ expects(:date_select).with(:object, :method, { :include_blank => true, :order => [:day, :month, :year], :use_month_names => months }).returns("KKKKKKKK")
assert_equal 'KKKKKKKK', pick_date(:object, :method)
end
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listas.softwarelivre.org/pipermail/noosfero-dev/attachments/20150309/1163e647/attachment-0001.html>
More information about the Noosfero-dev
mailing list