#631: added #edit #update actions to platforms/repositories_controller, wrote migration, updated models

This commit is contained in:
Vokhmin Alexey V 2012-09-06 17:43:50 +04:00
parent ec32cf7fa0
commit f0f11cb9dc
11 changed files with 54 additions and 8 deletions

1
.gitignore vendored
View File

@ -1,3 +1,4 @@
*~
.bundle
.rvmrc
.DS_Store

View File

@ -14,6 +14,23 @@ class Platforms::RepositoriesController < Platforms::BaseController
@projects = @projects.search(params[:query]).search_order if params[:query].present?
end
def edit
end
def update
if @repository.update_attributes(
:description => params[:repository][:description],
:publish_wtihout_qa => (params[:repository][:publish_wtihout_qa] || @repository.publish_wtihout_qa)
)
flash[:notice] = I18n.t("flash.repository.updated")
redirect_to platform_repository_path(@platform, @repository)
else
flash[:error] = I18n.t("flash.repository.update_error")
flash[:warning] = @repository.errors.full_messages.join('. ')
render :action => :edit
end
end
def new
@repository = Repository.new
@platform_id = params[:platform_id]

View File

@ -49,7 +49,7 @@ class Projects::BuildListsController < Projects::BaseController
@repository = @project.repositories.where(:id => @platform.repository_ids).first
params[:build_list][:save_to_repository_id] = @repository.id
params[:build_list][:auto_publish] = false if @platform.released
params[:build_list][:auto_publish] = false if @platform.released && !@repository.publish_wtihout_qa
Arch.where(:id => params[:arches]).each do |arch|
Platform.main.where(:id => params[:build_for_platforms]).each do |build_for_platform|

View File

@ -93,9 +93,9 @@ class Ability
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([:create, :edit, :update, :projects_list, :add_project, :remove_project], Repository) {|repository| local_admin? repository.platform}
can(:clear, Platform) {|platform| local_admin?(platform) && platform.personal?}
can([:change_visibility, :settings, :destroy], Repository) {|repository| owner? repository.platform}
can([:change_visibility, :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)}
@ -125,7 +125,7 @@ class Ability
# Shared cannot rights for all users (registered, admin)
cannot :destroy, Platform, :platform_type => 'personal'
cannot [:create, :destroy, :add_project, :remove_project], Repository, :platform => {:platform_type => 'personal'}
cannot [:create, :destroy, :edit, :update, :add_project, :remove_project], Repository, :platform => {:platform_type => 'personal'}
cannot :clear, Platform, :platform_type => 'main'
cannot :destroy, Issue

View File

@ -14,7 +14,7 @@ class Repository < ActiveRecord::Base
before_create :xml_rpc_create, :unless => lambda {Thread.current[:skip]}
before_destroy :xml_rpc_destroy, :unless => lambda {Thread.current[:skip]}
attr_accessible :name, :description
attr_accessible :name, :description, :publish_wtihout_qa
attr_readonly :name, :platform_id
def base_clone(attrs = {})

View File

@ -1,9 +1,13 @@
.leftlist= f.label :name, t("activerecord.attributes.repository.name"), :class => :label
.rightlist= f.text_field :name, :class => 'text_field'
- unless ['edit', 'update'].include? controller.action_name
.leftlist= f.label :name, t("activerecord.attributes.repository.name"), :class => :label
.rightlist= f.text_field :name, :class => 'text_field'
.leftlist= f.label :description, t("activerecord.attributes.repository.description"), :class => :label
.rightlist= f.text_field :description, :class => 'text_field'
.leftlist= f.label :publish_wtihout_qa, t("activerecord.attributes.repository.publish_wtihout_qa"), :class => :label
.rightlist= f.check_box :publish_wtihout_qa, :class => 'check_box'
.both
.button_block

View File

@ -0,0 +1,8 @@
-set_meta_tags :title => title_object(@repository)
= render 'submenu'
= render 'sidebar'
%h3.fix= "#{t("layout.repositories.about")}: #{@repository.name}"
= form_for @repository, :url => platform_repository_path(@platform, @repository), :html => { :class => :form } do |f|
= render "form", :f => f

View File

@ -2,7 +2,12 @@
= render 'submenu'
= render 'sidebar'
%h3.fix= "#{t("layout.repositories.about")}: #{@repository.name}"
%h3.fix
= "#{t("layout.repositories.about")}: "
- if can? :edit, @repository
= link_to @repository.name, edit_platform_repository_path(@platform, @repository)
- else
= @repository.name
%p= @repository.description

View File

@ -29,7 +29,9 @@ en:
flash:
repository:
saved: Repository added
updated: Repository updated
save_error: Unable to add repository
update_error: Unable to update repository
destroyed: Repository deleted
project_added: Project added to repository
project_not_added: Project adding error. A project with such name already exists in this repository. Remove the old project first
@ -44,6 +46,7 @@ en:
repository:
name: Name
description: Description
publish_wtihout_qa: Publication after release
platform_id: Platform
platform: Platform
created_at: Created

View File

@ -29,7 +29,9 @@ ru:
flash:
repository:
saved: Репозиторий успешно добавлен
updated: Репозиторий успешно обновлен
save_error: Не удалось добавить репозиторий
update_error: Не удалось обновить репозиторий
destroyed: Репозиторий успешно удален
project_added: Проект добавлен к репозиторию
project_not_added: Не удалось добавить проект. В этом репозитории уже есть проект с таким именем. Сначала нужно удалить старый проект
@ -44,6 +46,7 @@ ru:
repository:
name: Название
description: Описание
publish_wtihout_qa: Публикация после релиза
platform_id: Платформа
platform: Платформа
created_at: Создан

View File

@ -0,0 +1,5 @@
class AddPublishWtihoutQaToRepositories < ActiveRecord::Migration
def change
add_column :repositories, :publish_wtihout_qa, :boolean, :default => false
end
end