#82: update for adding new packages into repository
This commit is contained in:
parent
2b45e14545
commit
958017b3ed
|
@ -72,7 +72,7 @@ class Projects::ProjectsController < Projects::BaseController
|
||||||
redirect_to forked, :notice => t("flash.project.forked")
|
redirect_to forked, :notice => t("flash.project.forked")
|
||||||
else
|
else
|
||||||
flash[:warning] = t("flash.project.fork_error")
|
flash[:warning] = t("flash.project.fork_error")
|
||||||
flash[:error] = forked.errors.full_messages
|
flash[:error] = forked.errors.full_messages.join("\n")
|
||||||
redirect_to @project
|
redirect_to @project
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -33,6 +33,13 @@ class Project < ActiveRecord::Base
|
||||||
validates :visibility, :presence => true, :inclusion => {:in => VISIBILITIES}
|
validates :visibility, :presence => true, :inclusion => {:in => VISIBILITIES}
|
||||||
validate { errors.add(:base, :can_have_less_or_equal, :count => MAX_OWN_PROJECTS) if owner.projects.size >= MAX_OWN_PROJECTS }
|
validate { errors.add(:base, :can_have_less_or_equal, :count => MAX_OWN_PROJECTS) if owner.projects.size >= MAX_OWN_PROJECTS }
|
||||||
validate :check_default_branch
|
validate :check_default_branch
|
||||||
|
validate do |project|
|
||||||
|
project.project_to_repositories.each do |p_to_r|
|
||||||
|
next if p_to_r.valid?
|
||||||
|
p_to_r.errors.full_messages.each{ |msg| errors[:base] << msg }
|
||||||
|
end
|
||||||
|
errors.delete :project_to_repositories
|
||||||
|
end
|
||||||
|
|
||||||
attr_accessible :name, :description, :visibility, :srpm, :is_package, :default_branch, :has_issues, :has_wiki, :maintainer_id, :publish_i686_into_x86_64
|
attr_accessible :name, :description, :visibility, :srpm, :is_package, :default_branch, :has_issues, :has_wiki, :maintainer_id, :publish_i686_into_x86_64
|
||||||
attr_readonly :name, :owner_id, :owner_type
|
attr_readonly :name, :owner_id, :owner_type
|
||||||
|
|
|
@ -7,12 +7,12 @@ class ProjectToRepository < ActiveRecord::Base
|
||||||
|
|
||||||
after_destroy lambda { project.destroy_project_from_repository(repository) }, :unless => lambda {Thread.current[:skip]}
|
after_destroy lambda { project.destroy_project_from_repository(repository) }, :unless => lambda {Thread.current[:skip]}
|
||||||
|
|
||||||
validate :one_project_in_platform_repositories
|
validate :one_project_in_platform_repositories, :on => :create
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
|
||||||
def one_project_in_platform_repositories
|
def one_project_in_platform_repositories
|
||||||
errors.add(:project, 'should be one in platform') if Project.joins(:repositories => :platform).
|
errors.add(:base, I18n.t('activerecord.errors.project_to_repository.project')) if Project.joins(:repositories => :platform).
|
||||||
where('platforms.id = ?', repository.platform_id).by_name(project.name).count > 0
|
where('platforms.id = ?', repository.platform_id).by_name(project.name).exists?
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -14,5 +14,5 @@
|
||||||
- Group.can_own_project(current_user).each do |group|
|
- Group.can_own_project(current_user).each do |group|
|
||||||
=render 'choose_fork', :owner => group
|
=render 'choose_fork', :owner => group
|
||||||
%hr.bootstrap
|
%hr.bootstrap
|
||||||
- if can? :create, @project.build_lists.new
|
- if @project.is_package && can?(:create, @project.build_lists.new)
|
||||||
.r{:style => "display: block"}= link_to t('layout.projects.new_build_list'), new_project_build_list_path(@project), :class => 'button'
|
.r{:style => "display: block"}= link_to t('layout.projects.new_build_list'), new_project_build_list_path(@project), :class => 'button'
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
en:
|
||||||
|
activerecord:
|
||||||
|
errors:
|
||||||
|
project_to_repository:
|
||||||
|
project: Project already exists in platform
|
|
@ -0,0 +1,5 @@
|
||||||
|
ru:
|
||||||
|
activerecord:
|
||||||
|
errors:
|
||||||
|
project_to_repository:
|
||||||
|
project: Проект уже присутствует в платформе
|
|
@ -36,7 +36,7 @@ en:
|
||||||
update_error: Unable to update repository
|
update_error: Unable to update repository
|
||||||
destroyed: Repository deleted
|
destroyed: Repository deleted
|
||||||
project_added: Project added to repository
|
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
|
project_not_added: Project adding error. A project with such name already exists in one repository of platform. Remove the old project first
|
||||||
project_removed: Project deleted
|
project_removed: Project deleted
|
||||||
project_not_removed: Unable to delete project from repository
|
project_not_removed: Unable to delete project from repository
|
||||||
clear: Platform successfully cleared!
|
clear: Platform successfully cleared!
|
||||||
|
|
|
@ -36,7 +36,7 @@ ru:
|
||||||
update_error: Не удалось обновить репозиторий
|
update_error: Не удалось обновить репозиторий
|
||||||
destroyed: Репозиторий успешно удален
|
destroyed: Репозиторий успешно удален
|
||||||
project_added: Проект добавлен к репозиторию
|
project_added: Проект добавлен к репозиторию
|
||||||
project_not_added: Не удалось добавить проект. В этом репозитории уже есть проект с таким именем. Сначала нужно удалить старый проект
|
project_not_added: Не удалось добавить проект. В одном из репозиториев платформы уже есть проект с таким именем. Сначала нужно удалить старый проект
|
||||||
project_removed: Проект удален из репозитория
|
project_removed: Проект удален из репозитория
|
||||||
project_not_removed: Не удалось удалить проект из репозитория
|
project_not_removed: Не удалось удалить проект из репозитория
|
||||||
clear: Платформа успешно очищена!
|
clear: Платформа успешно очищена!
|
||||||
|
|
Loading…
Reference in New Issue