parent
ab5160643e
commit
b08a5874f5
@ -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 |
@ -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 |
@ -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 |
@ -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 %> |
@ -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> |
@ -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 |
@ -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 |
@ -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 |
@ -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 |
Loading…
Reference in new issue