Merge pull request #318 from warpc/279-new_design_for_platforms
[Refs #279] new design for platforms(add control for members, fix bugs)
This commit is contained in:
commit
047425a27f
|
@ -511,8 +511,10 @@ table.tablesorter.repo-projects th.th1 {
|
||||||
width: 250px;
|
width: 250px;
|
||||||
}
|
}
|
||||||
|
|
||||||
table.tablesorter.repo-projects th.th3 {
|
table.tablesorter.repo-projects th.th3,
|
||||||
|
table.tablesorter th.buttons {
|
||||||
width: 60px;
|
width: 60px;
|
||||||
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
table.tablesorter.repo-projects td.td2,
|
table.tablesorter.repo-projects td.td2,
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
# -*- encoding : utf-8 -*-
|
# -*- encoding : utf-8 -*-
|
||||||
class PlatformsController < ApplicationController
|
class PlatformsController < ApplicationController
|
||||||
before_filter :authenticate_user!, :except => :easy_urpmi
|
before_filter :authenticate_user!, :except => :easy_urpmi
|
||||||
before_filter :find_platform, :only => [:clone, :edit, :destroy]
|
before_filter :find_platform, :only => [:clone, :edit, :destroy, :members]
|
||||||
before_filter :get_paths, :only => [:new, :create, :clone]
|
before_filter :get_paths, :only => [:new, :create, :clone]
|
||||||
|
|
||||||
load_and_authorize_resource
|
load_and_authorize_resource
|
||||||
|
@ -14,7 +14,7 @@ class PlatformsController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@platforms = @platforms.paginate(:page => params[:page], :per_page => 20)
|
@platforms = @platforms.accessible_by(current_ability, :related).paginate(:page => params[:page], :per_page => 20)
|
||||||
end
|
end
|
||||||
|
|
||||||
def easy_urpmi
|
def easy_urpmi
|
||||||
|
@ -105,10 +105,47 @@ class PlatformsController < ApplicationController
|
||||||
flash[:notice] = t("flash.platform.destroyed")
|
flash[:notice] = t("flash.platform.destroyed")
|
||||||
redirect_to platforms_path
|
redirect_to platforms_path
|
||||||
end
|
end
|
||||||
|
|
||||||
def forbidden
|
def forbidden
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def members
|
||||||
|
@members = @platform.members.order('name')
|
||||||
|
end
|
||||||
|
|
||||||
|
def remove_members
|
||||||
|
all_user_ids = params['user_remove'].inject([]) {|a, (k, v)| a << k if v.first == '1'; a}
|
||||||
|
all_user_ids.each do |uid|
|
||||||
|
Relation.by_target(@platform).where(:object_id => uid, :object_type => 'User').each{|r| r.destroy}
|
||||||
|
end
|
||||||
|
redirect_to members_platform_path(@platform)
|
||||||
|
end
|
||||||
|
|
||||||
|
def remove_member
|
||||||
|
u = User.find(params[:member_id])
|
||||||
|
Relation.by_object(u).by_target(@platform).each{|r| r.destroy}
|
||||||
|
|
||||||
|
redirect_to members_platform_path(@platform)
|
||||||
|
end
|
||||||
|
|
||||||
|
def add_member
|
||||||
|
if params[:member_id].present?
|
||||||
|
member = User.find(params[:member_id])
|
||||||
|
if @platform.relations.exists?(:object_id => member.id, :object_type => member.class.to_s) or @platform.owner == member
|
||||||
|
flash[:warning] = t('flash.platform.members.already_added', :name => member.uname)
|
||||||
|
else
|
||||||
|
rel = @platform.relations.build(:role => 'admin')
|
||||||
|
rel.object = member
|
||||||
|
if rel.save
|
||||||
|
flash[:notice] = t('flash.platform.members.successfully_added', :name => member.uname)
|
||||||
|
else
|
||||||
|
flash[:error] = t('flash.platform.members.error_in_adding', :name => member.uname)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
redirect_to members_platform_url(@platform)
|
||||||
|
end
|
||||||
|
|
||||||
protected
|
protected
|
||||||
def get_paths
|
def get_paths
|
||||||
if params[:user_id]
|
if params[:user_id]
|
||||||
|
|
|
@ -31,6 +31,7 @@ class Ability
|
||||||
cannot :approve, RegisterRequest, :approved => true
|
cannot :approve, RegisterRequest, :approved => true
|
||||||
cannot :reject, RegisterRequest, :rejected => true
|
cannot :reject, RegisterRequest, :rejected => true
|
||||||
cannot [:owned, :related], BuildList
|
cannot [:owned, :related], BuildList
|
||||||
|
cannot [:owned, :related], Platform
|
||||||
end
|
end
|
||||||
|
|
||||||
if user.user?
|
if user.user?
|
||||||
|
@ -70,14 +71,12 @@ class Ability
|
||||||
can(:publish, BuildList) {|build_list| build_list.can_publish? && can?(:write, build_list.project)}
|
can(:publish, BuildList) {|build_list| build_list.can_publish? && can?(:write, build_list.project)}
|
||||||
can(:cancel, BuildList) {|build_list| build_list.can_cancel? && can?(:write, build_list.project)}
|
can(:cancel, BuildList) {|build_list| build_list.can_cancel? && can?(:write, build_list.project)}
|
||||||
|
|
||||||
can :read, Platform, :visibility => 'open'
|
can [:read, :members], Platform, :visibility => 'open'
|
||||||
can :read, Platform, :owner_type => 'User', :owner_id => user.id
|
can [:read, :owned, :related, :members], Platform, :owner_type => 'User', :owner_id => user.id
|
||||||
can :read, Platform, :owner_type => 'Group', :owner_id => user.group_ids
|
can [:read, :related, :members], Platform, :owner_type => 'Group', :owner_id => user.group_ids
|
||||||
can(:read, Platform, read_relations_for('platforms')) {|platform| local_reader? platform}
|
can([:read, :related, :members], Platform, read_relations_for('platforms')) {|platform| local_reader? platform}
|
||||||
# can([:update, :build_all], Platform) {|platform| local_admin? platform}
|
can([:update, :members], Platform) {|platform| local_admin? platform}
|
||||||
can([:update], Platform) {|platform| local_admin? platform}
|
can([:destroy, :members, :add_member, :remove_member, :remove_members] , Platform) {|platform| owner? platform}
|
||||||
#can([:freeze, :unfreeze, :destroy], Platform) {|platform| owner? platform}
|
|
||||||
can(:destroy, Platform) {|platform| owner? platform}
|
|
||||||
can :autocomplete_user_uname, Platform
|
can :autocomplete_user_uname, Platform
|
||||||
|
|
||||||
can [:read, :projects_list], Repository, :platform => {:visibility => 'open'}
|
can [:read, :projects_list], Repository, :platform => {:visibility => 'open'}
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
- @users.each do |user|
|
- @users.each do |user|
|
||||||
%tr#admin-table-members-row1
|
%tr#admin-table-members-row1
|
||||||
%td
|
%td
|
||||||
%span#niceCheckbox1.niceCheck-main{:onclick => "changeCheck(this)", :style => "background-position: 0px 0px; "}
|
%span#niceCheckbox1.niceCheck-main{ :style => "background-position: 0px 0px; "}
|
||||||
= check_box_tag "user_remove[#{user.id}][]"
|
= check_box_tag "user_remove[#{user.id}][]"
|
||||||
%td
|
%td
|
||||||
.img
|
.img
|
||||||
|
|
|
@ -12,9 +12,9 @@
|
||||||
.rightlist= f.select :distrib_type, options_for_select(APP_CONFIG['distr_types'])
|
.rightlist= f.select :distrib_type, options_for_select(APP_CONFIG['distr_types'])
|
||||||
.both
|
.both
|
||||||
|
|
||||||
.leftlist= f.label :parent, :class => :label
|
-#.leftlist= f.label :parent, :class => :label
|
||||||
.rightlist= f.collection_select :parent_platform_id, Platform.all, :id, :description, :include_blank => true
|
.rightlist= f.collection_select :parent_platform_id, Platform.all, :id, :description, :include_blank => true
|
||||||
.both
|
.both
|
||||||
|
|
||||||
- unless @platform.platform_type.in? ['personal']
|
- unless @platform.platform_type.in? ['personal']
|
||||||
.leftlist= f.label :released, :class => :label
|
.leftlist= f.label :released, :class => :label
|
||||||
|
|
|
@ -4,17 +4,24 @@
|
||||||
- content_for :sidebar do
|
- content_for :sidebar do
|
||||||
%aside
|
%aside
|
||||||
.admin-preferences
|
.admin-preferences
|
||||||
%ul
|
%nav
|
||||||
%li{:class => (act == :show && contr == :platforms) ? 'active' : ''}
|
%ul
|
||||||
= link_to t("layout.platforms.about"), platform_path(@platform)
|
%li{:class => (act == :show && contr == :platforms) ? 'active' : ''}
|
||||||
%li{:class => (contr == :repositories) ? 'active' : ''}
|
= link_to t("layout.platforms.about"), platform_path(@platform)
|
||||||
= link_to t("layout.repositories.list_header"), platform_repositories_path(@platform)
|
%li{:class => (contr == :repositories) ? 'active' : ''}
|
||||||
- if can? :read, @platform.products.build
|
= link_to t("layout.repositories.list_header"), platform_repositories_path(@platform)
|
||||||
%li{:class => (contr == :products) ? 'active' : ''}
|
- if can? :read, @platform.products.build
|
||||||
= link_to t("layout.products.list_header"), platform_products_path(@platform)
|
%li{:class => (contr == :products) ? 'active' : ''}
|
||||||
-#- if current_user.owner_of? @platform or current_user.admin?
|
= link_to t("layout.products.list_header"), platform_products_path(@platform)
|
||||||
%li{:class => (act == :index && contr == :private_users) ? 'active' : ''}
|
- if can? :update, @platform
|
||||||
= link_to t("layout.platforms.private_users"), platform_private_users_path(@platform)
|
%li{:class => (act == :edit && contr == :platforms) ? 'active' : nil}
|
||||||
|
= link_to t("platform_menu.settings"), edit_platform_path(@platform)
|
||||||
|
- if can? :members, @platform
|
||||||
|
%li{:class => (act == :members && contr == :platforms) ? 'active' : nil}
|
||||||
|
= link_to t("layout.platforms.members"), members_platform_path(@platform)
|
||||||
|
-#- if current_user.owner_of? @platform or current_user.admin?
|
||||||
|
%li{:class => (act == :index && contr == :private_users) ? 'active' : ''}
|
||||||
|
= link_to t("layout.platforms.private_users"), platform_private_users_path(@platform)
|
||||||
-#.block.notice
|
-#.block.notice
|
||||||
%h3= t("layout.groups.members")
|
%h3= t("layout.groups.members")
|
||||||
.content
|
.content
|
||||||
|
|
|
@ -3,5 +3,3 @@
|
||||||
.left= @platform.name
|
.left= @platform.name
|
||||||
%nav
|
%nav
|
||||||
%ul
|
%ul
|
||||||
- if can? :update, @platform
|
|
||||||
%li= link_to t("platform_menu.settings"), edit_platform_path(@platform), :class => (act == :edit && contr == :platforms) ? 'active' : nil
|
|
||||||
|
|
|
@ -4,13 +4,13 @@
|
||||||
= form_for @platform, :url => platform_path(@platform), :html => { :class => :form } do |f|
|
= form_for @platform, :url => platform_path(@platform), :html => { :class => :form } do |f|
|
||||||
= render :partial => "form", :locals => {:f => f}
|
= render :partial => "form", :locals => {:f => f}
|
||||||
|
|
||||||
.hr
|
- if can? :destroy, @platform
|
||||||
.leftside
|
.hr
|
||||||
= t("layout.platforms.delete_warning")
|
.leftside
|
||||||
.rightside
|
= t("layout.platforms.delete_warning")
|
||||||
- if can? :destroy, @platform
|
.rightside
|
||||||
= link_to t("layout.delete"), platform_path(@platform), :method => :delete, :confirm => t("layout.platforms.confirm_delete"), :class => 'button'
|
= link_to t("layout.delete"), platform_path(@platform), :method => :delete, :confirm => t("layout.platforms.confirm_delete"), :class => 'button'
|
||||||
.both
|
.both
|
||||||
|
|
||||||
-#.block
|
-#.block
|
||||||
.secondary-navigation
|
.secondary-navigation
|
||||||
|
|
|
@ -0,0 +1,42 @@
|
||||||
|
= render :partial => 'submenu'
|
||||||
|
= render :partial => 'sidebar'
|
||||||
|
|
||||||
|
= form_tag remove_members_platform_path(@platform), :id => 'members_form', :method => :post do
|
||||||
|
%table.tablesorter{:cellpadding => "0", :cellspacing => "0"}
|
||||||
|
%thead
|
||||||
|
%tr
|
||||||
|
- if can? :remove_members, @platform
|
||||||
|
%th
|
||||||
|
\
|
||||||
|
%th
|
||||||
|
= t("layout.collaborators.members")
|
||||||
|
- if can? :remove_member, @platform
|
||||||
|
%th.buttons
|
||||||
|
= t("layout.remove")
|
||||||
|
%tbody
|
||||||
|
- @members.select{|u| u != @platform.owner}.each_with_index do |user, num|
|
||||||
|
%tr{:id => "admin-table-members-row#{num}", :class => cycle(:odd, :even)}
|
||||||
|
- if can? :remove_members, @platform
|
||||||
|
%td
|
||||||
|
%span.niceCheck-main{:id => "niceCheckbox#{num}", :style => "background-position: 0px 0px; "}
|
||||||
|
= check_box_tag "user_remove[#{user.id}][]"
|
||||||
|
%td
|
||||||
|
.img
|
||||||
|
= image_tag avatar_url(user)
|
||||||
|
.forimg= link_to "#{user.uname} (#{user.name})", user_path(user)
|
||||||
|
- if can? :remove_member, @platform
|
||||||
|
%td.buttons
|
||||||
|
= link_to remove_member_platform_path(@platform, :member_id => user.id), :method => :delete, :confirm => t("layout.confirm") do
|
||||||
|
%span.delete
|
||||||
|
- if can? :remove_memvers, @platforms
|
||||||
|
= submit_tag t("layout.delete"), :class => 'button'
|
||||||
|
.both
|
||||||
|
|
||||||
|
- if can? :add_member, @platform
|
||||||
|
.hr.top
|
||||||
|
= form_tag add_member_platform_path(@platform) do
|
||||||
|
.admin-search
|
||||||
|
= autocomplete_field_tag 'member_id', params[:member_id], autocomplete_user_uname_users_path, :id_element => '#member_id_field'
|
||||||
|
= hidden_field_tag 'member_id', nil, :id => 'member_id_field'
|
||||||
|
= submit_tag t("layout.add"), :class => 'button'
|
||||||
|
.both
|
|
@ -1,7 +1,7 @@
|
||||||
= render :partial => 'submenu'
|
= render :partial => 'submenu'
|
||||||
= render :partial => 'sidebar'
|
= render :partial => 'sidebar'
|
||||||
|
|
||||||
%h3.fix= t("layout.platforms.about")
|
%h3.fix= "#{t("layout.platforms.about")} #{@platform.name}"
|
||||||
|
|
||||||
%p= @platform.description
|
%p= @platform.description
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
<% @projects.each do |project| %>
|
<% @projects.each do |project| %>
|
||||||
[
|
[
|
||||||
"<%=j link_to("#{project.owner.respond_to?(:uname) ? project.owner.uname : project.owner.name} / #{project.name}", project) %>",
|
"<%=j link_to("#{project.owner.respond_to?(:uname) ? project.owner.uname : project.owner.name} / #{project.name}", project) %>",
|
||||||
"<%= truncate(project.description, :length => 60).gsub("\n", ' ') %>",
|
"<%= truncate(project.description || '', :length => 60).gsub("\n", ' ') %>",
|
||||||
"<%=j link_to t("layout.add"), url_for(:controller => :repositories, :action => :add_project, :project_id => project.id) %>"
|
"<%=j link_to t("layout.add"), url_for(:controller => :repositories, :action => :add_project, :project_id => project.id) %>"
|
||||||
]<%= project == @projects.last ? '' : ',' %>
|
]<%= project == @projects.last ? '' : ',' %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
j(link_to("#{project.owner.respond_to?(:uname) ? project.owner.uname : project.owner.name} / #{project.name}", project)) +
|
j(link_to("#{project.owner.respond_to?(:uname) ? project.owner.uname : project.owner.name} / #{project.name}", project)) +
|
||||||
"</div>").html_safe
|
"</div>").html_safe
|
||||||
%>",
|
%>",
|
||||||
"<%= truncate(project.description, :length => 60).gsub("\n", ' ') %>",
|
"<%= truncate(project.description || '', :length => 60).gsub("\n", ' ') %>",
|
||||||
"<%=
|
"<%=
|
||||||
if can? :remove_project, @repository
|
if can? :remove_project, @repository
|
||||||
j(link_to('<span class="delete"> </span>'.html_safe,
|
j(link_to('<span class="delete"> </span>'.html_safe,
|
||||||
|
|
|
@ -12,6 +12,8 @@ en:
|
||||||
|
|
||||||
by: by
|
by: by
|
||||||
|
|
||||||
|
remove: Remove
|
||||||
|
|
||||||
visibilities:
|
visibilities:
|
||||||
open: open
|
open: open
|
||||||
hidden: hidden
|
hidden: hidden
|
||||||
|
|
|
@ -12,6 +12,8 @@ ru:
|
||||||
|
|
||||||
by: ''
|
by: ''
|
||||||
|
|
||||||
|
remove: Убрать
|
||||||
|
|
||||||
visibilities:
|
visibilities:
|
||||||
open: открытая
|
open: открытая
|
||||||
hidden: скрытая
|
hidden: скрытая
|
||||||
|
|
|
@ -37,6 +37,10 @@ en:
|
||||||
clone: To clone
|
clone: To clone
|
||||||
delete_warning: Attention! Deleted platform can not be restored!
|
delete_warning: Attention! Deleted platform can not be restored!
|
||||||
sys_repos_header: Connecting info
|
sys_repos_header: Connecting info
|
||||||
|
target_platform: Target platform
|
||||||
|
target_architecture: Target architecture
|
||||||
|
members: Members
|
||||||
|
|
||||||
|
|
||||||
flash:
|
flash:
|
||||||
platform:
|
platform:
|
||||||
|
@ -51,6 +55,10 @@ en:
|
||||||
destroyed: Platform deleted
|
destroyed: Platform deleted
|
||||||
build_all_success: All project build in progress
|
build_all_success: All project build in progress
|
||||||
clone_success: Cloned successfully
|
clone_success: Cloned successfully
|
||||||
|
members:
|
||||||
|
already_added: "%{name} is already added to platform"
|
||||||
|
successfully_added: "%{name} successfully added as member"
|
||||||
|
error_in_adding: "Fail to add %{name} as member"
|
||||||
|
|
||||||
activerecord:
|
activerecord:
|
||||||
models:
|
models:
|
||||||
|
|
|
@ -35,10 +35,11 @@ ru:
|
||||||
private_users: Данные для доступа
|
private_users: Данные для доступа
|
||||||
confirm_clone: Клонировать?
|
confirm_clone: Клонировать?
|
||||||
clone: Клонировать
|
clone: Клонировать
|
||||||
delete_warning: Внимание! Удаленная платформа удалению не подлежит.
|
delete_warning: Внимание! Удаленная платформа восстановлению не подлежит.
|
||||||
sys_repos_header: Данные для подключения
|
sys_repos_header: Данные для подключения
|
||||||
target_platform: Целевая платформа
|
target_platform: Целевая платформа
|
||||||
target_architecture: Целевая архитектура
|
target_architecture: Целевая архитектура
|
||||||
|
members: Участники
|
||||||
|
|
||||||
flash:
|
flash:
|
||||||
platform:
|
platform:
|
||||||
|
@ -53,6 +54,10 @@ ru:
|
||||||
destroyed: Платформа успешно удалена
|
destroyed: Платформа успешно удалена
|
||||||
build_all_success: Все проекты успешно отправлены на сборку
|
build_all_success: Все проекты успешно отправлены на сборку
|
||||||
clone_success: Клонирование успешно
|
clone_success: Клонирование успешно
|
||||||
|
members:
|
||||||
|
already_added: "%{name} уже является участником платформы"
|
||||||
|
successfully_added: "Участник #{name} успешно добавлен к платформе"
|
||||||
|
error_in_adding: "Не удалось добавить участника %{name}"
|
||||||
|
|
||||||
activerecord:
|
activerecord:
|
||||||
models:
|
models:
|
||||||
|
|
|
@ -74,13 +74,17 @@ Rosa::Application.routes.draw do
|
||||||
resources :private_users, :except => [:show, :destroy, :update]
|
resources :private_users, :except => [:show, :destroy, :update]
|
||||||
|
|
||||||
member do
|
member do
|
||||||
get 'clone'
|
get :clone
|
||||||
post 'make_clone'
|
get :members
|
||||||
post 'build_all'
|
post :remove_members
|
||||||
|
delete :remove_member
|
||||||
|
post :add_member
|
||||||
|
post :make_clone
|
||||||
|
post :build_all
|
||||||
end
|
end
|
||||||
|
|
||||||
collection do
|
collection do
|
||||||
get 'easy_urpmi'
|
get :easy_urpmi
|
||||||
get :autocomplete_user_uname
|
get :autocomplete_user_uname
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue