Commit 4949dfcee7cd902048190e31bd8f9e46f646120c

Authored by Rodrigo Souto
2 parents 122ef4c0 ab432d73

Merge branch 'stoa' of gitlab.com:colivre/noosfero into stoa

app/controllers/my_profile/cms_controller.rb
... ... @@ -27,7 +27,7 @@ class CmsController < MyProfileController
27 27 (user && (user.has_permission?('post_content', profile) || user.has_permission?('publish_content', profile)))
28 28 end
29 29  
30   - protect_if :except => [:suggest_an_article, :set_home_page, :edit, :destroy, :publish, :upload_files, :new] do |c, user, profile|
  30 + protect_if :except => [:suggest_an_article, :set_home_page, :edit, :destroy, :publish, :publish_on_portal_community, :publish_on_communities, :search_communities_to_publish, :upload_files, :new] do |c, user, profile|
31 31 user && (user.has_permission?('post_content', profile) || user.has_permission?('publish_content', profile))
32 32 end
33 33  
... ... @@ -37,7 +37,7 @@ class CmsController < MyProfileController
37 37 (user && (user.has_permission?('post_content', profile) || user.has_permission?('publish_content', profile)))
38 38 end
39 39  
40   - protect_if :only => [:destroy, :publish] do |c, user, profile|
  40 + protect_if :only => :destroy do |c, user, profile|
41 41 profile.articles.find(c.params[:id]).allow_post_content?(user)
42 42 end
43 43  
... ...
app/models/profile_suggestion.rb
... ... @@ -157,4 +157,22 @@ class ProfileSuggestion < ActiveRecord::Base
157 157 self.save
158 158 end
159 159  
  160 + def self.generate_all_profile_suggestions
  161 + Delayed::Job.enqueue(ProfileSuggestion::GenerateAllJob.new) unless ProfileSuggestion::GenerateAllJob.exists?
  162 + end
  163 +
  164 + def self.generate_profile_suggestions(person_id)
  165 + Delayed::Job.enqueue ProfileSuggestionsJob.new(person_id) unless ProfileSuggestionsJob.exists?(person_id)
  166 + end
  167 +
  168 + class GenerateAllJob
  169 + def self.exists?
  170 + Delayed::Job.by_handler("--- !ruby/object:ProfileSuggestion::GenerateAllJob {}\n").count > 0
  171 + end
  172 +
  173 + def perform
  174 + Person.find_each {|person| ProfileSuggestion.generate_profile_suggestions(person.id) }
  175 + end
  176 + end
  177 +
160 178 end
... ...
config/schedule.rb
... ... @@ -26,3 +26,7 @@ set :output, "log/cron.log"
26 26 every 1.minute do
27 27 runner "SearchTerm.calculate_scores"
28 28 end
  29 +
  30 +every 90.days do
  31 + runner "ProfileSuggestion.generate_all_profile_suggestions"
  32 +end
... ...
lib/profile_suggestions_job.rb
1 1 class ProfileSuggestionsJob < Struct.new(:person_id)
2 2  
  3 + def self.exists?(person_id)
  4 + !find(person_id).empty?
  5 + end
  6 +
  7 + def self.find(person_id)
  8 + Delayed::Job.by_handler("--- !ruby/struct:ProfileSuggestionsJob\nperson_id: #{person_id}\n")
  9 + end
  10 +
3 11 def perform
  12 + logger = Delayed::Worker.logger
4 13 begin
5 14 person = Person.find(person_id)
6 15  
7 16 ProfileSuggestion::RULES.each do |rule|
8 17 ProfileSuggestion.send(rule, person)
9 18 end
10   -
11 19 UserMailer.profiles_suggestions_email(person).deliver
12 20 rescue Exception => exception
13   - Rails.logger.warn("Error with suggestions for person ID %d\n%s" % [person_id, exception.to_s])
  21 + logger.warn("Error with suggestions for person ID %d: %s" % [person_id, exception.to_s])
14 22 end
15 23 end
16 24  
... ...
plugins/social_share_privacy/public/style.css
... ... @@ -4,3 +4,7 @@
4 4 #selected-social-networks {
5 5 width: 50%;
6 6 }
  7 +.social-buttons {
  8 + display: inline-block;
  9 + width: 100%;
  10 +}
... ...
plugins/social_share_privacy/public/stylesheets/common.css
1   -.social-buttons {
2   - display: inline-block;
3   -}
4 1 .social_share_privacy_area {
5 2 clear: both;
6 3 margin: 5px 0;
... ...
plugins/social_share_privacy/public/stylesheets/modules/flattr.css
1 1 .social_share_privacy_area.line .flattr img {
2 2 width: 72px;
3 3 height: 20px;
4   - margin-right: 98px;
  4 + margin-right: 48px;
5 5 }
6 6 .social_share_privacy_area.line .flattr a,
7 7 .social_share_privacy_area.line .flattr iframe {
8   - width: 150px;
  8 + width: 110px;
9 9 height: 20px;
10   - margin-right: 20px;
  10 + margin-right: 10px;
11 11 }
12 12 .social_share_privacy_area.line .flattr a {
13 13 display: inline-block;
... ...