Commit 4949dfcee7cd902048190e31bd8f9e46f646120c
Exists in
master
and in
29 other branches
Merge branch 'stoa' of gitlab.com:colivre/noosfero into stoa
Showing
7 changed files
with
41 additions
and
10 deletions
Show diff stats
app/controllers/my_profile/cms_controller.rb
@@ -27,7 +27,7 @@ class CmsController < MyProfileController | @@ -27,7 +27,7 @@ class CmsController < MyProfileController | ||
27 | (user && (user.has_permission?('post_content', profile) || user.has_permission?('publish_content', profile))) | 27 | (user && (user.has_permission?('post_content', profile) || user.has_permission?('publish_content', profile))) |
28 | end | 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 | user && (user.has_permission?('post_content', profile) || user.has_permission?('publish_content', profile)) | 31 | user && (user.has_permission?('post_content', profile) || user.has_permission?('publish_content', profile)) |
32 | end | 32 | end |
33 | 33 | ||
@@ -37,7 +37,7 @@ class CmsController < MyProfileController | @@ -37,7 +37,7 @@ class CmsController < MyProfileController | ||
37 | (user && (user.has_permission?('post_content', profile) || user.has_permission?('publish_content', profile))) | 37 | (user && (user.has_permission?('post_content', profile) || user.has_permission?('publish_content', profile))) |
38 | end | 38 | end |
39 | 39 | ||
40 | - protect_if :only => [:destroy, :publish] do |c, user, profile| | 40 | + protect_if :only => :destroy do |c, user, profile| |
41 | profile.articles.find(c.params[:id]).allow_post_content?(user) | 41 | profile.articles.find(c.params[:id]).allow_post_content?(user) |
42 | end | 42 | end |
43 | 43 |
app/models/profile_suggestion.rb
@@ -157,4 +157,22 @@ class ProfileSuggestion < ActiveRecord::Base | @@ -157,4 +157,22 @@ class ProfileSuggestion < ActiveRecord::Base | ||
157 | self.save | 157 | self.save |
158 | end | 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 | end | 178 | end |
config/schedule.rb
@@ -26,3 +26,7 @@ set :output, "log/cron.log" | @@ -26,3 +26,7 @@ set :output, "log/cron.log" | ||
26 | every 1.minute do | 26 | every 1.minute do |
27 | runner "SearchTerm.calculate_scores" | 27 | runner "SearchTerm.calculate_scores" |
28 | end | 28 | end |
29 | + | ||
30 | +every 90.days do | ||
31 | + runner "ProfileSuggestion.generate_all_profile_suggestions" | ||
32 | +end |
lib/profile_suggestions_job.rb
1 | class ProfileSuggestionsJob < Struct.new(:person_id) | 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 | def perform | 11 | def perform |
12 | + logger = Delayed::Worker.logger | ||
4 | begin | 13 | begin |
5 | person = Person.find(person_id) | 14 | person = Person.find(person_id) |
6 | 15 | ||
7 | ProfileSuggestion::RULES.each do |rule| | 16 | ProfileSuggestion::RULES.each do |rule| |
8 | ProfileSuggestion.send(rule, person) | 17 | ProfileSuggestion.send(rule, person) |
9 | end | 18 | end |
10 | - | ||
11 | UserMailer.profiles_suggestions_email(person).deliver | 19 | UserMailer.profiles_suggestions_email(person).deliver |
12 | rescue Exception => exception | 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 | end | 22 | end |
15 | end | 23 | end |
16 | 24 |
plugins/social_share_privacy/public/style.css
plugins/social_share_privacy/public/stylesheets/common.css
plugins/social_share_privacy/public/stylesheets/modules/flattr.css
1 | .social_share_privacy_area.line .flattr img { | 1 | .social_share_privacy_area.line .flattr img { |
2 | width: 72px; | 2 | width: 72px; |
3 | height: 20px; | 3 | height: 20px; |
4 | - margin-right: 98px; | 4 | + margin-right: 48px; |
5 | } | 5 | } |
6 | .social_share_privacy_area.line .flattr a, | 6 | .social_share_privacy_area.line .flattr a, |
7 | .social_share_privacy_area.line .flattr iframe { | 7 | .social_share_privacy_area.line .flattr iframe { |
8 | - width: 150px; | 8 | + width: 110px; |
9 | height: 20px; | 9 | height: 20px; |
10 | - margin-right: 20px; | 10 | + margin-right: 10px; |
11 | } | 11 | } |
12 | .social_share_privacy_area.line .flattr a { | 12 | .social_share_privacy_area.line .flattr a { |
13 | display: inline-block; | 13 | display: inline-block; |