Sets standard type if no type is selected

pull/493/head
Hagen Schink 11 years ago
parent 4e0e45086d
commit e14e8ef646
  1. 9
      app/controllers/projects_controller.rb
  2. 4
      app/models/type.rb
  3. 1
      config/locales/de.yml
  4. 5
      config/locales/en.yml

@ -193,9 +193,16 @@ class ProjectsController < ApplicationController
end
def types
flash[:notice] = []
unless params.has_key? :project
params[:project] = { "type_ids" => Type.standard_type.id }
flash[:notice] << l(:notice_automatic_set_of_standard_type)
end
params[:project].assert_valid_keys("type_ids")
if @project.update_attributes(params[:project])
flash[:notice] = l('notice_successful_update')
flash[:notice] << l('notice_successful_update')
else
flash[:error] = l('timelines.cannot_update_planning_element_types')
end

@ -91,6 +91,10 @@ class Type < ActiveRecord::Base
Status.where(status_table[:id].in(old_id_subselect).or(status_table[:id].in(new_id_subselect)))
end
def self.standard_type
@@standard_type ||= Type.where(is_standard: true).first
end
def statuses
return [] if new_record?
@statuses ||= Type.statuses([id])

@ -1030,6 +1030,7 @@ de:
notice_to_many_principals_to_display: "Es gibt zu viele Treffer.\nBitte engen Sie die Suche ein, indem sie den Namen der Person (oder der Gruppe) eingeben."
notice_unable_delete_time_entry: "Der Zeiterfassungseintrag konnte nicht gelöscht werden."
notice_unable_delete_version: "Die Version konnte nicht gelöscht werden."
notice_automatic_set_of_standard_type: "Der Standard-Typ wurde automatisch gesetzt."
# Default format for numbers
number:

@ -1012,13 +1012,10 @@ en:
notice_to_many_principals_to_display: "There are too many results.\nNarrow down the search by typing in the name of the new member (or group)."
notice_unable_delete_time_entry: "Unable to delete time log entry."
notice_unable_delete_version: "Unable to delete version."
notice_automatic_set_of_standard_type: "Set standard type automatically."
# Default format for numbers
number:
format:
delimiter: ""
precision: 3

Loading…
Cancel
Save