Commit 5b423b0237d69da996f5679eb927f771caea87da
1 parent
c8dc0297
Exists in
master
and in
22 other branches
environment: encapsulate portal_enabled logic inside the model
Showing
3 changed files
with
6 additions
and
4 deletions
Show diff stats
app/controllers/my_profile/cms_controller.rb
@@ -71,7 +71,6 @@ class CmsController < MyProfileController | @@ -71,7 +71,6 @@ class CmsController < MyProfileController | ||
71 | 71 | ||
72 | def index | 72 | def index |
73 | @article = nil | 73 | @article = nil |
74 | - @portal_enabled = environment.portal_community && environment.enabled?('use_portal_community') | ||
75 | @articles = profile.top_level_articles.paginate( | 74 | @articles = profile.top_level_articles.paginate( |
76 | :order => "case when type = 'Folder' then 0 when type ='Blog' then 1 else 2 end, updated_at DESC", | 75 | :order => "case when type = 'Folder' then 0 when type ='Blog' then 1 else 2 end, updated_at DESC", |
77 | :per_page => per_page, | 76 | :per_page => per_page, |
@@ -266,7 +265,6 @@ class CmsController < MyProfileController | @@ -266,7 +265,6 @@ class CmsController < MyProfileController | ||
266 | 265 | ||
267 | def publish | 266 | def publish |
268 | @article = profile.articles.find(params[:id]) | 267 | @article = profile.articles.find(params[:id]) |
269 | - @portal_enabled = environment.portal_community && environment.enabled?('use_portal_community') | ||
270 | record_coming | 268 | record_coming |
271 | @failed = {} | 269 | @failed = {} |
272 | if request.post? | 270 | if request.post? |
@@ -321,7 +319,7 @@ class CmsController < MyProfileController | @@ -321,7 +319,7 @@ class CmsController < MyProfileController | ||
321 | def publish_on_portal_community | 319 | def publish_on_portal_community |
322 | if request.post? | 320 | if request.post? |
323 | @article = profile.articles.find(params[:id]) | 321 | @article = profile.articles.find(params[:id]) |
324 | - if environment.portal_community && environment.enabled?('use_portal_community') | 322 | + if environment.portal_enabled |
325 | task = ApproveArticle.create!(:article => @article, :name => params[:name], :target => environment.portal_community, :requestor => user) | 323 | task = ApproveArticle.create!(:article => @article, :name => params[:name], :target => environment.portal_community, :requestor => user) |
326 | begin | 324 | begin |
327 | task.finish unless environment.portal_community.moderated_articles? | 325 | task.finish unless environment.portal_community.moderated_articles? |
app/models/environment.rb
@@ -806,6 +806,10 @@ class Environment < ActiveRecord::Base | @@ -806,6 +806,10 @@ class Environment < ActiveRecord::Base | ||
806 | "home-page-news/#{cache_key}-#{language}" | 806 | "home-page-news/#{cache_key}-#{language}" |
807 | end | 807 | end |
808 | 808 | ||
809 | + def portal_enabled | ||
810 | + portal_community && enabled?('use_portal_community') | ||
811 | + end | ||
812 | + | ||
809 | def notification_emails | 813 | def notification_emails |
810 | [contact_email].select(&:present?) + admins.map(&:email) | 814 | [contact_email].select(&:present?) + admins.map(&:email) |
811 | end | 815 | end |
app/views/cms/publish.html.erb
@@ -67,7 +67,7 @@ | @@ -67,7 +67,7 @@ | ||
67 | <% end %> | 67 | <% end %> |
68 | 68 | ||
69 | 69 | ||
70 | - <% if @portal_enabled %> | 70 | + <% if environment.portal_enabled %> |
71 | <li onmouseover="javascript: jQuery(this).addClass('mouseover')" onmouseout="jQuery(this).removeClass('mouseover')"> | 71 | <li onmouseover="javascript: jQuery(this).addClass('mouseover')" onmouseout="jQuery(this).removeClass('mouseover')"> |
72 | <strong><%= _("Publish your article on portal community") %></strong> | 72 | <strong><%= _("Publish your article on portal community") %></strong> |
73 | <div class='description'><%= _('You can suggest this article to the portal community, where it can show up on the homepage.') %></div> | 73 | <div class='description'><%= _('You can suggest this article to the portal community, where it can show up on the homepage.') %></div> |