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