[Git][noosfero/noosfero][stable-1.8] Merge branch 'solid_mes' into 'master'
Rodrigo Souto
gitlab at mg.gitlab.com
Thu Jun 29 10:15:26 BRT 2017
Rodrigo Souto pushed to branch stable-1.8 at Noosfero / noosfero
Commits:
9e80bcbf by Rodrigo Souto at 2017-06-29T13:04:14+00:00
Merge branch 'solid_mes' into 'master'
Removing code duplication in Products and Push Notification plugins.
See merge request !1260
- - - - -
7 changed files:
- plugins/products/controllers/profile/products_plugin/catalog_controller.rb
- plugins/products/controllers/profile/products_plugin/page_controller.rb
- plugins/products/controllers/public/products_plugin/search_controller.rb
- plugins/products/lib/products_plugin/products_helper.rb
- plugins/push_notification/lib/push_notification_plugin/observers/approve_article_observer.rb
- + plugins/push_notification/lib/push_notification_plugin/observers/observers_helper.rb
- plugins/push_notification/lib/push_notification_plugin/observers/suggest_article_observer.rb
Changes:
=====================================
plugins/products/controllers/profile/products_plugin/catalog_controller.rb
=====================================
--- a/plugins/products/controllers/profile/products_plugin/catalog_controller.rb
+++ b/plugins/products/controllers/profile/products_plugin/catalog_controller.rb
@@ -16,12 +16,5 @@ module ProductsPlugin
redirect_to controller: 'profile', profile: profile.identifier, action: 'index'
end
- # inherit routes from core skipping use_relative_controller!
- def url_for options
- options[:controller] = "/#{options[:controller]}" if options.is_a? Hash and options[:controller] and not options[:controller].to_s.starts_with? '/'
- super options
- end
- helper_method :url_for
-
end
end
=====================================
plugins/products/controllers/profile/products_plugin/page_controller.rb
=====================================
--- a/plugins/products/controllers/profile/products_plugin/page_controller.rb
+++ b/plugins/products/controllers/profile/products_plugin/page_controller.rb
@@ -220,12 +220,5 @@ module ProductsPlugin
end
end
- # inherit routes from core skipping use_relative_controller!
- def url_for options
- options[:controller] = "/#{options[:controller]}" if options.is_a? Hash and options[:controller] and not options[:controller].to_s.starts_with? '/'
- super options
- end
- helper_method :url_for
-
end
end
=====================================
plugins/products/controllers/public/products_plugin/search_controller.rb
=====================================
--- a/plugins/products/controllers/public/products_plugin/search_controller.rb
+++ b/plugins/products/controllers/public/products_plugin/search_controller.rb
@@ -8,14 +8,5 @@ module ProductsPlugin
full_text_search
end
- protected
-
- # inherit routes from core skipping use_relative_controller!
- def url_for options
- options[:controller] = "/#{options[:controller]}" if options.is_a? Hash and options[:controller] and not options[:controller].to_s.starts_with? '/'
- super options
- end
- helper_method :url_for
-
end
end
=====================================
plugins/products/lib/products_plugin/products_helper.rb
=====================================
--- a/plugins/products/lib/products_plugin/products_helper.rb
+++ b/plugins/products/lib/products_plugin/products_helper.rb
@@ -1,5 +1,10 @@
module ProductsPlugin::ProductsHelper
+ def url_for options
+ options[:controller] = "/#{options[:controller]}" if options.is_a? Hash and options[:controller] and not options[:controller].to_s.starts_with? '/'
+ super options
+ end
+
protected
def product_path(product)
@@ -316,4 +321,5 @@ module ProductsPlugin::ProductsHelper
_("%{currency} %{production_cost} of %{currency} %{product_price}").html_safe % {currency: currency, production_cost: content_tag('span', production_cost, class: 'production_cost'), product_price: content_tag('span', product_price, class: 'product_price')}
end
+
end
=====================================
plugins/push_notification/lib/push_notification_plugin/observers/approve_article_observer.rb
=====================================
--- a/plugins/push_notification/lib/push_notification_plugin/observers/approve_article_observer.rb
+++ b/plugins/push_notification/lib/push_notification_plugin/observers/approve_article_observer.rb
@@ -1,14 +1,11 @@
module PushNotificationPlugin::Observers
+
+ include ObserversHelper
+
module ApproveArticleObserver
def approve_article_after_create_callback(approve_article)
- requestor = approve_article.requestor
- target = approve_article.target
-
- if target.person?
- users = [target.user]
- elsif target.organization?
- users = target.admins.map{|person| person.user}
- end
+ target, requestor = get_target_and_requestor approve_article
+ users = get_users_info target
send_to_users("approve_article",
users,
=====================================
plugins/push_notification/lib/push_notification_plugin/observers/observers_helper.rb
=====================================
--- /dev/null
+++ b/plugins/push_notification/lib/push_notification_plugin/observers/observers_helper.rb
@@ -0,0 +1,15 @@
+module PushNotificationPlugin::Observers::ObserversHelper
+
+ def get_target_and_requestor(article)
+ target = article.target, requestor = article.requestor
+ end
+
+ def get_users_info(target)
+ if target.person?
+ users = [target.user]
+ elsif target.organization?
+ users = target.admins.map{|person| person.user}
+ end
+ end
+
+end
=====================================
plugins/push_notification/lib/push_notification_plugin/observers/suggest_article_observer.rb
=====================================
--- a/plugins/push_notification/lib/push_notification_plugin/observers/suggest_article_observer.rb
+++ b/plugins/push_notification/lib/push_notification_plugin/observers/suggest_article_observer.rb
@@ -1,14 +1,11 @@
module PushNotificationPlugin::Observers
+
+ include ObserversHelper
+
module SuggestArticleObserver
def suggest_article_after_create_callback(suggest_article)
- requestor = suggest_article.requestor
- target = suggest_article.target
-
- if target.person?
- users = [target.user]
- elsif target.organization?
- users = target.admins.map{|person| person.user}
- end
+ target, requestor = get_target_and_requestor suggest_article
+ users = get_users_info target
send_to_users("suggest_article",
users,
View it on GitLab: https://gitlab.com/noosfero/noosfero/commit/9e80bcbfa2e5c248c3fb0f429c5bc4148111eb9d
---
View it on GitLab: https://gitlab.com/noosfero/noosfero/commit/9e80bcbfa2e5c248c3fb0f429c5bc4148111eb9d
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/20170629/542d9158/attachment-0001.html>
More information about the Noosfero-dev
mailing list