Commit 4399cbfe667cdafd78b562c649bb6c296ecef1a2

Authored by Luciano Prestes
1 parent 7bfd56ca

Add repository block

Signed-off-by: Gabriela Navarro <navarro1703@gmail.com>
Signed-off-by: Luciano Prestes <lucianopcbr@gmail.com>
lib/download_block.rb
1 1 class DownloadBlock < Block
2 2  
3   - attr_accessible :name, :link, :software_description,:show_name, :version_news
  3 + attr_accessible :name, :link, :software_description, :show_name, :version_news
4 4  
5 5 settings_items :name, :type => :string, :default => ''
6 6 settings_items :link, :type => :string, :default => ''
... ...
lib/mpog_software_plugin.rb
... ... @@ -129,7 +129,8 @@ class MpogSoftwarePlugin &lt; Noosfero::Plugin
129 129 SoftwaresBlock => {:type => [Environment, Person] },
130 130 SoftwareInformationBlock => {:type => [Community] },
131 131 InstitutionsBlock => {:type => [Environment, Person]},
132   - DownloadBlock => {:type => [Community]}
  132 + DownloadBlock => {:type => [Community]},
  133 + RepositoryBlock => {:type => [Community]}
133 134 }
134 135 end
135 136  
... ... @@ -221,7 +222,7 @@ class MpogSoftwarePlugin &lt; Noosfero::Plugin
221 222  
222 223 required_list[:person_fields].each do |field|
223 224 if person.send(field).blank?
224   - empty_fields << field.sub("_"," ")
  225 + empty_fields << field.sub("_"," ")
225 226 end
226 227 end
227 228 required_list[:user_fields].each do |field|
... ...
lib/repository_block.rb 0 → 100644
... ... @@ -0,0 +1,30 @@
  1 +class RepositoryBlock < Block
  2 +
  3 + attr_accessible :link, :show_name
  4 +
  5 + settings_items :link, :type => :string, :default => ''
  6 + settings_items :show_name, :type => :boolean, :default => false
  7 +
  8 + def self.description
  9 + _('Repository Link')
  10 + end
  11 +
  12 + def help
  13 + _('This block displays the repository link of a software.')
  14 + end
  15 +
  16 + def content(args={})
  17 + block = self
  18 + s = show_name
  19 + lambda do |object|
  20 + render(
  21 + :file => 'blocks/repository',
  22 + :locals => { :block => block, :show_name => s }
  23 + )
  24 + end
  25 + end
  26 +
  27 + def cacheable?
  28 + false
  29 + end
  30 +end
... ...
test/unit/repository_block_test.rb 0 → 100644
... ... @@ -0,0 +1,28 @@
  1 +require File.dirname(__FILE__) + '/../../../../test/test_helper'
  2 +require File.dirname(__FILE__) + '/../helpers/plugin_test_helper'
  3 +
  4 +class RepositoryBlockTest < ActiveSupport::TestCase
  5 + include PluginTestHelper
  6 +
  7 + should 'inherit from Block' do
  8 + assert_kind_of Block, RepositoryBlock.new
  9 + end
  10 +
  11 + should 'declare its default title' do
  12 + RepositoryBlock.any_instance.stubs(:profile_count).returns(0)
  13 + assert_equal Block.new.default_title, RepositoryBlock.new.default_title
  14 + end
  15 +
  16 + should 'describe itself' do
  17 + assert_not_equal Block.description, RepositoryBlock.description
  18 + end
  19 +
  20 + should 'have software info to repository it' do
  21 +
  22 + link = "gitlab.com/teste"
  23 +
  24 + block = RepositoryBlock.create(:link => link)
  25 +
  26 + assert_equal block.link, link, "Link should not be empty"
  27 + end
  28 +end
... ...
views/blocks/repository.html.erb 0 → 100644
... ... @@ -0,0 +1 @@
  1 +<%= link_to _("Repositorio") , block.link, :id => "bt_repositorio", :target => "_blank" %>
0 2 \ No newline at end of file
... ...
views/box_organizer/_repository_block.html.erb 0 → 100644
... ... @@ -0,0 +1,3 @@
  1 +<div id='edit-repository-block'>
  2 + <%= labelled_form_field _('Link:'), text_field_tag('block[link]', @block.link) %>
  3 +</div>
... ...