noosfero | 2 new commits pushed to repository
Antonio Terceiro
gitlab at gitlab.com
Mon Mar 16 16:27:32 BRT 2015
Antonio Terceiro pushed to refs/heads/next at <a href="https://gitlab.com/noosfero/noosfero">Noosfero / noosfero</a>
Commits:
<a href="https://gitlab.com/noosfero/noosfero/commit/497160239c025f98c5f855a8c9f3d5b45c5c4937">49716023</a> by Filipe Ribeiro
Add Secret type to communities' privacy options
- created 'secret' attribute for profiles
- redefined scope for secret communities
Signed-off-by: Arthur Del Esposte <arthurmde at gmail.com>
Signed-off-by: Álvaro Fernando <alvarofernandoms at gmail.com>
Signed-off-by: Dylan Guedes <djmgguedes at gmail.com>
Signed-off-by: Fabio Teixeira <fabio1079 at gmail.com>
Signed-off-by: Filipe Ribeiro <firibeiro77 at live.com>
Signed-off-by: Pedro de Lyra <pedrodelyra at gmail.com>
Signed-off-by: Tallys Martins <tallysmartins at gmail.com>
- - - - -
<a href="https://gitlab.com/noosfero/noosfero/commit/be674ec979a004e9fbd5f23066466c48e56c0ef7">be674ec9</a> by Antonio Terceiro
Merge branch 'softwarepublico/noosfero-secret_comunity' into next
See merge request !481
- - - - -
Changes:
=====================================
app/models/profile.rb
=====================================
--- a/app/models/profile.rb
+++ b/app/models/profile.rb
@@ -3,7 +3,7 @@
# which by default is the one returned by Environment:default.
class Profile < ActiveRecord::Base
- attr_accessible :name, :identifier, :public_profile, :nickname, :custom_footer, :custom_header, :address, :zip_code, :contact_phone, :image_builder, :description, :closed, :template_id, :environment, :lat, :lng, :is_template, :fields_privacy, :preferred_domain_id, :category_ids, :country, :city, :state, :national_region_code, :email, :contact_email, :redirect_l10n, :notification_time, :redirection_after_login, :email_suggestions, :allow_members_to_invite, :invite_friends_only
+ attr_accessible :name, :identifier, :public_profile, :nickname, :custom_footer, :custom_header, :address, :zip_code, :contact_phone, :image_builder, :description, :closed, :template_id, :environment, :lat, :lng, :is_template, :fields_privacy, :preferred_domain_id, :category_ids, :country, :city, :state, :national_region_code, :email, :contact_email, :redirect_l10n, :notification_time, :redirection_after_login, :email_suggestions, :allow_members_to_invite, :invite_friends_only, :secret
# use for internationalizable human type names in search facets
# reimplement on subclasses
@@ -119,9 +119,9 @@ class Profile < ActiveRecord::Base
Profile.column_names.map{|n| [Profile.table_name, n].join('.')}.join(',')
end
- scope :visible, :conditions => { :visible => true }
+ scope :visible, :conditions => { :visible => true, :secret => false }
scope :disabled, :conditions => { :visible => false }
- scope :public, :conditions => { :visible => true, :public_profile => true }
+ scope :public, :conditions => { :visible => true, :public_profile => true, :secret => false }
scope :enabled, :conditions => { :enabled => true }
# Subclasses must override this method
=====================================
app/views/profile_editor/edit.html.erb
=====================================
--- a/app/views/profile_editor/edit.html.erb
+++ b/app/views/profile_editor/edit.html.erb
@@ -34,10 +34,13 @@
</div>
<% else %>
<div>
- <%= labelled_radio_button _('Public — show content of this group to all internet users'), 'profile_data[public_profile]', true, @profile.public_profile? %>
+ <%= labelled_check_box _("Secret — hide the community and all its contents for non members and other people can't join this community unless they are invited to."), 'profile_data[secret]', true, profile.secret, :class => "profile-secret-box" %>
</div>
<div>
- <%= labelled_radio_button _('Private — show content of this group only to members'), 'profile_data[public_profile]', false, !@profile.public_profile? %>
+ <%= labelled_radio_button _('Public — show content of this group to all internet users'), 'profile_data[public_profile]', true, @profile.public_profile?, :class => "public-community-button" %>
+ </div>
+ <div>
+ <%= labelled_radio_button _('Private — show content of this group only to members'), 'profile_data[public_profile]', false, !@profile.public_profile?, :class => "private-community-button" %>
</div>
<% end %>
@@ -85,4 +88,6 @@
<% end %>
<% end %>
<% end %>
-<% end %>
\ No newline at end of file
+<% end %>
+
+<%= javascript_include_tag 'profile_editor' %>
=====================================
db/migrate/20150223180806_add_secret_to_profile.rb
=====================================
--- /dev/null
+++ b/db/migrate/20150223180806_add_secret_to_profile.rb
@@ -0,0 +1,5 @@
+class AddSecretToProfile < ActiveRecord::Migration
+ def change
+ add_column :profiles, :secret, :boolean, :default => false
+ end
+end
=====================================
db/schema.rb
=====================================
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20150122165042) do
+ActiveRecord::Schema.define(:version => 20150223180806) do
create_table "abuse_reports", :force => true do |t|
t.integer "reporter_id"
@@ -535,6 +535,7 @@ ActiveRecord::Schema.define(:version => 20150122165042) do
t.integer "welcome_page_id"
t.boolean "allow_members_to_invite", :default => true
t.boolean "invite_friends_only", :default => false
+ t.boolean "secret", :default => false
end
add_index "profiles", ["activities_count"], :name => "index_profiles_on_activities_count"
=====================================
features/secret_community.feature
=====================================
--- /dev/null
+++ b/features/secret_community.feature
@@ -0,0 +1,60 @@
+Feature: Use a secret community
+ As a community administrator
+ I want to manage the community privacy
+
+ Background:
+ Given the following users
+ | login | name |
+ | jose | Jose Wilker |
+ | maria | Maria Carminha |
+ And the following community
+ | identifier | name |
+ | mycommunity | My Community |
+ And "Jose Wilker" is admin of "My Community"
+ And I am logged in as "jose"
+ And I go to mycommunity's control panel
+ And I follow "Community Info and settings"
+ And I check "Secret"
+ And I press "Save"
+ And I follow "Logout"
+
+ @selenium
+ Scenario: Hide privacity options when secret is checked
+ Given I am logged in as "jose"
+ And I go to mycommunity's control panel
+ And I follow "Community Info and settings"
+ Then I should not see "Public — show content of this group to all internet users"
+ And I should not see "Private — show content of this group only to members"
+ And I uncheck "Secret"
+ Then I should see "Public — show content of this group to all internet users"
+ Then I should see "Private — show content of this group only to members"
+
+ @selenium
+ Scenario: Non members shouldn't see secret communit's content
+ Given I am logged in as "maria"
+ And I go to mycommunity's homepage
+ And I should see "Access denied"
+ And I follow "Communities"
+ Then I should not see "My Community"
+
+ Scenario: A member should see the secret community's content
+ Given I am logged in as "maria"
+ And "Maria Carminha" is a member of "My Community"
+ And I go to maria's control panel
+ And I follow "Manage my groups"
+ And I follow "My Community"
+ Then I should see "My Community"
+
+ @selenium
+ Scenario: public article on a secret profile should not be displayed
+ Given I am logged in as "jose"
+ And I go to mycommunity's control panel
+ And I follow "Manage Content"
+ And I follow "New content"
+ And I follow "Text article with visual editor"
+ And I fill in "Title" with "My public article"
+ And I choose "Public"
+ And I press "Save and continue"
+ When I am logged in as "maria"
+ And I go to /mycommunity/my-public-article
+ Then I should not see "My public article"
=====================================
public/javascripts/profile_editor.js
=====================================
--- /dev/null
+++ b/public/javascripts/profile_editor.js
@@ -0,0 +1,26 @@
+(function($){
+ 'use strict';
+
+ function show_or_hide_privacy_radio_buttons(hide_options) {
+ var public_community = $(".public-community-button").parent();
+ var private_community = $(".private-community-button").parent();
+ if (hide_options) {
+ $(".private-community-button").selected();
+ public_community.hide();
+ private_community.hide();
+
+ } else {
+ public_community.show();
+ private_community.show();
+ }
+ }
+
+ $(document).ready(function(){
+ var profile_secret = $(".profile-secret-box");
+ show_or_hide_privacy_radio_buttons(profile_secret.is(":checked"));
+ profile_secret.change(function(){
+ show_or_hide_privacy_radio_buttons(this.checked);
+ });
+
+ });
+})(jQuery);
=====================================
test/unit/profile_test.rb
=====================================
--- a/test/unit/profile_test.rb
+++ b/test/unit/profile_test.rb
@@ -443,6 +443,24 @@ class ProfileTest < ActiveSupport::TestCase
assert_not_includes result, p2
end
+ should 'be able to find the public profiles but not secret ones' do
+ p1 = create(Profile, :public_profile => true)
+ p2 = create(Profile, :public_profile => true, :secret => true)
+
+ result = Profile.public
+ assert_includes result, p1
+ assert_not_includes result, p2
+ end
+
+ should 'be able to find visible profiles but not secret ones' do
+ p1 = create(Profile, :visible => true)
+ p2 = create(Profile, :visible => true, :secret => true)
+
+ result = Profile.visible
+ assert_includes result, p1
+ assert_not_includes result, p2
+ end
+
should 'have public content by default' do
assert_equal true, Profile.new.public_content
end
@@ -485,7 +503,7 @@ class ProfileTest < ActiveSupport::TestCase
should 'categorize in the entire category hierarchy' do
c1 = fast_create(Category)
c2 = fast_create(Category, :parent_id => c1.id)
- c3 = fast_create(Category, :parent_id => c2.id)
+ c3 = fast_create(Category, :parent_id => c2.id)
profile = create_user('testuser').person
profile.add_category(c3)
@@ -1006,7 +1024,7 @@ class ProfileTest < ActiveSupport::TestCase
should 'copy header when applying template' do
template = fast_create(Profile)
- template[:custom_header] = '{name}'
+ template[:custom_header] = '{name}'
template.save!
p = create(Profile, :name => 'test prof')
@@ -1260,7 +1278,7 @@ class ProfileTest < ActiveSupport::TestCase
task2 = Task.create!(:requestor => person, :target => another)
person.stubs(:is_admin?).with(other).returns(true)
- Environment.find(:all).select{|i| i != other }.each do |env|
+ Environment.find(:all).select{|i| i != other }.each do |env|
person.stubs(:is_admin?).with(env).returns(false)
end
@@ -1729,7 +1747,7 @@ class ProfileTest < ActiveSupport::TestCase
assert profile.is_on_homepage?("/#{profile.identifier}/#{homepage.slug}", homepage)
end
-
+
should 'find profiles with image' do
env = fast_create(Environment)
2.times do |n|
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listas.softwarelivre.org/pipermail/noosfero-dev/attachments/20150316/f77e3c59/attachment-0001.html>
More information about the Noosfero-dev
mailing list