#192: added ability to change visibility of platform
This commit is contained in:
parent
0e5e8cfd0b
commit
874086e1ca
|
@ -56,6 +56,17 @@ class Platforms::PlatformsController < Platforms::BaseController
|
|||
end
|
||||
end
|
||||
|
||||
def change_visibility
|
||||
if @platform.change_visibility
|
||||
flash[:notice] = I18n.t("flash.platform.saved")
|
||||
redirect_to @platform
|
||||
else
|
||||
flash[:error] = I18n.t("flash.platform.save_error")
|
||||
flash[:warning] = @platform.errors.full_messages.join('. ')
|
||||
render :action => :edit
|
||||
end
|
||||
end
|
||||
|
||||
def clone
|
||||
@cloned = Platform.new
|
||||
@cloned.name = @platform.name + "_clone"
|
||||
|
|
|
@ -105,7 +105,7 @@ class Ability
|
|||
can [:read, :related, :members], Platform, :owner_type => 'Group', :owner_id => user.group_ids
|
||||
can([:read, :related, :members], Platform, read_relations_for('platforms')) {|platform| local_reader? platform}
|
||||
can :related, Platform, :id => user.repositories.pluck(:platform_id)
|
||||
can([:update, :destroy], Platform) {|platform| owner?(platform) }
|
||||
can([:update, :destroy, :change_visibility], Platform) {|platform| owner?(platform) }
|
||||
can([:local_admin_manage, :members, :add_member, :remove_member, :remove_members] , Platform) {|platform| owner?(platform) || local_admin?(platform) }
|
||||
|
||||
can([:create, :publish], MassBuild) {|mass_build| owner?(mass_build.save_to_platform) || local_admin?(mass_build.save_to_platform)}
|
||||
|
@ -118,7 +118,7 @@ class Ability
|
|||
can([:remove_members, :remove_member, :add_member, :signatures], Repository) {|repository| owner?(repository.platform) || local_admin?(repository.platform)}
|
||||
can([:add_project, :remove_project], Repository) {|repository| repository.members.exists?(:id => user.id)}
|
||||
can(:clear, Platform) {|platform| owner?(platform) && platform.personal?}
|
||||
can([:change_visibility, :settings, :destroy, :edit, :update], Repository) {|repository| owner? repository.platform}
|
||||
can([:settings, :destroy, :edit, :update], Repository) {|repository| owner? repository.platform}
|
||||
|
||||
can([:create, :destroy], KeyPair) {|key_pair| owner?(key_pair.repository.platform) || local_admin?(key_pair.repository.platform)}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# -*- encoding : utf-8 -*-
|
||||
class Platform < ActiveRecord::Base
|
||||
VISIBILITIES = ['open']#, 'hidden'] # Disable support hidden platforms.
|
||||
VISIBILITIES = %w(open hidden)
|
||||
|
||||
belongs_to :parent, :class_name => 'Platform', :foreign_key => 'parent_platform_id'
|
||||
belongs_to :owner, :polymorphic => true
|
||||
|
@ -142,10 +142,8 @@ class Platform < ActiveRecord::Base
|
|||
def change_visibility
|
||||
if !hidden?
|
||||
update_attributes(:visibility => 'hidden')
|
||||
remove_symlink_directory
|
||||
else
|
||||
update_attributes(:visibility => 'open')
|
||||
symlink_directory
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -5,6 +5,16 @@
|
|||
= form_for @platform, :url => platform_path(@platform), :html => { :class => :form } do |f|
|
||||
= render "form", :f => f
|
||||
|
||||
- if can? :change_visibility, @platform
|
||||
.hr
|
||||
.leftside= t('activerecord.attributes.platform.visibility')
|
||||
.rightside= link_to t("layout.platforms.change_visibility_from_#{@platform.visibility}"),
|
||||
change_visibility_platform_path(@platform),
|
||||
:method => :post,
|
||||
:confirm => t("layout.platforms.confirm_change_visibility"),
|
||||
:class => 'button'
|
||||
.both
|
||||
|
||||
- if can? :destroy, @platform
|
||||
.hr
|
||||
.leftside= t("layout.platforms.delete_warning")
|
||||
|
|
|
@ -46,6 +46,9 @@ en:
|
|||
mass_build: Mass build
|
||||
build_task: Build Task
|
||||
refresh_button: Refresh
|
||||
change_visibility_from_hidden: Change status to "Public"
|
||||
change_visibility_from_open: Change status to "Private"
|
||||
confirm_change_visibility: Are you sure you want to change visibility of this platform?
|
||||
|
||||
flash:
|
||||
platform:
|
||||
|
|
|
@ -46,6 +46,9 @@ ru:
|
|||
build_task: Сборочное задание
|
||||
refresh_button: Обновить
|
||||
project: Проект
|
||||
change_visibility_from_hidden: Сменить статус на "Публичный"
|
||||
change_visibility_from_open: Сменить статус на "Приватный"
|
||||
confirm_change_visibility: Вы уверены, что хотите сменить статус этой платформы?
|
||||
|
||||
flash:
|
||||
platform:
|
||||
|
|
|
@ -22,8 +22,6 @@ en:
|
|||
|
||||
personal_repositories:
|
||||
settings_header: Settings
|
||||
change_visibility_from_hidden: Change status to "Public"
|
||||
change_visibility_from_open: Change status to "Private"
|
||||
settings: Settings
|
||||
show: My repository
|
||||
private_users: Private repository users
|
||||
|
|
|
@ -22,8 +22,6 @@ ru:
|
|||
|
||||
personal_repositories:
|
||||
settings_header: Настройки
|
||||
change_visibility_from_hidden: Сменить статус на "Публичный"
|
||||
change_visibility_from_open: Сменить статус на "Приватный"
|
||||
settings: Настройки
|
||||
show: Мой репозиторий
|
||||
private_users: Пользователи приватного репозитория
|
||||
|
|
|
@ -28,5 +28,5 @@ ru:
|
|||
authentication_token: Токен
|
||||
created_at: Создан
|
||||
updated_at: Обновлен
|
||||
creator: Создатель
|
||||
updater: Обновитель
|
||||
creator: Создал
|
||||
updater: Обновил
|
||||
|
|
|
@ -143,8 +143,9 @@ Rosa::Application.routes.draw do
|
|||
get :clone
|
||||
get :members
|
||||
post :remove_members # fixme: change post to delete
|
||||
post :change_visibility
|
||||
delete :remove_member
|
||||
post :add_member
|
||||
post :add_member
|
||||
post :make_clone
|
||||
get :advisories
|
||||
end
|
||||
|
|
|
@ -29,6 +29,22 @@ shared_examples_for 'platform user with owner rights' do
|
|||
end
|
||||
end
|
||||
|
||||
context 'perform change_visibility action' do
|
||||
before do
|
||||
@visibility = @platform.visibility
|
||||
post :change_visibility, :id => @platform.id
|
||||
end
|
||||
|
||||
it 'should be able to perform action' do
|
||||
response.should redirect_to(platform_path(@platform))
|
||||
end
|
||||
|
||||
it 'ensures that visibility of platform has been changed' do
|
||||
@platform.reload
|
||||
@platform.visibility.should_not == @visibility
|
||||
end
|
||||
end
|
||||
|
||||
context 'platform user with destroy rights for main platforms only' do
|
||||
it 'should be able to perform destroy action for main platform' do
|
||||
delete :destroy, :id => @platform.id
|
||||
|
@ -62,6 +78,22 @@ shared_examples_for 'platform user without owner rights' do
|
|||
end
|
||||
end
|
||||
|
||||
context 'perform change_visibility action' do
|
||||
before do
|
||||
@visibility = @platform.visibility
|
||||
post :change_visibility, :id => @platform.id
|
||||
end
|
||||
|
||||
it 'should not be able to perform action' do
|
||||
response.should_not be_success
|
||||
end
|
||||
|
||||
it 'ensures that visibility of platform has not been changed' do
|
||||
@platform.reload
|
||||
@platform.visibility.should == @visibility
|
||||
end
|
||||
end
|
||||
|
||||
context 'platform user without destroy rights' do
|
||||
it 'should not be able to perform destroy action for main platform' do
|
||||
delete :destroy, :id => @platform.id
|
||||
|
|
Loading…
Reference in New Issue