Commit 62248e7e4d1c978ba0dab23814aba06f4e6b4b36
Exists in
master
and in
48 other branches
Merge branch 'article-template-list' into 'master'
Article template list This MR implements a Macro on software communities plugin that allows the use of {profile} variable in articles throw a menu button added to TinyMCE. See merge request !100
Showing
5 changed files
with
46 additions
and
2 deletions
Show diff stats
src/noosfero-spb/software_communities/lib/macros/allow_variables.rb
0 → 100644
@@ -0,0 +1,15 @@ | @@ -0,0 +1,15 @@ | ||
1 | +class SoftwareCommunitiesPlugin::AllowVariables < Noosfero::Plugin::Macro | ||
2 | + def self.configuration | ||
3 | + { :params => [], | ||
4 | + :skip_dialog => true, | ||
5 | + :title => _("Insert Profile"), | ||
6 | + :generator => 'insertProfile();', | ||
7 | + :js_files => 'allow_variables.js', | ||
8 | + :icon_path => '/designs/icons/tango/Tango/16x16/actions/document-properties.png' | ||
9 | + } | ||
10 | + end | ||
11 | + | ||
12 | + def parse(params, inner_html, source) | ||
13 | + source.profile.identifier | ||
14 | + end | ||
15 | +end |
src/noosfero-spb/software_communities/lib/software_communities_plugin.rb
src/noosfero-spb/software_communities/lib/statistic_block.rb
@@ -55,8 +55,13 @@ class StatisticBlock < Block | @@ -55,8 +55,13 @@ class StatisticBlock < Block | ||
55 | def get_software_statistics | 55 | def get_software_statistics |
56 | statistics = {} | 56 | statistics = {} |
57 | software = SoftwareInfo.find_by_community_id(self.owner.id) | 57 | software = SoftwareInfo.find_by_community_id(self.owner.id) |
58 | - statistics[:saved_resources] = software.saved_resources | ||
59 | - statistics[:benefited_people] = software.benefited_people | 58 | + if software.present? |
59 | + statistics[:saved_resources] = software.saved_resources | ||
60 | + statistics[:benefited_people] = software.benefited_people | ||
61 | + else | ||
62 | + statistics[:saved_resources] = 0 | ||
63 | + statistics[:benefited_people] = 0 | ||
64 | + end | ||
60 | statistics | 65 | statistics |
61 | end | 66 | end |
62 | end | 67 | end |
src/noosfero-spb/software_communities/lib/tasks/templates.rake
@@ -39,4 +39,23 @@ namespace :templates do | @@ -39,4 +39,23 @@ namespace :templates do | ||
39 | end | 39 | end |
40 | end | 40 | end |
41 | 41 | ||
42 | + desc "Copy mail list article from template to all Communities" | ||
43 | + task :copy_mail_article => :environment do | ||
44 | + article = Profile['software'].articles.find_by_slug('registro-na-lista') | ||
45 | + puts "Copying article #{article.title}: " | ||
46 | + if article.present? | ||
47 | + SoftwareInfo.find_each do |software| | ||
48 | + community = software.community | ||
49 | + a_copy = article.copy_without_save | ||
50 | + a_copy.profile = software.community | ||
51 | + a_copy.save if a_copy.profile.present? | ||
52 | + box = community.boxes.detect {|x| x.blocks.find_by_title("Participe") } if community.present? | ||
53 | + block = box.blocks.find_by_title("Participe") if box.present? | ||
54 | + link = block.links.detect { |l| l["name"] == "Lista de E-mails" } if block.present? | ||
55 | + link["address"] = "/{profile}/#{a_copy.path}" if link.present? | ||
56 | + block.save if block.present? | ||
57 | + print "." | ||
58 | + end | ||
59 | + end | ||
60 | + end | ||
42 | end | 61 | end |
src/noosfero-spb/software_communities/public/allow_variables.js
0 → 100644