diff --git a/app/controllers/projects/projects_controller.rb b/app/controllers/projects/projects_controller.rb index 4c76cbbb4..23ff01ec9 100644 --- a/app/controllers/projects/projects_controller.rb +++ b/app/controllers/projects/projects_controller.rb @@ -72,7 +72,7 @@ class Projects::ProjectsController < Projects::BaseController redirect_to forked, :notice => t("flash.project.forked") else flash[:warning] = t("flash.project.fork_error") - flash[:error] = forked.errors.full_messages + flash[:error] = forked.errors.full_messages.join("\n") redirect_to @project end end diff --git a/app/models/project.rb b/app/models/project.rb index 6d5d5e8f2..ef9445f66 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -33,6 +33,13 @@ class Project < ActiveRecord::Base 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 :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_readonly :name, :owner_id, :owner_type diff --git a/app/models/project_to_repository.rb b/app/models/project_to_repository.rb index 16035ce3e..a1f9c5327 100644 --- a/app/models/project_to_repository.rb +++ b/app/models/project_to_repository.rb @@ -7,12 +7,12 @@ class ProjectToRepository < ActiveRecord::Base 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 def one_project_in_platform_repositories - errors.add(:project, 'should be one in platform') if Project.joins(:repositories => :platform). - where('platforms.id = ?', repository.platform_id).by_name(project.name).count > 0 + 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).exists? end end diff --git a/app/views/projects/git/base/_fork.html.haml b/app/views/projects/git/base/_fork.html.haml index be9cf54d4..98d55a301 100644 --- a/app/views/projects/git/base/_fork.html.haml +++ b/app/views/projects/git/base/_fork.html.haml @@ -14,5 +14,5 @@ - Group.can_own_project(current_user).each do |group| =render 'choose_fork', :owner => group %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' diff --git a/config/locales/models/project_to_repository.en.yml b/config/locales/models/project_to_repository.en.yml new file mode 100644 index 000000000..553d2e8f3 --- /dev/null +++ b/config/locales/models/project_to_repository.en.yml @@ -0,0 +1,5 @@ +en: + activerecord: + errors: + project_to_repository: + project: Project already exists in platform \ No newline at end of file diff --git a/config/locales/models/project_to_repository.ru.yml b/config/locales/models/project_to_repository.ru.yml new file mode 100644 index 000000000..503a54f54 --- /dev/null +++ b/config/locales/models/project_to_repository.ru.yml @@ -0,0 +1,5 @@ +ru: + activerecord: + errors: + project_to_repository: + project: Проект уже присутствует в платформе diff --git a/config/locales/models/repository.en.yml b/config/locales/models/repository.en.yml index 11dcae4db..3330fd0e9 100644 --- a/config/locales/models/repository.en.yml +++ b/config/locales/models/repository.en.yml @@ -36,7 +36,7 @@ en: 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 + 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_not_removed: Unable to delete project from repository clear: Platform successfully cleared! diff --git a/config/locales/models/repository.ru.yml b/config/locales/models/repository.ru.yml index f5e5a58fa..257926dbc 100644 --- a/config/locales/models/repository.ru.yml +++ b/config/locales/models/repository.ru.yml @@ -36,7 +36,7 @@ ru: update_error: Не удалось обновить репозиторий destroyed: Репозиторий успешно удален project_added: Проект добавлен к репозиторию - project_not_added: Не удалось добавить проект. В этом репозитории уже есть проект с таким именем. Сначала нужно удалить старый проект + project_not_added: Не удалось добавить проект. В одном из репозиториев платформы уже есть проект с таким именем. Сначала нужно удалить старый проект project_removed: Проект удален из репозитория project_not_removed: Не удалось удалить проект из репозитория clear: Платформа успешно очищена!