diff --git a/plugins/dspace/controllers/dspace_plugin_controller.rb b/plugins/dspace/controllers/dspace_plugin_controller.rb
index f7b753b..509e9d9 100644
--- a/plugins/dspace/controllers/dspace_plugin_controller.rb
+++ b/plugins/dspace/controllers/dspace_plugin_controller.rb
@@ -7,7 +7,15 @@ class DspacePluginController < PublicController
item_id = params[:id]
begin
- @item = Dspace::Item.get_item_by_id item_id
+ @collection = DspacePlugin::Collection.find(collection_id)
+ rescue ActiveRecord::RecordNotFound
+ render_not_found
+ return
+ end
+
+ begin
+ dspace_server = @collection.parent.parent.dspace_server_url
+ @item = Dspace::Item.get_item_by_id dspace_server, item_id
rescue ActiveResource::UnauthorizedAccess
render_not_found
return
diff --git a/plugins/dspace/controllers/dspace_plugin_myprofile_controller.rb b/plugins/dspace/controllers/dspace_plugin_myprofile_controller.rb
index ec133aa..380cfa1 100644
--- a/plugins/dspace/controllers/dspace_plugin_myprofile_controller.rb
+++ b/plugins/dspace/controllers/dspace_plugin_myprofile_controller.rb
@@ -31,20 +31,12 @@ class DspacePluginMyprofileController < CmsController
article_data.merge!(params[:article]) if params[:article]
if @type == 'DspacePlugin::Collection'
- ids_list = 'dspace_collections_ids'
- names_list = 'dspace_collections_names'
+ dspace_objects = article_data['dspace_collections']
elsif @type == 'DspacePlugin::Communityy'
- ids_list = 'dspace_communities_ids'
- names_list = 'dspace_communities_names'
+ dspace_objects = article_data['dspace_communities']
end
- index = -1
-
- article_data[ids_list].each do |id|
-
- index += 1
-
- name = article_data[names_list][index]
+ dspace_objects.each do |object|
entity = klass.new
@@ -55,18 +47,19 @@ class DspacePluginMyprofileController < CmsController
parent_id = parent.id
end
- entity.dspace_community_id = id if @type == 'DspacePlugin::Communityy'
-
- if @type == 'DspacePlugin::Collection'
- entity.dspace_collection_id = id
+ if @type == 'DspacePlugin::Communityy'
+ entity.dspace_community_id = object['id']
+ elsif @type == 'DspacePlugin::Collection'
entity.dspace_community_id = article_data['dspace_community_id']
+ entity.dspace_collection_id = object['id']
+ entity.accept_comments = false
end
+ entity.name = object['name']
entity.profile = profile
entity.author = user
entity.last_changed_by = user
entity.created_by = user
- entity.name = name
entity.save!
diff --git a/plugins/dspace/lib/dspace/client.rb b/plugins/dspace/lib/dspace/client.rb
deleted file mode 100644
index a8edce1..0000000
--- a/plugins/dspace/lib/dspace/client.rb
+++ /dev/null
@@ -1,16 +0,0 @@
-class Dspace::Client
-
- def initialize(server_url)
- @server_url = server_url
- end
-
- def get_collections
- Dspace::Collection.get_all_collections_from @server_url
- end
-
- def get_communities
- Dspace::Community.get_all_communities_from @server_url
- end
-
-end
-
diff --git a/plugins/dspace/lib/dspace/collection.rb b/plugins/dspace/lib/dspace/collection.rb
index 4dfbab6..5c3a7de 100644
--- a/plugins/dspace/lib/dspace/collection.rb
+++ b/plugins/dspace/lib/dspace/collection.rb
@@ -7,34 +7,9 @@ class Dspace::Collection < Dspace::Resource
item_list = []
if result.items.count > 0
-
result.items.each { |element|
-
- item_metadata = Dspace::Item.get_all_item_metadata_from dspace_server, element.id
-
- # author
- metadata = item_metadata[0].attributes
- if metadata != {}
- metadata = Hash[[metadata.map{|k,v| v}]]
- author = metadata.has_key?('dc.contributor.author') ? metadata['dc.contributor.author'] : nil
- end
-
- # date issued
- metadata = item_metadata[3].attributes
- if metadata != {}
- metadata = Hash[[metadata.map{|k,v| v}]]
- issue_date = metadata.has_key?('dc.date.issued') ? metadata['dc.date.issued'] : nil
- end
-
- item = DspacePlugin::Item.new
-
- item.id = element.id
- item.name = element.name
- item.author = author
- item.issue_date = issue_date
-
+ item = Dspace::Item.get_item_by_id dspace_server, element.id
item_list << item
-
}
end
diff --git a/plugins/dspace/lib/dspace/item.rb b/plugins/dspace/lib/dspace/item.rb
index 98d5109..ffc9470 100644
--- a/plugins/dspace/lib/dspace/item.rb
+++ b/plugins/dspace/lib/dspace/item.rb
@@ -6,8 +6,8 @@ class Dspace::Item < Dspace::Resource
result.metadata
end
- def self.get_item_by_id(item_id)
- self.site = 'http://dspace.maljr.net/rest/'
+ def self.get_item_by_id(dspace_server, item_id)
+ self.site = dspace_server
result = self.find item_id, :params => { :expand => 'metadata' }
item_metadata = Dspace::Item.get_all_item_metadata_from self.site, result.id
diff --git a/plugins/dspace/lib/dspace_plugin/collection.rb b/plugins/dspace/lib/dspace_plugin/collection.rb
index 5141853..ea5522e 100644
--- a/plugins/dspace/lib/dspace_plugin/collection.rb
+++ b/plugins/dspace/lib/dspace_plugin/collection.rb
@@ -18,9 +18,9 @@ class DspacePlugin::Collection < Article
end
def to_html(options = {})
- dspace_collection = self
+ dspace_content = self
proc do
- render :file => 'content_viewer/collection', :locals => {:dspace_collection => dspace_collection}
+ render :file => 'content_viewer/dspace_content', :locals => { :dspace_content => dspace_content }
end
end
diff --git a/plugins/dspace/lib/dspace_plugin/collection_helper.rb b/plugins/dspace/lib/dspace_plugin/collection_helper.rb
new file mode 100644
index 0000000..7b155e5
--- /dev/null
+++ b/plugins/dspace/lib/dspace_plugin/collection_helper.rb
@@ -0,0 +1,14 @@
+module DspacePlugin::CollectionHelper
+
+ include ArticleHelper
+
+ def custom_options_for_article(article,tokenized_children)
+ @article = article
+
+ visibility_options(article,tokenized_children) +
+ content_tag('div',
+ hidden_field_tag('article[accept_comments]', 0)
+ )
+ end
+
+end
diff --git a/plugins/dspace/lib/dspace_plugin/communityy.rb b/plugins/dspace/lib/dspace_plugin/communityy.rb
index 1274636..9a80040 100644
--- a/plugins/dspace/lib/dspace_plugin/communityy.rb
+++ b/plugins/dspace/lib/dspace_plugin/communityy.rb
@@ -1,4 +1,4 @@
-class DspacePlugin::Communityy < Article
+class DspacePlugin::Communityy < Folder
settings_items :dspace_community_id, :type => :string
@@ -17,9 +17,9 @@ class DspacePlugin::Communityy < Article
end
def to_html(options = {})
- dspace_community = self
+ dspace_content = self
proc do
- render :file => 'content_viewer/community', :locals => {:dspace_community => dspace_community}
+ render :file => 'content_viewer/dspace_content', :locals => { :dspace_content => dspace_content }
end
end
diff --git a/plugins/dspace/lib/dspace_plugin/communityy_helper.rb b/plugins/dspace/lib/dspace_plugin/communityy_helper.rb
new file mode 100644
index 0000000..b518101
--- /dev/null
+++ b/plugins/dspace/lib/dspace_plugin/communityy_helper.rb
@@ -0,0 +1,14 @@
+module DspacePlugin::CommunityyHelper
+
+ include ArticleHelper
+
+ def custom_options_for_article(article,tokenized_children)
+ @article = article
+
+ visibility_options(article,tokenized_children) +
+ content_tag('div',
+ hidden_field_tag('article[accept_comments]', 0)
+ )
+ end
+
+end
diff --git a/plugins/dspace/lib/dspace_plugin/dspace_block.rb b/plugins/dspace/lib/dspace_plugin/dspace_block.rb
deleted file mode 100644
index 3838050..0000000
--- a/plugins/dspace/lib/dspace_plugin/dspace_block.rb
+++ /dev/null
@@ -1,35 +0,0 @@
-class DspacePlugin::DspaceBlock < Block
-
- settings_items :dspace_server_url, :type => :string, :default => ""
- settings_items :collections, :type => :string, :default => ""
-
- attr_accessible :dspace_server_url, :collections
-
- def self.description
- _('DSpace library')
- end
-
- def help
- _('This block displays a DSpace content.')
- end
-
- def content(args={})
- block = self
- proc do
- dspace_client = Dspace::Client.new(block.dspace_server_url)
- collection_items = dspace_client.get_collection_items(block.collections)
- if !collection_items.blank?
- content_tag('div',
- render(:file => 'blocks/dspace', :locals => {:collection_items => collection_items})
- )
- else
- ''
- end
- end
- end
-
- def cacheable?
- false
- end
-
-end
diff --git a/plugins/dspace/lib/dspace_plugin/item.rb b/plugins/dspace/lib/dspace_plugin/item.rb
index 064f8c1..609da1d 100644
--- a/plugins/dspace/lib/dspace_plugin/item.rb
+++ b/plugins/dspace/lib/dspace_plugin/item.rb
@@ -1,6 +1,8 @@
class DspacePlugin::Item
- attr_accessor :id, :name, :author, :issue_date, :abstract, :description, :uri, :files
+ include DspacePlugin::ItemHelper
+
+ attr_accessor :id, :name, :author, :issue_date, :abstract, :description, :uri, :files, :mimetype
def initialize
self.files = []
diff --git a/plugins/dspace/lib/dspace_plugin/item_helper.rb b/plugins/dspace/lib/dspace_plugin/item_helper.rb
new file mode 100644
index 0000000..aaa0c7b
--- /dev/null
+++ b/plugins/dspace/lib/dspace_plugin/item_helper.rb
@@ -0,0 +1,8 @@
+module DspacePlugin::ItemHelper
+
+ def remove_slash_at_end_url(url)
+ url.gsub!(/\/$/,'') if url =~ /\/$/
+ url
+ end
+
+end
diff --git a/plugins/dspace/lib/dspace_plugin/library.rb b/plugins/dspace/lib/dspace_plugin/library.rb
index 4a13073..e39ab38 100644
--- a/plugins/dspace/lib/dspace_plugin/library.rb
+++ b/plugins/dspace/lib/dspace_plugin/library.rb
@@ -1,10 +1,16 @@
-class DspacePlugin::Library < Blog
+class DspacePlugin::Library < Folder
settings_items :dspace_server_url, :type => :string
attr_accessible :dspace_server_url
def dspace_server_url_valid
+
+ if self.dspace_server_url.blank?
+ errors.add(:dspace_server_url, _("can't be blank") )
+ return
+ end
+
errors.add(self.dspace_server_url, _("is not a valid URL. Please correct it and resubmit.")) unless url_valid?(self.dspace_server_url)
end
@@ -23,9 +29,9 @@ class DspacePlugin::Library < Blog
end
def to_html(options = {})
- dspace_library = self
+ dspace_content = self
proc do
- render :file => 'content_viewer/library', :locals => {:dspace_library => dspace_library}
+ render :file => 'content_viewer/dspace_content', :locals => { :dspace_content => dspace_content }
end
end
diff --git a/plugins/dspace/lib/dspace_plugin/library_helper.rb b/plugins/dspace/lib/dspace_plugin/library_helper.rb
new file mode 100644
index 0000000..c756ec8
--- /dev/null
+++ b/plugins/dspace/lib/dspace_plugin/library_helper.rb
@@ -0,0 +1,14 @@
+module DspacePlugin::LibraryHelper
+
+ include ArticleHelper
+
+ def custom_options_for_article(article,tokenized_children)
+ @article = article
+
+ visibility_options(article,tokenized_children) +
+ content_tag('div',
+ hidden_field_tag('article[accept_comments]', 0)
+ )
+ end
+
+end
diff --git a/plugins/dspace/lib/ext/article.rb b/plugins/dspace/lib/ext/article.rb
deleted file mode 100644
index 659fe60..0000000
--- a/plugins/dspace/lib/ext/article.rb
+++ /dev/null
@@ -1,95 +0,0 @@
-require_dependency 'article'
-
-class Article
-
- scope :dspace, :conditions => ["articles.published = true and (articles.type != 'UploadedFile' and articles.type != 'Blog' and articles.type != 'RssFeed') OR articles.type is NULL"]
-
- def self.articles_columns
- Article.column_names.map {|c| "articles.#{c}"} .join(",")
- end
-
- def self.most_accessed(owner, limit = nil)
- conditions = owner.kind_of?(Environment) ? ["hits > 0"] : ["profile_id = ? and hits > 0", owner.id]
- result = Article.dspace.find(
- :all,
- :order => 'hits desc',
- :limit => limit,
- :conditions => conditions)
- result.paginate({:page => 1, :per_page => limit})
- end
-
- def self.most_commented_dspace(owner, limit)
- conditions = owner.kind_of?(Environment) ? ["comments_count > 0"] : ["profile_id = ? and comments_count > 0", owner.id]
- result = Article.dspace.find(
- :all,
- :order => 'comments_count desc',
- :limit => limit,
- :conditions => conditions)
- result.paginate({:page => 1, :per_page => limit})
- end
-
- def self.more_positive_votes(owner, limit = nil)
- conditions = owner.kind_of?(Environment) ? {'votes.voteable_type' => 'Article'} : ["profile_id = ? and votes.voteable_type = ? ", owner.id, 'Article']
- result = Article.dspace.find(
- :all,
- :order => 'sum(vote) desc',
- :group => 'voteable_id, ' + articles_columns,
- :limit => limit,
- :having => ['sum(vote) > 0'],
- :conditions => conditions,
- :joins => 'INNER JOIN votes ON articles.id = votes.voteable_id')
- result.paginate({:page => 1, :per_page => limit})
- end
-
- def self.more_negative_votes(owner, limit = nil)
- conditions = owner.kind_of?(Environment) ? {'votes.voteable_type' => 'Article'} : ["profile_id = ? and votes.voteable_type = 'Article' ", owner.id]
- result = Article.dspace.find(
- :all,
- :order => 'sum(vote) asc',
- :group => 'voteable_id, ' + articles_columns,
- :limit => limit,
- :having => ['sum(vote) < 0'],
- :conditions => conditions,
- :joins => 'INNER JOIN votes ON articles.id = votes.voteable_id'
- )
- result.paginate({:page => 1, :per_page => limit})
- end
-
- def self.most_liked(owner, limit = nil)
- conditions = owner.kind_of?(Environment) ? ["votes.voteable_type = 'Article' and vote > 0"] : ["votes.voteable_type = 'Article' and vote > 0 and profile_id = ? ", owner.id]
- result = Article.dspace.find(
- :all,
- :select => articles_columns,
- :order => 'count(voteable_id) desc',
- :group => 'voteable_id, ' + articles_columns,
- :limit => limit,
- :conditions => conditions,
- :joins => 'INNER JOIN votes ON articles.id = votes.voteable_id')
- result.paginate({:page => 1, :per_page => limit})
- end
-
- def self.most_disliked(owner, limit = nil)
- conditions = owner.kind_of?(Environment) ? ["votes.voteable_type = 'Article' and vote < 0"] : ["votes.voteable_type = 'Article' and vote < 0 and profile_id = ? ", owner.id]
- result = Article.dspace.find(
- :all,
- :order => 'count(voteable_id) desc',
- :group => 'voteable_id, ' + articles_columns,
- :limit => limit,
- :conditions => conditions,
- :joins => 'INNER JOIN votes ON articles.id = votes.voteable_id')
- result.paginate({:page => 1, :per_page => limit})
- end
-
- def self.most_voted(owner, limit = nil)
- conditions = owner.kind_of?(Environment) ? ["votes.voteable_type = 'Article'"] : ["votes.voteable_type = 'Article' and profile_id = ? ", owner.id]
- result = Article.dspace.find(
- :all,
- :select => articles_columns,
- :order => 'count(voteable_id) desc',
- :group => 'voteable_id, ' + articles_columns,
- :limit => limit,
- :conditions => conditions,
- :joins => 'INNER JOIN votes ON articles.id = votes.voteable_id')
- result.paginate({:page => 1, :per_page => limit})
- end
-end
diff --git a/plugins/dspace/public/icons/audio.png b/plugins/dspace/public/icons/audio.png
new file mode 100644
index 0000000..fc4e198
Binary files /dev/null and b/plugins/dspace/public/icons/audio.png differ
diff --git a/plugins/dspace/public/icons/doc.png b/plugins/dspace/public/icons/doc.png
new file mode 100644
index 0000000..ff31c47
Binary files /dev/null and b/plugins/dspace/public/icons/doc.png differ
diff --git a/plugins/dspace/public/icons/image.png b/plugins/dspace/public/icons/image.png
new file mode 100644
index 0000000..83b32b4
Binary files /dev/null and b/plugins/dspace/public/icons/image.png differ
diff --git a/plugins/dspace/public/icons/pdf.png b/plugins/dspace/public/icons/pdf.png
new file mode 100644
index 0000000..9b5123c
Binary files /dev/null and b/plugins/dspace/public/icons/pdf.png differ
diff --git a/plugins/dspace/public/icons/spreadsheet.png b/plugins/dspace/public/icons/spreadsheet.png
new file mode 100644
index 0000000..06103e5
Binary files /dev/null and b/plugins/dspace/public/icons/spreadsheet.png differ
diff --git a/plugins/dspace/public/icons/text.png b/plugins/dspace/public/icons/text.png
new file mode 100644
index 0000000..ff069ff
Binary files /dev/null and b/plugins/dspace/public/icons/text.png differ
diff --git a/plugins/dspace/public/icons/video.png b/plugins/dspace/public/icons/video.png
new file mode 100644
index 0000000..cfe02b5
Binary files /dev/null and b/plugins/dspace/public/icons/video.png differ
diff --git a/plugins/dspace/public/javascripts/dspace_plugin.js b/plugins/dspace/public/javascripts/dspace_plugin.js
index 6ff6bfe..83e0367 100644
--- a/plugins/dspace/public/javascripts/dspace_plugin.js
+++ b/plugins/dspace/public/javascripts/dspace_plugin.js
@@ -1,3 +1,5 @@
+/**
+
function selectCommunity(element, community_slug) {
var hidden_field = jQuery('').attr({
id: 'article_dspace_community_name_',
@@ -9,6 +11,7 @@ function selectCommunity(element, community_slug) {
jQuery(hidden_field).insertAfter(element);
}
+
function selectCollection(element, collection_slug) {
var hidden_field = jQuery('').attr({
id: 'article_dspace_collection_name_',
@@ -20,6 +23,10 @@ function selectCollection(element, collection_slug) {
jQuery(hidden_field).insertAfter(element);
}
+function select_action(field_active) {
+}
+**/
+
jQuery(document).ready(function() {
url_base = window.location.protocol + '//' + window.location.host;
forms = jQuery('form');
@@ -29,4 +36,50 @@ jQuery(document).ready(function() {
forms[f].action = url_action.replace("/cms/new", "/plugin/dspace/new").replace(url_base,'');
}
});
+
+ function check_fields(check, table_id) {
+ var checkboxes = jQuery("#" + table_id + " tbody tr td input[type='checkbox']")
+ for (var i = 0; i < checkboxes.length; i++) {
+ if (checkboxes[i].disabled == false) {
+ checkboxes[i].checked = check
+ }
+ }
+ }
+
+ function verify_checked(field_id){
+ var checkboxes = jQuery("#" + field_id + "_fields_conf tbody tr td input[type='checkbox']")
+ var allchecked = true;
+ for (var j = 1; j < checkboxes.length; j++) {
+ if(!checkboxes[j].checked) {
+ allchecked = false;
+ break;
+ }
+ }
+
+ var checkbox = jQuery("#" + field_id + "_active");
+ checkbox.attr("checked", allchecked);
+ }
+
+
+ function check_all(field_id) {
+ jQuery("#" + field_id + "_active").click(function (){
+ check_fields(this.checked, field_id + "_fields_conf")
+ });
+ verify_checked(field_id);
+ }
+
+ check_all("community");
+ check_all("collection");
+
+ jQuery("input[type='checkbox']").click(function () {
+ var checkbox = jQuery(this).attr("id").split("_");
+ verify_checked(checkbox.first());
+
+ if(this.checked == false) {
+ jQuery("#" + checkbox.first() + "_" + checkbox.last()).attr("checked", false)
+ }
+
+ jQuery(this).next().attr("disabled", !this.checked);
+ })
+
});
diff --git a/plugins/dspace/public/style.css b/plugins/dspace/public/style.css
index b5a477e..dbabb59 100644
--- a/plugins/dspace/public/style.css
+++ b/plugins/dspace/public/style.css
@@ -1,10 +1,11 @@
#dspace_library ul {
margin: 0;
- padding: 0 0 0 20px;
+ padding: 0 0 0 5px;
}
#dspace_library li {
- list-style-image: url(/designs/themes/base/imgs/li-recent.gif);
+ /**list-style-image: url(/designs/themes/base/imgs/li-recent.gif);*/
+ list-style-type: none;
}
#dspace_library li.item,
@@ -28,7 +29,7 @@
}
.dspace_item_section {
- margin-left: 20px;
+ margin: 15px;
}
.dspace_item_section_title {
diff --git a/plugins/dspace/test/test_helper.rb b/plugins/dspace/test/test_helper.rb
deleted file mode 100644
index cca1fd3..0000000
--- a/plugins/dspace/test/test_helper.rb
+++ /dev/null
@@ -1 +0,0 @@
-require File.dirname(__FILE__) + '/../../../test/test_helper'
diff --git a/plugins/dspace/test/unit/article.rb b/plugins/dspace/test/unit/article.rb
deleted file mode 100644
index 64ecbcb..0000000
--- a/plugins/dspace/test/unit/article.rb
+++ /dev/null
@@ -1,148 +0,0 @@
-require File.dirname(__FILE__) + '/../test_helper'
-
-require 'comment_controller'
-# Re-raise errors caught by the controller.
-class CommentController; def rescue_action(e) raise e end; end
-
-class DspaceBlockTest < ActiveSupport::TestCase
-
- include AuthenticatedTestHelper
- fixtures :users, :environments
-
- def setup
- @controller = CommentController.new
- @request = ActionController::TestRequest.new
- @response = ActionController::TestResponse.new
- @profile = create_user('testinguser').person
- @environment = @profile.environment
- end
- attr_reader :profile, :environment
-
- def enable_vote_plugin
- enabled = false
- environment=Environment.default
- if Noosfero::Plugin.all.include?('VotePlugin')
- if not environment.enabled_plugins.include?(:vote)
- environment.enable_plugin(Vote)
- environment.save!
- end
- enabled = true
- end
- enabled
- end
-
- should 'list most commented articles' do
- Article.delete_all
- a1 = create(TextileArticle, :name => "art 1", :profile_id => profile.id)
- a2 = create(TextileArticle, :name => "art 2", :profile_id => profile.id)
- a3 = create(TextileArticle, :name => "art 3", :profile_id => profile.id)
-
- 2.times { Comment.create(:title => 'test', :body => 'asdsad', :author => profile, :source => a2).save! }
- 4.times { Comment.create(:title => 'test', :body => 'asdsad', :author => profile, :source => a3).save! }
-
- # should respect the order (more commented comes first)
- assert_equal a3.name, profile.articles.most_commented_dspace(Environment.default, 3).first.name
- # It is a2 instead of a1 since it does not list articles without comments
- assert_equal a2.name, profile.articles.most_commented_dspace(Environment.default, 3).last.name
- end
-
-
- should 'find the most voted' do
- if not enable_vote_plugin
- return
- end
- article = fast_create(Article, {:name=>'2 votes'})
- 2.times{
- person = fast_create(Person)
- person.vote_for(article)
- }
- article = fast_create(Article, {:name=>'10 votes'})
- 10.times{
- person = fast_create(Person)
- person.vote_for(article)
- }
- article = fast_create(Article, {:name=>'5 votes'})
- 5.times{
- person = fast_create(Person)
- person.vote_for(article)
- }
- articles = Article.most_voted(Environment.default, 5)
- assert_equal '10 votes', articles.first.name
- assert_equal '2 votes', articles.last.name
- end
-
- should 'list the most postive' do
- if not enable_vote_plugin
- return
- end
- article = fast_create(Article, {:name=>'23 votes for 20 votes against'})
- 20.times{
- person = fast_create(Person)
- person.vote_against(article)
- }
- 23.times{
- person = fast_create(Person)
- person.vote_for(article)
- }
- article = fast_create(Article, {:name=>'10 votes for 5 votes against'})
- 10.times{
- person = fast_create(Person)
- person.vote_for(article)
- }
- 5.times{
- person = fast_create(Person)
- person.vote_against(article)
- }
- article = fast_create(Article, {:name=>'2 votes against'})
- 2.times{
- person = fast_create(Person)
- person.vote_against(article)
- }
-
- article = fast_create(Article, {:name=>'7 votes for'})
- 7.times{
- person = fast_create(Person)
- person.vote_for(article)
- }
- articles = Article.more_positive_votes(Environment.default, 5)
- assert_equal '7 votes for', articles.first.name
- assert_equal '23 votes for 20 votes against', articles.last.name
- end
-
- should 'list the most negative' do
- if not enable_vote_plugin
- return
- end
- article = fast_create(Article, {:name=>'23 votes for 29 votes against'})
- 29.times{
- person = fast_create(Person)
- person.vote_against(article)
- }
- 23.times{
- person = fast_create(Person)
- person.vote_for(article)
- }
- article = fast_create(Article, {:name=>'10 votes for 15 votes against'})
- 10.times{
- person = fast_create(Person)
- person.vote_for(article)
- }
- 15.times{
- person = fast_create(Person)
- person.vote_against(article)
- }
- article = fast_create(Article, {:name=>'2 votes against'})
- 2.times{
- person = fast_create(Person)
- person.vote_against(article)
- }
- article = fast_create(Article, {:name=>'7 votes for'})
- 7.times{
- person = fast_create(Person)
- person.vote_for(article)
- }
- articles = Article.more_negative_votes(Environment.default, 5)
- assert_equal '23 votes for 29 votes against', articles.first.name
- assert_equal '2 votes against', articles.last.name
- end
-end
\ No newline at end of file
diff --git a/plugins/dspace/test/unit/dspace_plugin_test.rb b/plugins/dspace/test/unit/dspace_plugin_test.rb
deleted file mode 100644
index 08087c5..0000000
--- a/plugins/dspace/test/unit/dspace_plugin_test.rb
+++ /dev/null
@@ -1,29 +0,0 @@
-require File.dirname(__FILE__) + '/../test_helper'
-
-class DspacePluginTest < ActiveSupport::TestCase
-
- def setup
- @plugin = DspacePlugin.new
- end
-
- should 'be a noosfero plugin' do
- assert_kind_of Noosfero::Plugin, @plugin
- end
-
- should 'have name' do
- assert_equal 'Relevant Content Plugin', DspacePlugin.plugin_name
- end
-
- should 'have description' do
- assert_equal _("A plugin that lists the most accessed, most commented, most liked and most disliked contents."), DspacePlugin.plugin_description
- end
-
- should 'have stylesheet' do
- assert @plugin.stylesheet?
- end
-
- should "return DspaceBlock in extra_blocks class method" do
- assert DspacePlugin.extra_blocks.keys.include?(DspacePlugin::DspaceBlock)
- end
-
-end
diff --git a/plugins/dspace/views/cms/dspace_plugin/_collection.html.erb b/plugins/dspace/views/cms/dspace_plugin/_collection.html.erb
index d4b1d20..d672f5a 100644
--- a/plugins/dspace/views/cms/dspace_plugin/_collection.html.erb
+++ b/plugins/dspace/views/cms/dspace_plugin/_collection.html.erb
@@ -10,10 +10,14 @@
<% collections = Dspace::Community.get_all_collections_from( dspace_server_url, community_id ).map { |collection| item = [_(collection.name), collection.id] } %>
-
-
- |
- <%= _('Collection name') %> |
+
+
+
+ <%= _("Check/Uncheck All Unlocked")%>
+ |
+
+
+ |
<% dspace_collections_ids = DspacePlugin::Collection.find(:all, :conditions => { :parent_id => @article.parent_id}).map { |collection| ids = collection.dspace_collection_id.to_i } %>
@@ -21,14 +25,22 @@
<% collections.each do |collection| %>
- <% if dspace_collections_ids.include? collection[1] %>
- <%= check_box_tag "article[dspace_collections_ids][]", collection[1], true, :disabled => 'disabled', :onclick => "selectCollection(this,'#{collection[0]}')" %> |
- <% else %>
- <%= check_box_tag "article[dspace_collections_ids][]", collection[1], false, :onclick => "selectCollection(this,'#{collection[0]}')" %> |
- <% end %>
<%= collection[0] %>
|
+
+ <% if dspace_collections_ids.include? collection[1] %>
+
+ <%= check_box_tag "article[dspace_collections][][id]", collection[1], true, :disabled => 'disabled', :id => "collection_id_#{collection[1]}" %>
+ <%= hidden_field_tag "article[dspace_collections][][name]", collection[0], :disabled => 'disabled' %>
+ |
+ <% else %>
+
+ <%= check_box_tag "article[dspace_collections][][id]", collection[1], false, :id => "collection_id_#{collection[1]}" %>
+ <%= hidden_field_tag "article[dspace_collections][][name]", collection[0], :disabled => 'disabled', :id => "collection_name_#{collection[1]}" %>
+ |
+ <% end %>
+
<% end %>
diff --git a/plugins/dspace/views/cms/dspace_plugin/_communityy.html.erb b/plugins/dspace/views/cms/dspace_plugin/_communityy.html.erb
index ef3ecd8..91d7185 100644
--- a/plugins/dspace/views/cms/dspace_plugin/_communityy.html.erb
+++ b/plugins/dspace/views/cms/dspace_plugin/_communityy.html.erb
@@ -6,10 +6,14 @@
<% communities = Dspace::Community.get_all_communities_from(dspace_server_url).map { |community| item = [_(community.name), community.id] } %>
-
-
- |
- <%= _('Community name') %> |
+