Remove project responsible and type

pull/6482/head
Oliver Günther 6 years ago
parent ab5160643e
commit b08a5874f5
No known key found for this signature in database
GPG Key ID: A3A8BDAD7C0C552C
  1. 132
      app/controllers/project_types_controller.rb
  2. 9
      app/controllers/projects_controller.rb
  3. 4
      app/helpers/projects_helper.rb
  4. 8
      app/models/permitted_params.rb
  5. 6
      app/models/project.rb
  6. 49
      app/models/project_type.rb
  7. 2
      app/models/type/attributes.rb
  8. 3
      app/models/user.rb
  9. 62
      app/seeders/basic_data/project_type_seeder.rb
  10. 16
      app/seeders/basic_data/workflow_seeder.rb
  11. 1
      app/seeders/basic_data_seeder.rb
  12. 44
      app/views/project_types/_form.html.erb
  13. 44
      app/views/project_types/confirm_destroy.html.erb
  14. 40
      app/views/project_types/edit.html.erb
  15. 102
      app/views/project_types/index.html.erb
  16. 40
      app/views/project_types/new.html.erb
  17. 4
      app/views/projects/form/_project_attributes.html.erb
  18. 35
      app/views/projects/form/attributes/_project_type_id.html.erb
  19. 51
      app/views/projects/form/attributes/_responsible_id.html.erb
  20. 2
      config/configuration.yml.example
  21. 5
      config/initializers/menus.rb
  22. 28
      config/locales/en.yml
  23. 1
      config/locales/js-en.yml
  24. 10
      config/routes.rb
  25. 20
      db/migrate/20180801072018_remove_responsible_and_type_from_project.rb
  26. 6
      features/step_definitions/project_steps.rb
  27. 49
      features/step_definitions/project_type_steps.rb
  28. 4
      lib/api/v3/projects/project_representer.rb
  29. 2
      spec/controllers/copy_projects_controller_spec.rb
  30. 114
      spec/controllers/project_types_controller_spec.rb
  31. 34
      spec/factories/project_type_factory.rb
  32. 48
      spec/features/project_types/project_type_administration_spec.rb
  33. 62
      spec/features/projects/project_responsible_spec.rb
  34. 14
      spec/lib/api/v3/projects/project_representer_spec.rb
  35. 2
      spec/lib/api/v3/work_packages/schema/work_package_schema_representer_spec.rb
  36. 27
      spec/models/permitted_params_spec.rb
  37. 73
      spec/models/project_type_spec.rb
  38. 12
      spec/models/user_deletion_spec.rb
  39. 1
      spec_legacy/unit/project_spec.rb

@ -1,132 +0,0 @@
#-- encoding: UTF-8
#-- copyright
# OpenProject is a project management system.
# Copyright (C) 2012-2018 the OpenProject Foundation (OPF)
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License version 3.
#
# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
# Copyright (C) 2006-2017 Jean-Philippe Lang
# Copyright (C) 2010-2013 the ChiliProject Team
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# See docs/COPYRIGHT.rdoc for more details.
#++
class ProjectTypesController < ApplicationController
before_action :disable_api
before_action :check_permissions
accept_key_auth :index, :show
layout 'admin'
def index
@project_types = ProjectType.all
respond_to do |format|
format.html
end
end
def new
@project_type = ProjectType.new
respond_to do |format|
format.html
end
end
def create
@project_type = ProjectType.new(permitted_params.project_type)
if @project_type.save
flash[:notice] = l(:notice_successful_create)
redirect_to project_types_path
else
render action: 'new'
end
end
def show
@project_type = ProjectType.find(params[:id])
respond_to do |_format|
end
end
def edit
@project_type = ProjectType.find(params[:id])
respond_to do |format|
format.html
end
end
def update
@project_type = ProjectType.find(params[:id])
if @project_type.update_attributes(permitted_params.project_type)
flash[:notice] = l(:notice_successful_update)
redirect_to project_types_path
else
render action: :edit
end
end
def confirm_destroy
@project_type = ProjectType.find(params[:id])
respond_to do |format|
format.html
end
end
def destroy
@project_type = ProjectType.find(params[:id])
flash[:notice] = l(:notice_successful_delete) if @project_type.destroy
redirect_to project_types_path
end
def move
@project_type = ProjectType.find(params[:id])
if @project_type.update_attributes(permitted_params.project_type_move)
flash[:notice] = l(:notice_successful_update)
else
flash.now[:error] = l('timelines.project_type_could_not_be_saved')
render action: 'edit'
end
redirect_to project_types_path
end
protected
def default_breadcrumb
if action_name == 'index'
t('timelines.admin_menu.project_types')
else
ActionController::Base.helpers.link_to(t('timelines.admin_menu.project_types'), project_types_path)
end
end
def show_local_breadcrumb
true
end
def check_permissions
render_403 unless readonly_api_request or User.current.allowed_to_globally?(:edit_timelines)
end
def readonly_api_request
api_request? and %w[index show].include? params[:action]
end
end

@ -40,7 +40,6 @@ class ProjectsController < ApplicationController
before_action :require_admin, only: [:archive, :unarchive, :destroy, :destroy_info]
before_action :jump_to_project_menu_item, only: :show
before_action :load_project_settings, only: :settings
before_action :determine_base
accept_key_auth :index, :level_list, :show, :create, :update, :destroy
@ -303,14 +302,6 @@ class ProjectsController < ApplicationController
protected
def determine_base
@base = if params[:project_type_id]
ProjectType.find(params[:project_type_id]).projects
else
Project
end
end
def set_sorting(query)
orders = query.orders.select(&:valid?).map { |o| [o.attribute.to_s, o.direction.to_s] }

@ -120,10 +120,6 @@ module ProjectsHelper
l("label_version_sharing_#{sharing}")
end
def options_for_project_types
ProjectType.all.map { |t| [t.name, t.id] }
end
def filter_set?
params[:filters].present?
end

@ -130,18 +130,10 @@ class PermittedParams
params.require(:member).permit(*self.class.permitted_attributes[:member])
end
def project_type
params.require(:project_type).permit(*self.class.permitted_attributes[:project_type])
end
def projects_type_ids
params.require(:project).require(:type_ids).map(&:to_i).select { |x| x > 0 }
end
def project_type_move
params.require(:project_type).permit(*self.class.permitted_attributes[:move_to])
end
def query
# there is a weird bug in strong_parameters gem which makes the permit call
# on the sort_criteria pattern return the sort_criteria-hash contents AND

@ -179,12 +179,6 @@ class Project < ActiveRecord::Base
scope :visible, ->(user = User.current) { Project.visible_by(user) }
scope :newest, -> { order(created_on: :desc) }
# timelines stuff
belongs_to :project_type, class_name: '::ProjectType'
belongs_to :responsible, class_name: 'User'
def visible?(user = User.current)
self.active? and (self.is_public? or user.admin? or user.member_of?(self))
end

@ -1,49 +0,0 @@
#-- encoding: UTF-8
#-- copyright
# OpenProject is a project management system.
# Copyright (C) 2012-2018 the OpenProject Foundation (OPF)
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License version 3.
#
# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
# Copyright (C) 2006-2017 Jean-Philippe Lang
# Copyright (C) 2010-2013 the ChiliProject Team
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# See docs/COPYRIGHT.rdoc for more details.
#++
class ProjectType < ActiveRecord::Base
extend Pagination::Model
self.table_name = 'project_types'
acts_as_list
default_scope { order('position ASC') }
has_many :projects, class_name: 'Project',
foreign_key: 'project_type_id'
validates_presence_of :name
validates_length_of :name, maximum: 255, unless: lambda { |e| e.name.blank? }
def self.available_grouping_project_types
# this should be all project types to which there are projects to
# which there are dependencies from projects that the user can see
order(:name)
end
end

@ -143,7 +143,7 @@ module Type::Attributes
I18n.t('label_date')
else
key = attr_i18n_key(name)
I18n.t("activerecord.attributes.work_package.#{key}", default: '')
I18n.t("activerecord.attributes.work_package.#{key}", fallback: false, default: '')
.presence || I18n.t("attributes.#{key}")
end
end

@ -67,9 +67,6 @@ class User < Principal
has_many :responsible_for_issues, foreign_key: 'responsible_id',
class_name: 'WorkPackage',
dependent: :nullify
has_many :responsible_for_projects, foreign_key: 'responsible_id',
class_name: 'Project',
dependent: :nullify
has_many :watches, class_name: 'Watcher',
dependent: :delete_all
has_many :changesets, dependent: :nullify

@ -1,62 +0,0 @@
#-- encoding: UTF-8
#-- copyright
# OpenProject is a project management system.
# Copyright (C) 2012-2018 the OpenProject Foundation (OPF)
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License version 3.
#
# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
# Copyright (C) 2006-2017 Jean-Philippe Lang
# Copyright (C) 2010-2013 the ChiliProject Team
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# See docs/COPYRIGHT.rdoc for more details.
#++
module BasicData
class ProjectTypeSeeder < Seeder
def seed_data!
return unless applicable?
ProjectType.transaction do
data.each do |attributes|
ProjectType.create!(attributes)
end
end
end
def applicable?
if ProjectType.any?
return false
end
true
end
def not_applicable_message
if ProjectType.any?
'Skipping project types as there are already some configured'
end
end
def data
[
{ name: I18n.t(:default_project_type_scrum) },
{ name: I18n.t(:default_project_type_standard) }
]
end
end
end

@ -53,22 +53,6 @@ module BasicData
is_in_roadmap: true,
is_milestone: false)
# Adds the standard type to all existing projects
#
# As this seed might be executed on an existing database, there might be projects
# that do not have the default type yet.
condition = "NOT EXISTS
(SELECT * from projects_types
WHERE projects.id = projects_types.project_id
AND projects_types.type_id = #{standard_type.id})"
projects_without_standard_type = Project.where(condition).all
projects_without_standard_type.each do |project|
project.types << standard_type
end
[WorkPackage, Journal::WorkPackageJournal].each do |klass|
klass.where(type_id: nil).update_all(type_id: standard_type.id)
end

@ -35,7 +35,6 @@ class BasicDataSeeder < CompositeSeeder
BasicData::ColorSeeder,
BasicData::WorkflowSeeder,
BasicData::PrioritySeeder,
BasicData::ProjectTypeSeeder,
BasicData::SettingSeeder
]
end

@ -1,44 +0,0 @@
<%#-- copyright
OpenProject is a project management system.
Copyright (C) 2012-2018 the OpenProject Foundation (OPF)
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License version 3.
OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
Copyright (C) 2006-2017 Jean-Philippe Lang
Copyright (C) 2010-2013 the ChiliProject Team
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
See docs/COPYRIGHT.rdoc for more details.
++#%>
<%#
Form for Project Types.
needs locals:
f: labelled form builder
project_type: ProjectType
%>
<%= error_messages_for 'project_type' %>
<div class="form--field">
<%= f.text_field :name, required: true, container_class: '-middle' %>
</div>
<%= f.button t(:button_save), class: 'button -highlight -with-icon icon-checkmark' %>
<%= link_to t(:button_cancel), project_types_path, class: 'button' %>

@ -1,44 +0,0 @@
<%#-- copyright
OpenProject is a project management system.
Copyright (C) 2012-2018 the OpenProject Foundation (OPF)
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License version 3.
OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
Copyright (C) 2006-2017 Jean-Philippe Lang
Copyright (C) 2010-2013 the ChiliProject Team
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
See docs/COPYRIGHT.rdoc for more details.
++#%>
<%= toolbar title: @project_type.name %>
<%= labelled_tabular_form_for(@project_type,
url: project_type_path(@project_type),
html: {method: 'delete'}) do |f| %>
<div class='flash warning'>
<%= l('timelines.really_delete_project_type') %>
<span class="close-handler" role="button" tabindex="0" aria-label="{{ ::I18n.t('js.close_popup_title') }}">
<%= op_icon('icon-close') %>
</span>
</div>
<%= submit_tag l(:button_delete), class: 'button -highlight' %>
<%= link_to l(:button_cancel), project_types_path, class: 'button' %>
<% end %>

@ -1,40 +0,0 @@
<%#-- copyright
OpenProject is a project management system.
Copyright (C) 2012-2018 the OpenProject Foundation (OPF)
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License version 3.
OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
Copyright (C) 2006-2017 Jean-Philippe Lang
Copyright (C) 2010-2013 the ChiliProject Team
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
See docs/COPYRIGHT.rdoc for more details.
++#%>
<% html_title l(:label_administration), "#{l(:label_edit)} #{l("timelines.admin_menu.project_type")} #{h @project_type.name}" %>
<% local_assigns[:additional_breadcrumb] = @project_type.name %>
<%= toolbar title: "#{l(:label_edit)} #{l("timelines.admin_menu.project_type")} #{@project_type.name}" %>
<%= labelled_tabular_form_for(@project_type,
url: project_type_path(@project_type),
html: {method: 'put'}) do |f| %>
<%= render partial: "project_types/form",
locals: {f: f, project_type: @project_type} %>
<% end %>

@ -1,102 +0,0 @@
<%#-- copyright
OpenProject is a project management system.
Copyright (C) 2012-2018 the OpenProject Foundation (OPF)
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License version 3.
OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
Copyright (C) 2006-2017 Jean-Philippe Lang
Copyright (C) 2010-2013 the ChiliProject Team
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
See docs/COPYRIGHT.rdoc for more details.
++#%>
<% html_title l(:label_administration), l("timelines.admin_menu.project_types") %>
<%= toolbar title: l("timelines.admin_menu.project_types") do %>
<li class="toolbar-item">
<%= link_to new_project_type_path,
{ class: 'button -alt-highlight',
aria: {label: t('timelines.new_project_type')},
title: t('timelines.new_project_type')} do %>
<%= op_icon('button--icon icon-add') %>
<span class="button--text"><%= t('activerecord.attributes.project.project_type') %></span>
<% end %>
</li>
<% end %>
<% if @project_types.any? %>
<div class="generic-table--container">
<div class="generic-table--results-container">
<table class="generic-table">
<colgroup>
<col highlight-col>
<col highlight-col>
<col highlight-col>
<col>
</colgroup>
<thead>
<tr>
<th>
<div class="generic-table--sort-header-outer">
<div class="generic-table--sort-header">
<span>
<%= ProjectType.human_attribute_name(:name) %>
</span>
</div>
</div>
</th>
<th>
<div class="generic-table--sort-header-outer">
<div class="generic-table--sort-header">
<span>
<%= ProjectType.human_attribute_name(:position) %>
</span>
</div>
</div>
</th>
<th><div class="generic-table--empty-header"></div></th>
</tr>
</thead>
<tbody>
<% @project_types.each do |type| %>
<tr>
<td class="timelines-pt-name">
<%= link_to(h(type.name), edit_project_type_path(type)) %>
</td>
<td class="timelines-pt-reorder">
<%= reorder_links('project_type', {action: 'move', id: type}) %>
</td>
<td class="timelines-pt-actions buttons">
<%= link_to(confirm_destroy_project_type_path(type),
class: 'icon icon-delete') do %>
<%= l(:button_delete) %>
<span class="hidden-for-sighted"><%=h type.name %></span>
<% end %>
</td>
</tr>
<% end %>
</tbody>
</table>
</div>
</div>
<% else %>
<%= no_results_box(action_url: new_project_type_path, display_action: true) %>
<% end %>

@ -1,40 +0,0 @@
<%#-- copyright
OpenProject is a project management system.
Copyright (C) 2012-2018 the OpenProject Foundation (OPF)
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License version 3.
OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
Copyright (C) 2006-2017 Jean-Philippe Lang
Copyright (C) 2010-2013 the ChiliProject Team
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
See docs/COPYRIGHT.rdoc for more details.
++#%>
<% html_title l(:label_administration), "#{l(:label_new)} #{l("timelines.admin_menu.project_type")}" %>
<% local_assigns[:additional_breadcrumb] = l(:label_new) + ' ' + l("timelines.admin_menu.project_type") %>
<%= toolbar title: l('timelines.new_project_type') %>
<%= labelled_tabular_form_for(@project_type,
url: project_types_path,
html: {method: 'post'}) do |f| %>
<%= render partial: "project_types/form",
locals: {f: f, project_type: @project_type} %>
<% end %>

@ -32,8 +32,6 @@ See docs/COPYRIGHT.rdoc for more details.
locals: { form: form } %>
<%= render partial: "customizable/form",
locals: { form: form, all_fields: all_fields, only_required: render_advanced } %>
<%= render partial: "projects/form/attributes/responsible_id",
locals: { form: form } %>
<% if render_advanced %>
<fieldset id="advanced-settings" class="form--fieldset -collapsible collapsed">
<legend class="form--fieldset-legend" title="<%=t(:label_show_hide)%>" >
@ -48,8 +46,6 @@ See docs/COPYRIGHT.rdoc for more details.
locals: { form: form } %>
<%= render partial: "projects/form/attributes/identifier",
locals: { form: form } %>
<%= render partial: "projects/form/attributes/project_type_id",
locals: { form: form } %>
<%= render partial: "projects/form/attributes/is_public",
locals: { form: form } %>
<% unless all_fields %>

@ -1,35 +0,0 @@
<%#-- copyright
OpenProject is a project management system.
Copyright (C) 2012-2018 the OpenProject Foundation (OPF)
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License version 3.
OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
Copyright (C) 2006-2017 Jean-Philippe Lang
Copyright (C) 2010-2013 the ChiliProject Team
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
See docs/COPYRIGHT.rdoc for more details.
++#%>
<div class="form--field">
<%= form.select :project_type_id,
options_for_project_types,
include_blank: true,
container_class: '-middle' %>
</div>

@ -1,51 +0,0 @@
<%#-- copyright
OpenProject is a project management system.
Copyright (C) 2012-2018 the OpenProject Foundation (OPF)
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License version 3.
OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
Copyright (C) 2006-2017 Jean-Philippe Lang
Copyright (C) 2010-2013 the ChiliProject Team
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
See docs/COPYRIGHT.rdoc for more details.
++#%>
<%
project = form.object
%>
<div class="form--field">
<% if project && project.persisted? %>
<% if User.current.impaired? %>
<%= form.select :responsible_id, project.possible_responsibles.map {|m| [m.name, m.id]}, include_blank: true, container_class: '-wide' %>
<% else %>
<% responsible = project.responsible.nil? ? [t('label_none_parentheses'), -1] : [project.responsible.name, project.responsible.id]
options = { :'data-ajaxURL' => url_for({controller: "/members",
project_id: project,
action: "paginate_users" }),
:'data-projectId' => project.id,
:'data-selected' => [responsible].to_json
}
%>
<%= javascript_include_tag "autocompleter.js" %>
<%= javascript_include_tag "project/responsible_attribute.js" %>
<%= form.select(:responsible_id, options_for_select([]), {container_class: '-wide'}, options) %>
<% end %>
<% end %>
</div>

@ -127,7 +127,6 @@
# - settings
# - ldap_authentication
# - colors
# - project_types
# - export_card_configurations
# - plugins
# - info
@ -143,7 +142,6 @@
# - 'admin/info'
# - 'admin/plugins'
# - 'export_card_configurations'
# - 'project_types'
# - 'colors'
# - 'settings'
# - 'admin/enumerations'

@ -219,11 +219,6 @@ Redmine::MenuManager.map :admin_menu do |menu|
caption: :'timelines.admin_menu.colors',
icon: 'icon2 icon-status'
menu.push :project_types,
{ controller: '/project_types', action: 'index' },
caption: :'timelines.admin_menu.project_types',
icon: 'icon2 icon-project-types'
menu.push :enterprise,
{ controller: '/enterprises', action: 'show' },
caption: :label_enterprise_edition,

@ -152,10 +152,6 @@ en:
no_results_title_text: There are currently no versions for the project.
no_results_content_text: Create a new version
project_types:
index:
no_results_title_text: There are currently no project types.
no_results_content_text: Create a new project type
members:
index:
no_results_title_text: There are currently no members part of this project.
@ -351,7 +347,6 @@ en:
identifier: "Identifier"
latest_activity_at: "Latest activity at"
parent: "Subproject of"
project_type: "Project type"
queries: "Queries"
types: "Types"
versions: "Versions"
@ -405,8 +400,6 @@ en:
redirect_existing_links: "Redirect existing links"
planning_element_type_color:
hexcode: Hex code
project_type:
position: Position
work_package:
begin_insertion: "Begin of the insertion"
begin_deletion: "Begin of the deletion"
@ -590,7 +583,6 @@ en:
one : "Role"
other: "Roles"
type: "Type"
project_type: Project type
user: "User"
version: "Version"
wiki: "Wiki"
@ -852,11 +844,6 @@ en:
default_priority_normal: "Normal"
default_priority_high: "High"
default_priority_immediate: "Immediate"
default_project_type_scrum: "Scrum team"
default_project_type_standard: "Standard project"
default_reported_project_status_green: "Green"
default_reported_project_status_amber: "Amber"
default_reported_project_status_red: "Red"
default_role_anonymous: "Anonymous"
default_role_developer: "Developer"
default_role_project_admin: "Project admin"
@ -1200,7 +1187,6 @@ en:
label_edit: "Edit"
label_enable_multi_select: "Toggle multiselect"
label_enabled_project_custom_fields: 'Enabled custom fields'
label_enabled_project_types: 'Enabled types'
label_enabled_project_modules: 'Enabled modules'
label_enabled_project_activities: 'Enabled time tracking activities'
label_end_to_end: "end to end"
@ -2240,8 +2226,6 @@ en:
admin_menu:
color: "Color"
colors: "Colors"
project_type: "Project type"
project_types: "Project types"
associations: "Dependencies"
board_could_not_be_saved: "Board could not be saved"
button_delete_all: "Delete all"
@ -2258,7 +2242,6 @@ en:
one: "1 day"
other: "%{count} days"
edit_color: "Edit color"
edit_project_type: "Edit project type"
edit_thing: "Edit"
edit_timeline: "Edit timeline report %{timeline}"
delete_timeline: "Delete timeline report %{timeline}"
@ -2335,7 +2318,6 @@ en:
project_filters: "Filter projects"
project_responsible: "Show projects with accountable"
project_status: "Show project status"
project_types: "Show project types"
timeframe: "Show timeframe"
timeframe_end: "to"
timeframe_start: "from"
@ -2345,7 +2327,6 @@ en:
new_color: "New color"
new_association: "New dependency"
new_work_package: "New work package"
new_project_type: "New project type"
new_reporting: "New reporting"
new_timeline: "New timeline report"
no_projects_for_reporting_available: "There are no projects to which a reporting association can be created."
@ -2371,20 +2352,12 @@ en:
show: "Status: %{comment}"
planning_element_update: "Update: %{title}"
project_type_could_not_be_saved: "Project type could not be saved"
type_could_not_be_saved: "Type could not be saved"
reporting_could_not_be_saved: "Reporting could not be saved"
properties: "Properties"
really_delete_color: >
Are you sure, you want to delete the following color?
Types using this color will not be deleted.
really_delete_project_type: >
Are you sure, you want to delete the following project type?
Projects using this type will not be deleted.
really_delete_timeline: >
Are you sure, you want to delete the following timeline report?
Work packages shown in this timeline report will not be
deleted.
really_delete_reporting: >
Are you sure, you want to delete the following reporting?
Previous reporting statuses will be deleted, too.
@ -2393,7 +2366,6 @@ en:
timelines: "Timeline reports"
settings: "Timelines"
vertical_work_package: "Vertical work packages"
without_project_type: "Without project type"
you_are_viewing_the_selected_timeline: "You are viewing the selected timeline report"
zoom:
in: "Zoom in"

@ -450,7 +450,6 @@ en:
level5: "Expand level 5"
all: "Show all"
project_status: "Project status"
project_type: "Project type"
really_close_dialog: "Do you really want to close the dialog and lose the entered data?"
responsible: "Responsible"
save: Save

@ -537,16 +537,6 @@ OpenProject::Application.routes.draw do
end
end
resources :project_types, controller: 'project_types' do
member do
get :confirm_destroy
get :move
post :move
end
resources :projects, only: %i[index show], controller: 'projects'
end
# This route should probably be removed, but it's used at least by one cuke and we don't
# want to break it.
# This route intentionally occurs after the admin/roles/new route, so that one takes

@ -0,0 +1,20 @@
class RemoveResponsibleAndTypeFromProject < ActiveRecord::Migration[5.1]
def up
remove_belongs_to :projects, :responsible
remove_belongs_to :projects, :work_packages_responsible
remove_belongs_to :projects, :project_type
drop_table :project_types
end
def down
# Recreate project type
Tables::ProjectTypes.create self
change_table :projects do |t|
t.belongs_to :responsible, type: :int
t.belongs_to :work_packages_responsible, type: :int
t.belongs_to :project_type, type: :int
end
end
end

@ -27,13 +27,9 @@
# See docs/COPYRIGHT.rdoc for more details.
#++
Given /^there is a project named "([^"]*)"(?: of type "([^"]*)")?$/ do |name, project_type_name|
Given /^there is a project named "([^"]*)?$/ do |name|
attributes = { name: name,
identifier: name.downcase.gsub(' ', '_') }
if project_type_name
attributes.merge!(project_type: ProjectType.find_by!(name: project_type_name))
end
FactoryBot.create(:project, attributes)
end

@ -1,49 +0,0 @@
#-- encoding: UTF-8
#-- copyright
# OpenProject is a project management system.
# Copyright (C) 2012-2018 the OpenProject Foundation (OPF)
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License version 3.
#
# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
# Copyright (C) 2006-2017 Jean-Philippe Lang
# Copyright (C) 2010-2013 the ChiliProject Team
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# See docs/COPYRIGHT.rdoc for more details.
#++
InstanceFinder.register(ProjectType, Proc.new { |name| ProjectType.find_by(name: name) })
Given /^the project(?: named "([^"]*)")? has no project type$/ do |name|
project = get_project(name)
project.update_attribute(:project_type_id, nil)
end
Given /^the project(?: named "([^"]*)")? is of the type "([^"]*)"$/ do |name, type_name|
type_id = ProjectType.select(:id).find_by(name: type_name).id
project = get_project(name)
project.update_attribute(:project_type_id, type_id)
end
When /^I follow the edit link of the project type "([^"]*)"$/ do |project_type_name|
type = ProjectType.find_by(name: project_type_name)
href = Rails.application.routes.url_helpers.edit_project_type_path(type)
click_link(type.name, href: href)
end

@ -36,8 +36,6 @@ module API
class ProjectRepresenter < ::API::Decorators::Single
include ::API::Caching::CachedRepresenter
cached_representer key_parts: %i(project_type)
self_link
link :createWorkPackage,
@ -87,8 +85,6 @@ module API
exec_context: :decorator,
getter: ->(*) { datetime_formatter.format_datetime(represented.updated_on) }
property :type, getter: ->(*) { project_type.try(:name) }, render_nil: true
def _type
'Project'
end

@ -36,8 +36,6 @@ describe CopyProjectsController, type: :controller do
let(:copy_project_params) {
{
'description' => 'Some pretty description',
'responsible_id' => current_user.id,
'project_type_id' => '',
'enabled_module_names' => ['work_package_tracking', 'boards', ''],
'is_public' => project.is_public,
'type_ids' => project.types.map(&:id)

@ -1,114 +0,0 @@
#-- copyright
# OpenProject is a project management system.
# Copyright (C) 2012-2018 the OpenProject Foundation (OPF)
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License version 3.
#
# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
# Copyright (C) 2006-2017 Jean-Philippe Lang
# Copyright (C) 2010-2013 the ChiliProject Team
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# See docs/COPYRIGHT.rdoc for more details.
#++
require 'spec_helper'
describe ProjectTypesController, type: :controller do
let(:current_user) { FactoryBot.create(:admin) }
before do
allow(User).to receive(:current).and_return current_user
end
describe 'index.html' do
def fetch
get 'index'
end
it_should_behave_like 'a controller action with require_admin'
end
describe 'new.html' do
def fetch
get 'new'
end
it_should_behave_like 'a controller action with require_admin'
end
describe 'create.html' do
def fetch
post 'create', params: { project_type: FactoryBot.build(:project_type).attributes }
end
def expect_redirect_to
Regexp.new(project_types_path)
end
it_should_behave_like 'a controller action with require_admin'
end
describe 'edit.html' do
def fetch
FactoryBot.create(:project_type, id: '1337')
get 'edit', params: { id: '1337' }
end
it_should_behave_like 'a controller action with require_admin'
end
describe 'update.html' do
def fetch
FactoryBot.create(:project_type, id: '1337')
put 'update', params: { id: '1337', project_type: { 'name' => 'blubs' } }
end
def expect_redirect_to
project_types_path
end
it_should_behave_like 'a controller action with require_admin'
end
describe 'move.html' do
def fetch
FactoryBot.create(:project_type, id: '1337')
post 'move', params: { id: '1337', project_type: { move_to: 'highest' } }
end
def expect_redirect_to
project_types_path
end
it_should_behave_like 'a controller action with require_admin'
end
describe 'confirm_destroy.html' do
def fetch
FactoryBot.create(:project_type, id: '1337')
get 'confirm_destroy', params: { id: '1337' }
end
it_should_behave_like 'a controller action with require_admin'
end
describe 'destroy.html' do
def fetch
FactoryBot.create(:project_type, id: '1337')
post 'destroy', params: { id: '1337' }
end
def expect_redirect_to
project_types_path
end
it_should_behave_like 'a controller action with require_admin'
end
end

@ -1,34 +0,0 @@
#-- copyright
# OpenProject is a project management system.
# Copyright (C) 2012-2018 the OpenProject Foundation (OPF)
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License version 3.
#
# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
# Copyright (C) 2006-2017 Jean-Philippe Lang
# Copyright (C) 2010-2013 the ChiliProject Team
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# See docs/COPYRIGHT.rdoc for more details.
#++
FactoryBot.define do
factory(:project_type, class: ProjectType) do
sequence(:name) do |n| "Project Type No. #{n}" end
sequence(:position) { |n| n }
end
end

@ -1,48 +0,0 @@
#-- copyright
# OpenProject is a project management system.
# Copyright (C) 2012-2018 the OpenProject Foundation (OPF)
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License version 3.
#
# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
# Copyright (C) 2006-2017 Jean-Philippe Lang
# Copyright (C) 2010-2013 the ChiliProject Team
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# See docs/COPYRIGHT.rdoc for more details.
#++
require 'spec_helper'
feature 'project type administration', type: :feature do
let(:admin) { FactoryBot.create(:admin) }
before do
login_as(admin)
end
scenario 'CRUD' do
# Only a stub for now
visit project_types_path
expect(page)
.to have_content(I18n.t(:'project_types.index.no_results_title_text'))
click_link I18n.t(:'project_types.index.no_results_content_text')
end
end

@ -1,62 +0,0 @@
#-- copyright
# OpenProject is a project management system.
# Copyright (C) 2012-2018 the OpenProject Foundation (OPF)
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License version 3.
#
# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
# Copyright (C) 2006-2017 Jean-Philippe Lang
# Copyright (C) 2010-2013 the ChiliProject Team
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# See docs/COPYRIGHT.rdoc for more details.
#++
require 'spec_helper'
require 'features/projects/project_settings_page'
describe 'Projects responsible setting',
type: :feature,
with_settings: { user_format: :firstname_lastname },
js: true do
include Capybara::Select2
let!(:admin) { FactoryBot.create :admin }
let!(:user) { FactoryBot.create(:user, firstname: 'Foo', lastname: 'Bar', member_in_project: project) }
let!(:project) do
FactoryBot.create(:project,
name: 'Plain project',
identifier: 'plain-project')
end
let(:settings_page) { ProjectSettingsPage.new(project) }
before do
login_as admin
end
it 'can set the responsible (Regression test #28091)' do
settings_page.visit_settings
expect(page).to have_selector('.form--label', text: 'Responsible')
select2('Foo Bar', css: '#s2id_project_responsible_id')
click_on 'Save'
expect(page).to have_selector('.select2-chosen', text: 'Foo Bar')
project.reload
expect(project.responsible).to eq(user)
end
end

@ -71,8 +71,6 @@ describe ::API::V3::Projects::ProjectRepresenter do
let(:date) { project.updated_on }
let(:json_path) { 'updatedAt' }
end
it { is_expected.to have_json_path('type') }
end
describe '_links' do
@ -161,11 +159,6 @@ describe ::API::V3::Projects::ProjectRepresenter do
end
describe '#json_cache_key' do
let(:project_type) { FactoryBot.build_stubbed(:project_type) }
before do
project.project_type = project_type
end
let!(:former_cache_key) { representer.json_cache_key }
it 'includes the name of the representer class' do
@ -186,13 +179,6 @@ describe ::API::V3::Projects::ProjectRepresenter do
expect(representer.json_cache_key)
.not_to eql former_cache_key
end
it 'changes when the project\'s project_type is updated' do
project.project_type.updated_at = Time.now + 20.seconds
expect(representer.json_cache_key)
.not_to eql former_cache_key
end
end
end
end

@ -715,7 +715,7 @@ describe ::API::V3::WorkPackages::Schema::WorkPackageSchemaRepresenter do
it_behaves_like 'has basic schema properties' do
let(:path) { 'responsible' }
let(:type) { 'User' }
let(:name) { I18n.t('activerecord.attributes.work_package.responsible') }
let(:name) { I18n.t('attributes.responsible') }
let(:required) { false }
let(:writable) { true }
end

@ -83,12 +83,6 @@ describe PermittedParams, type: :model do
params = ActionController::Parameters.new(project_type: { 'blubs1' => 'blubs' })
expect(PermittedParams.new(params, user).project_type.to_h).to eq({})
PermittedParams.permit(:project_type, :blubs1)
expect(PermittedParams.new(params, user).project_type.to_h).to eq('blubs1' => 'blubs')
PermittedParams.instance_variable_set(:@whitelisted_params, original_whitelisted)
end
@ -120,27 +114,6 @@ describe PermittedParams, type: :model do
it_behaves_like 'allows params'
end
describe '#project_type' do
let(:attribute) { :project_type }
describe 'name' do
let(:hash) { { 'name' => 'blubs' } }
it_behaves_like 'allows params'
end
end
describe '#project_type_move' do
let(:attribute) { :project_type_move }
let(:hash_key) { :project_type }
describe 'move_to' do
let(:hash) { { 'move_to' => '1' } }
it_behaves_like 'allows params'
end
end
describe '#pref' do
let(:attribute) { :pref }

@ -1,73 +0,0 @@
#-- copyright
# OpenProject is a project management system.
# Copyright (C) 2012-2018 the OpenProject Foundation (OPF)
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License version 3.
#
# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
# Copyright (C) 2006-2017 Jean-Philippe Lang
# Copyright (C) 2010-2013 the ChiliProject Team
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# See docs/COPYRIGHT.rdoc for more details.
#++
require 'spec_helper'
describe ProjectType, type: :model do
describe '- Relations ' do
describe '#projects' do
it 'can read projects w/ the help of the has_many association' do
project_type = FactoryBot.create(:project_type)
project = FactoryBot.create(:project, project_type_id: project_type.id)
project_type.reload
expect(project_type.projects.size).to eq(1)
expect(project_type.projects.first).to eq(project)
end
end
end
describe '- Validations ' do
let(:attributes) {
{ name: 'Project Type No. 1' }
}
describe 'name' do
it 'is invalid w/o a name' do
attributes[:name] = nil
project_type = ProjectType.new(attributes)
expect(project_type).not_to be_valid
expect(project_type.errors[:name]).to be_present
expect(project_type.errors[:name]).to eq(["can't be blank."])
end
it 'is invalid w/ a name longer than 255 characters' do
attributes[:name] = 'A' * 500
project_type = ProjectType.new(attributes)
expect(project_type).not_to be_valid
expect(project_type.errors[:name]).to be_present
expect(project_type.errors[:name]).to eq(['is too long (maximum is 255 characters).'])
end
end
end
end

@ -449,18 +449,6 @@ describe User, 'deletion', type: :model do
end
end
describe 'WHEN the user is responsible for a project' do
before do
project.responsible = user
project.save!
user.destroy
project.reload
end
it { expect(Project.find_by(id: project.id)).to eq(project) }
it { expect(project.responsible).to be_nil }
end
describe 'WHEN the user is assigned an issue category' do
let(:category) {
FactoryBot.build(:category, assigned_to: user,

@ -229,7 +229,6 @@ describe Project, type: :model do
assert_equal 0, Wiki.count
assert_equal 0, WikiPage.count
assert_equal 0, WikiContent.count
assert_equal 0, Project.connection.select_all('SELECT * FROM projects_types').to_a.size
assert_equal 0, Project.connection.select_all('SELECT * FROM custom_fields_projects').to_a.size
assert_equal 0, CustomValue.where(customized_type: ['Project', 'Issue', 'TimeEntry', 'Version']).count
end

Loading…
Cancel
Save