[Git][noosfero/noosfero][master] 3 commits: Adding area news behaviour configs
Leandro Nunes
gitlab at mg.gitlab.com
Wed Apr 4 18:05:18 BRT 2018
Leandro Nunes pushed to branch master at Noosfero / noosfero
Commits:
83863b38 by Victor Moura at 2017-11-07T13:36:54Z
Adding area news behaviour configs
- - - - -
3bac2a44 by Victor Moura at 2017-11-07T13:46:15Z
Changing set_portal_news_amount to set_portal_news_configurations
- - - - -
3f33fbc6 by Leandro Nunes at 2018-04-04T21:05:02Z
Merge branch 'add_area_news_custom_behaviour' into 'master'
Add area news custom behaviour
Closes #291
See merge request noosfero/noosfero!1350
- - - - -
6 changed files:
- app/controllers/admin/admin_panel_controller.rb
- app/models/environment.rb
- app/views/admin_panel/set_portal_community.html.erb
- app/views/admin_panel/set_portal_news_amount.html.erb → app/views/admin_panel/set_portal_news_configurations.html.erb
- app/views/home/index.html.erb
- test/functional/admin_panel_controller_test.rb
Changes:
=====================================
app/controllers/admin/admin_panel_controller.rb
=====================================
--- a/app/controllers/admin/admin_panel_controller.rb
+++ b/app/controllers/admin/admin_panel_controller.rb
@@ -60,12 +60,12 @@ class AdminPanelController < AdminController
env.portal_folders = folders
if env.save
session[:notice] = _('Saved the portal folders')
- redirect_to :action => 'set_portal_news_amount'
+ redirect_to :action => 'set_portal_news_configurations'
end
end
end
- def set_portal_news_amount
+ def set_portal_news_configurations
if request.post?
if @environment.update(params[:environment])
session[:notice] = _('Saved the number of news on folders')
=====================================
app/models/environment.rb
=====================================
--- a/app/models/environment.rb
+++ b/app/models/environment.rb
@@ -13,7 +13,7 @@ class Environment < ApplicationRecord
:reports_lower_bound, :noreply_email,
:signup_welcome_screen_body, :members_whitelist_enabled,
:members_whitelist, :highlighted_news_amount,
- :portal_news_amount, :date_format, :signup_intro,
+ :portal_news_amount, :area_news_show_not_highlighted, :date_format, :signup_intro,
:enable_feed_proxy, :http_feed_proxy, :https_feed_proxy,
:disable_feed_ssl, :layout_template, :boxes_attributes
@@ -319,6 +319,7 @@ class Environment < ApplicationRecord
settings_items :news_amount_by_folder, :type => Integer, :default => 4
settings_items :highlighted_news_amount, :type => Integer, :default => 2
settings_items :portal_news_amount, :type => Integer, :default => 5
+ settings_items :area_news_show_not_highlighted, :type => :boolean, :default => false
settings_items :help_message_to_add_enterprise, :type => String, :default => ''
settings_items :tip_message_enterprise_activation_question, :type => String, :default => ''
=====================================
app/views/admin_panel/set_portal_community.html.erb
=====================================
--- a/app/views/admin_panel/set_portal_community.html.erb
+++ b/app/views/admin_panel/set_portal_community.html.erb
@@ -18,7 +18,7 @@
<%= button 'ok', _('Enable'), {:action => 'manage_portal_community', :activate => 1} %>
<% end %>
<%= button 'folder', _('Select Portal Folders'), {:action => 'set_portal_folders'} %>
- <%= button 'edit', _('Define news amount on portal'), {:action => 'set_portal_news_amount'} %>
+ <%= button 'edit', _('Define news configurations on portal'), {:action => 'set_portal_news_configurations'} %>
<%= button 'delete', _('Remove'), { :action => 'unset_portal_community'} %>
<% end %>
<% end %>
=====================================
app/views/admin_panel/set_portal_news_amount.html.erb → app/views/admin_panel/set_portal_news_configurations.html.erb
=====================================
--- a/app/views/admin_panel/set_portal_news_amount.html.erb
+++ b/app/views/admin_panel/set_portal_news_configurations.html.erb
@@ -1,10 +1,12 @@
-<h1><%= _('News amount on portal') %></h1>
+<h1><%= _('News configurations on portal') %></h1>
<%= labelled_form_for :environment do |f| %>
<%= labelled_form_field _('Number of highlighted news'), select(:environment, :highlighted_news_amount, (0..10).to_a) %>
<%= labelled_form_field _('Number of portal news'), select(:environment, :portal_news_amount, (0..10).to_a) %>
<%= labelled_form_field _('Number of news by folder'), select(:environment, :news_amount_by_folder, (1..10).to_a) %>
+ <%= labelled_radio_button( _('Show all news on area news'), 'environment[area_news_show_not_highlighted]', true, environment.area_news_show_not_highlighted) %>
+ <%= labelled_radio_button( _('Show only not highlighted news on area news'), 'environment[area_news_show_not_highlighted]', false, !environment.area_news_show_not_highlighted) %>
<%= button_bar do %>
<%= submit_button(:save, _('Save')) %>
=====================================
app/views/home/index.html.erb
=====================================
--- a/app/views/home/index.html.erb
+++ b/app/views/home/index.html.erb
@@ -38,7 +38,7 @@
<%= content_tag(:div, :class => 'news-area-inner-2') do %>
<h3><%= link_to h(folder.title), folder.url %></h3>
<ul>
- <% folder.news(environment.news_amount_by_folder).each do |news| %>
+ <% folder.news(environment.news_amount_by_folder, environment.area_news_show_not_highlighted).each do |news| %>
<li> <%= link_to(h(news.title), news.url) %></li>
<% end%>
</ul>
=====================================
test/functional/admin_panel_controller_test.rb
=====================================
--- a/test/functional/admin_panel_controller_test.rb
+++ b/test/functional/admin_panel_controller_test.rb
@@ -337,17 +337,18 @@ class AdminPanelControllerTest < ActionController::TestCase
env.news_amount_by_folder = 5
env.save
- get :set_portal_news_amount
+ get :set_portal_news_configurations
assert_tag :tag => 'select', :descendant => {:tag => 'option', :attributes => {:value => 5, :selected => 'selected'}}
end
- should 'save amount of news' do
- post :set_portal_news_amount, :environment => { :news_amount_by_folder => '3', :highlighted_news_amount => '2', :portal_news_amount => '5' }
+ should 'save configuration of news' do
+ post :set_portal_news_configurations, :environment => { :news_amount_by_folder => '3', :highlighted_news_amount => '2', :portal_news_amount => '5', :area_news_show_not_highlighted => false }
assert_redirected_to :action => 'index'
assert_equal 3, Environment.default.news_amount_by_folder
assert_equal 2, Environment.default.highlighted_news_amount
assert_equal 5, Environment.default.portal_news_amount
+ assert_equal false, Environment.default.area_news_show_not_highlighted
end
should 'display plugins links' do
View it on GitLab: https://gitlab.com/noosfero/noosfero/compare/69458550d5c296981bba85ac339636fc84759075...3f33fbc6382630530eb3702c57193f5b0bde5eaa
---
View it on GitLab: https://gitlab.com/noosfero/noosfero/compare/69458550d5c296981bba85ac339636fc84759075...3f33fbc6382630530eb3702c57193f5b0bde5eaa
You're receiving this email because of your account on gitlab.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listas.softwarelivre.org/pipermail/noosfero-dev/attachments/20180404/1f776fb2/attachment-0001.html>
More information about the Noosfero-dev
mailing list