[issue #279] Fixed some bugs:

*  Redirect to repositroies page when remove repository.
  *  Fixed sorting background in Datatables styles.
  *  Fixed save button translation in platforms form.
  *  Fixed platform save & create flashes.
  *  Fixed cancel buttons in platform, product & repository forms.
  *  Redirect to created product on creation.
  *  Redirect to platform's products page after product destruction.
  *  Fixed permissions to Build button on product page.
  *  Fixed permissions to Add button on repository page.
  *  Fixed forbidden redirect when trying to acces
     RepositoriesController#projects_list by unprivilleged user.
This commit is contained in:
George Vinogradov 2012-03-16 02:56:12 +04:00
parent 9911d9f25e
commit cc68163238
14 changed files with 53 additions and 34 deletions

View File

@ -568,3 +568,12 @@ div#crontab_generator .leftlist select,
div#crontab_generator .rightlist select {
margin-top: 10px;
}
table.dataTable tr.odd td.sorting_1 {
background-color: #F0F0F6;
}
table.dataTable tr.even td.sorting_1 {
background-color: #FFFFFF;
}

View File

@ -57,10 +57,10 @@ class PlatformsController < ApplicationController
@platform.owner = @admin_id.blank? ? get_owner : User.find(@admin_id)
if @platform.save
flash[:notice] = I18n.t("flash.platform.saved")
flash[:notice] = I18n.t("flash.platform.created")
redirect_to @platform
else
flash[:error] = I18n.t("flash.platform.save_error")
flash[:error] = I18n.t("flash.platform.create_error")
render :action => :new
end
end
@ -125,7 +125,7 @@ class PlatformsController < ApplicationController
@platform.delay.destroy if @platform
flash[:notice] = t("flash.platform.destroyed")
redirect_to root_path
redirect_to platforms_path
end
def forbidden

View File

@ -35,7 +35,7 @@ class ProductsController < ApplicationController
@product = @platform.products.new params[:product]
if @product.save
flash[:notice] = t('flash.product.saved')
redirect_to @platform
redirect_to platform_product_path(@platform, @product)
else
flash[:error] = t('flash.product.save_error')
render :action => :new
@ -58,7 +58,7 @@ class ProductsController < ApplicationController
def destroy
@product.destroy
flash[:notice] = t("flash.product.destroyed")
redirect_to @platform
redirect_to platform_products_path(@platform)
end
protected

View File

@ -36,7 +36,7 @@ class RepositoriesController < ApplicationController
platform_id = @repository.platform_id
flash[:notice] = t("flash.repository.destroyed")
redirect_to platform_path(platform_id)
redirect_to platform_repositories_path(platform_id)
end
def create

View File

@ -79,10 +79,10 @@ class Ability
can(:destroy, Platform) {|platform| owner? platform}
can :autocomplete_user_uname, Platform
can :read, Repository, :platform => {:visibility => 'open'}
can :read, Repository, :platform => {:owner_type => 'User', :owner_id => user.id}
can :read, Repository, :platform => {:owner_type => 'Group', :owner_id => user.group_ids}
can(:read, Repository, read_relations_for('repositories', 'platforms')) {|repository| local_reader? repository.platform}
can [:read, :projects_list], Repository, :platform => {:visibility => 'open'}
can [:read, :projects_list], Repository, :platform => {:owner_type => 'User', :owner_id => user.id}
can [:read, :projects_list], Repository, :platform => {:owner_type => 'Group', :owner_id => user.group_ids}
can([:read, :projects_list], Repository, read_relations_for('repositories', 'platforms')) {|repository| local_reader? repository.platform}
can([:create, :update, :projects_list, :add_project, :remove_project], Repository) {|repository| local_admin? repository.platform}
can([:change_visibility, :settings, :destroy], Repository) {|repository| owner? repository.platform}

View File

@ -1,19 +1,24 @@
- unless ['edit', 'update'].include? controller.action_name
.leftlist= f.label :name, :class => :label
.rightlist= f.text_field :name, :class => 'text_field'
.both
.leftlist= f.label :description, :class => :label
.rightlist= f.text_field :description, :class => 'text_field'
.rightlist= f.text_area :description, :class => 'text_field'
.both
- unless ['edit', 'update'].include? controller.action_name
.leftlist= f.label :distrib_type, :class => :label
.rightlist= f.select :distrib_type, options_for_select(APP_CONFIG['distr_types'])
.both
.leftlist= f.label :parent, :class => :label
.rightlist= f.collection_select :parent_platform_id, Platform.all, :id, :description, :include_blank => true
.both
.leftlist= f.label :released, :class => :label
.rightlist= f.check_box :released, :class => 'check_box'
.both
.leftlist= label_tag "", t("layout.platforms.admin_id"), :class => :label
.rightlist= autocomplete_field_tag 'admin_id', @admin_uname, autocomplete_user_uname_platforms_path, :id_element => '#admin_id_field'
@ -21,9 +26,9 @@
.both
.button_block
= submit_tag t("layout.clone")
= submit_tag t("layout.save")
-#%input.button{:type => "submit", :class => "button"}
-#= image_tag("choose.png", :alt => t("layout.save"))
-#= t("layout.clone")
%span.text_button_padding= t("layout.or")
= link_to t("layout.cancel"), @platforms_path, :class => "button"
= link_to t("layout.cancel"), @platform.new_record? ? root_path : platform_path(@platform), :class => "button"

View File

@ -1,4 +1,9 @@
.block
%h3= t("layout.platforms.new_header")
= form_for :platform, :url => platforms_path, :html => { :class => :form } do |f|
= render :partial => "form", :locals => {:f => f}
-#.block
.secondary-navigation
%ul.wat-cf
%li.first= link_to "#{t("layout.platforms.list")}", @platforms_path

View File

@ -48,5 +48,5 @@
-#= image_tag("choose.png", :alt => t("layout.save"))
-#= t("layout.clone")
%span.text_button_padding= t("layout.or")
= link_to t("layout.cancel"), platform_path(@platform), :class => "button"
= link_to t("layout.cancel"), @product.new_record? ? platform_path(@platform) : platform_product_path(@platform, @product), :class => "button"

View File

@ -12,7 +12,7 @@
= link_to image_tag("x.png", :alt => t("layout.delete")) + " " + t("layout.delete"), platform_product_path(@platform, @product), :method => "delete", :class => "button", :confirm => t("layout.products.confirm_delete")
-# if @product.can_clone?
=# link_to t("layout.products.clone"), clone_platform_product_path(@platform, @product), :class => "button"
- if can?(:create, @product => ProductBuildList)
- if can?(:create, @product.product_build_lists.build)
= link_to t("layout.products.build"), platform_product_product_build_lists_path(@platform, @product), :class => "button", :method => 'post', :confirm => t("layout.confirm")
%h3= t("layout.products.build_lists_monitoring")

View File

@ -12,4 +12,4 @@
-#= image_tag("choose.png", :alt => t("layout.save"))
-#= t("layout.clone")
%span.text_button_padding= t("layout.or")
= link_to t("layout.cancel"), @repositories_path, :class => "button"
= link_to t("layout.cancel"), @repository.new_record? ? platform_repositories_path(@platform) : platform_repository_path(@platform, @repository), :class => "button"

View File

@ -15,22 +15,17 @@
%>",
"<%=j project.description %>",
"<%=
j(link_to('<span class="delete">&nbsp;</span>'.html_safe, remove_project_repository_path(@repository, :project_id => project.id), :method => :delete, :confirm => t("layout.confirm")))
#j link_to t("layout.add"), url_for(:controller => :repositories, :action => :add_project, :project_id => project.id)
if can? :remove_project, @repository
j(link_to('<span class="delete">&nbsp;</span>'.html_safe,
remove_project_repository_path(@repository, :project_id => project.id),
:method => :delete, :confirm => t("layout.confirm")
)
)
else
''
end
%>"
]<%= project == @projects.last ? '' : ',' %>
<% end %>
]
<%
# %tr{:id => "Row#{project_counter}", :class => cycle('odd', 'even')}
# %td
# = link_to project do
# .table-sort-left= image_tag visibility_icon(project.visibility)
# .table-sort-right #{project.owner.uname} / #{project.name}
# %td.td2
# %span= project.description
# %td.buttons
# = link_to remove_project_repository_path(@repository, :project_id => project.id), :method => :delete, :confirm => t("layout.confirm") do
# %span.delete &nbsp;
%>
}

View File

@ -8,6 +8,7 @@
%br
%br
%h3.fix= t("layout.projects.list_header")
- if can? :add_project, @repository
= link_to t("layout.projects.add"), add_project_repository_path(@repository), :class => 'button'
= render :partial => 'proj_list'#, :object => @projects

View File

@ -39,7 +39,9 @@ en:
flash:
platform:
saved: Platform saved
created: Platform created
save_error: Platform saves error
create_error: Platform create error
freezed: Platform freezed
freeze_error: Platform freezing error, try again
unfreezed: Platform unfreezed

View File

@ -38,8 +38,10 @@ ru:
flash:
platform:
saved: Платформа успешно добавлена
save_error: Не удалось создать платформу
saved: Платформа успешно сохранена
created: Платформа успешно добавлена
save_error: Не удалось сохранить платформу
create_error: Не удалось создать платформу
freezed: Платформа успешно заморожена
freeze_error: Не удалось заморозить платформу, попробуйте еще раз
unfreezed: Платформа успешно разморожена