[Git][noosfero/noosfero][master] 2 commits: Apply SOLID
Rodrigo Souto
gitlab at mg.gitlab.com
Tue Oct 17 11:54:39 BRST 2017
Rodrigo Souto pushed to branch master at Noosfero / noosfero
Commits:
a8087c69 by jessicacris at 2017-10-16T12:46:58-03:00
Apply SOLID
- - - - -
94c252d0 by Rodrigo Souto at 2017-10-17T13:54:25+00:00
Merge branch 'jessica-refactoring' into 'master'
Apply SOLID
See merge request noosfero/noosfero!1322
- - - - -
2 changed files:
- app/controllers/admin/templates_controller.rb
- app/helpers/sweeper_helper.rb
Changes:
=====================================
app/controllers/admin/templates_controller.rb
=====================================
--- a/app/controllers/admin/templates_controller.rb
+++ b/app/controllers/admin/templates_controller.rb
@@ -16,12 +16,16 @@ class TemplatesController < AdminController
end
end
+ def create_template(template)
+ create_organization_template(template)
+ session[:notice] = _('New template created')
+ redirect_to :action => 'index'
+ end
+
def create_community_template
if request.post?
begin
- create_organization_template(Community)
- session[:notice] = _('New template created')
- redirect_to :action => 'index'
+ create_template(Community)
rescue
@error = _('Name has already been taken')
end
@@ -31,9 +35,7 @@ class TemplatesController < AdminController
def create_enterprise_template
if request.post?
begin
- create_organization_template(Enterprise)
- session[:notice] = _('New template created')
- redirect_to :action => 'index'
+ create_template(Enterprise)
rescue
@error = _('Name has already been taken')
end
@@ -108,4 +110,3 @@ class TemplatesController < AdminController
end
end
-
=====================================
app/helpers/sweeper_helper.rb
=====================================
--- a/app/helpers/sweeper_helper.rb
+++ b/app/helpers/sweeper_helper.rb
@@ -43,6 +43,11 @@ module SweeperHelper
expire_timeout_fragment(profile.relationships_cache_key)
end
+ def expire_block?(block, causes)
+ conditions = block.class.expire_on
+ (conditions[block] & causes).present?
+ end
+
def expire_blocks_cache(context, causes)
if context.kind_of?(Profile)
profile = context
@@ -55,13 +60,11 @@ module SweeperHelper
blocks_to_expire = []
if profile
profile.blocks.each {|block|
- conditions = block.class.expire_on
- blocks_to_expire << block unless (conditions[:profile] & causes).blank?
+ blocks_to_expire << block if expire_block?(block, causes)
}
end
environment.blocks.each {|block|
- conditions = block.class.expire_on
- blocks_to_expire << block unless (conditions[:environment] & causes).blank?
+ blocks_to_expire << block if expire_block?(block, causes)
}
blocks_to_expire.uniq!
View it on GitLab: https://gitlab.com/noosfero/noosfero/compare/8770276d84ad7e1b92128db082bfbd4b2428d3c0...94c252d0760e7ee55cd3824ea3015dc8d382b014
---
View it on GitLab: https://gitlab.com/noosfero/noosfero/compare/8770276d84ad7e1b92128db082bfbd4b2428d3c0...94c252d0760e7ee55cd3824ea3015dc8d382b014
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/20171017/e338c5bb/attachment-0001.html>
More information about the Noosfero-dev
mailing list