Revision 1297:0a574315af3e .svn/pristine/a6

View differences:

.svn/pristine/a6/a65be5ff4e4d817d915292a1086456273d988086.svn-base
1
<h2><%= link_to l(@enumeration.option_name), enumerations_path %> &#187; <%=l(:label_enumeration_new)%></h2>
2

  
3
<%= labelled_form_for :enumeration, @enumeration, :url => enumerations_path do |f| %>
4
  <%= f.hidden_field :type  %>
5
  <%= render :partial => 'form', :locals => {:f => f} %>
6
  <%= submit_tag l(:button_create) %>
7
<% end %>
.svn/pristine/a6/a68ae98331ab8e425c64f338d2d4aae23bc594f6.svn-base
1
# Redmine - project management software
2
# Copyright (C) 2006-2012  Jean-Philippe Lang
3
#
4
# This program is free software; you can redistribute it and/or
5
# modify it under the terms of the GNU General Public License
6
# as published by the Free Software Foundation; either version 2
7
# of the License, or (at your option) any later version.
8
#
9
# This program is distributed in the hope that it will be useful,
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
# GNU General Public License for more details.
13
#
14
# You should have received a copy of the GNU General Public License
15
# along with this program; if not, write to the Free Software
16
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
17

  
18
require File.expand_path('../../test_helper', __FILE__)
19
require 'wikis_controller'
20

  
21
# Re-raise errors caught by the controller.
22
class WikisController; def rescue_action(e) raise e end; end
23

  
24
class WikisControllerTest < ActionController::TestCase
25
  fixtures :projects, :users, :roles, :members, :member_roles, :enabled_modules, :wikis
26

  
27
  def setup
28
    @controller = WikisController.new
29
    @request    = ActionController::TestRequest.new
30
    @response   = ActionController::TestResponse.new
31
    User.current = nil
32
  end
33

  
34
  def test_create
35
    @request.session[:user_id] = 1
36
    assert_nil Project.find(3).wiki
37

  
38
    assert_difference 'Wiki.count' do
39
      xhr :post, :edit, :id => 3, :wiki => { :start_page => 'Start page' }
40
      assert_response :success
41
      assert_template 'edit'
42
      assert_equal 'text/javascript', response.content_type
43
    end
44

  
45
    wiki = Project.find(3).wiki
46
    assert_not_nil wiki
47
    assert_equal 'Start page', wiki.start_page
48
  end
49

  
50
  def test_create_with_failure
51
    @request.session[:user_id] = 1
52

  
53
    assert_no_difference 'Wiki.count' do
54
      xhr :post, :edit, :id => 3, :wiki => { :start_page => '' }
55
      assert_response :success
56
      assert_template 'edit'
57
      assert_equal 'text/javascript', response.content_type
58
    end
59

  
60
    assert_include 'errorExplanation', response.body
61
    assert_include 'Start page can&#x27;t be blank', response.body
62
  end
63

  
64
  def test_update
65
    @request.session[:user_id] = 1
66

  
67
    assert_no_difference 'Wiki.count' do
68
      xhr :post, :edit, :id => 1, :wiki => { :start_page => 'Other start page' }
69
      assert_response :success
70
      assert_template 'edit'
71
      assert_equal 'text/javascript', response.content_type
72
    end
73

  
74
    wiki = Project.find(1).wiki
75
    assert_equal 'Other start page', wiki.start_page
76
  end
77

  
78
  def test_destroy
79
    @request.session[:user_id] = 1
80
    post :destroy, :id => 1, :confirm => 1
81
    assert_redirected_to :controller => 'projects', :action => 'settings', :id => 'ecookbook', :tab => 'wiki'
82
    assert_nil Project.find(1).wiki
83
  end
84

  
85
  def test_not_found
86
    @request.session[:user_id] = 1
87
    post :destroy, :id => 999, :confirm => 1
88
    assert_response 404
89
  end
90
end
.svn/pristine/a6/a6be7752b3e1c7a6a368129ebcfd669e88823a53.svn-base
1
# Redmine - project management software
2
# Copyright (C) 2006-2012  Jean-Philippe Lang
3
#
4
# This program is free software; you can redistribute it and/or
5
# modify it under the terms of the GNU General Public License
6
# as published by the Free Software Foundation; either version 2
7
# of the License, or (at your option) any later version.
8
#
9
# This program is distributed in the hope that it will be useful,
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
# GNU General Public License for more details.
13
#
14
# You should have received a copy of the GNU General Public License
15
# along with this program; if not, write to the Free Software
16
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
17

  
18
require File.expand_path('../../../test_helper', __FILE__)
19

  
20
class RoutingFilesTest < ActionController::IntegrationTest
21
  def test_files
22
    assert_routing(
23
        { :method => 'get', :path => "/projects/33/files" },
24
        { :controller => 'files', :action => 'index', :project_id => '33' }
25
      )
26
    assert_routing(
27
        { :method => 'get', :path => "/projects/33/files/new" },
28
        { :controller => 'files', :action => 'new', :project_id => '33' }
29
      )
30
    assert_routing(
31
        { :method => 'post', :path => "/projects/33/files" },
32
        { :controller => 'files', :action => 'create', :project_id => '33' }
33
      )
34
  end
35
end
.svn/pristine/a6/a6d8d977a7db837089d88e0eb10b4689db86305a.svn-base
1
# Redmine - project management software
2
# Copyright (C) 2006-2012  Jean-Philippe Lang
3
#
4
# This program is free software; you can redistribute it and/or
5
# modify it under the terms of the GNU General Public License
6
# as published by the Free Software Foundation; either version 2
7
# of the License, or (at your option) any later version.
8
#
9
# This program is distributed in the hope that it will be useful,
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
# GNU General Public License for more details.
13
#
14
# You should have received a copy of the GNU General Public License
15
# along with this program; if not, write to the Free Software
16
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
17

  
18
class Project < ActiveRecord::Base
19
  include Redmine::SafeAttributes
20

  
21
  # Project statuses
22
  STATUS_ACTIVE     = 1
23
  STATUS_CLOSED     = 5
24
  STATUS_ARCHIVED   = 9
25

  
26
  # Maximum length for project identifiers
27
  IDENTIFIER_MAX_LENGTH = 100
28

  
29
  # Specific overidden Activities
30
  has_many :time_entry_activities
31
  has_many :members, :include => [:principal, :roles], :conditions => "#{User.table_name}.type='User' AND #{User.table_name}.status=#{User::STATUS_ACTIVE}"
32
  has_many :memberships, :class_name => 'Member'
33
  has_many :member_principals, :class_name => 'Member',
34
                               :include => :principal,
35
                               :conditions => "#{Principal.table_name}.type='Group' OR (#{Principal.table_name}.type='User' AND #{Principal.table_name}.status=#{User::STATUS_ACTIVE})"
36
  has_many :users, :through => :members
37
  has_many :principals, :through => :member_principals, :source => :principal
38

  
39
  has_many :enabled_modules, :dependent => :delete_all
40
  has_and_belongs_to_many :trackers, :order => "#{Tracker.table_name}.position"
41
  has_many :issues, :dependent => :destroy, :include => [:status, :tracker]
42
  has_many :issue_changes, :through => :issues, :source => :journals
43
  has_many :versions, :dependent => :destroy, :order => "#{Version.table_name}.effective_date DESC, #{Version.table_name}.name DESC"
44
  has_many :time_entries, :dependent => :delete_all
45
  has_many :queries, :dependent => :delete_all
46
  has_many :documents, :dependent => :destroy
47
  has_many :news, :dependent => :destroy, :include => :author
48
  has_many :issue_categories, :dependent => :delete_all, :order => "#{IssueCategory.table_name}.name"
49
  has_many :boards, :dependent => :destroy, :order => "position ASC"
50
  has_one :repository, :conditions => ["is_default = ?", true]
51
  has_many :repositories, :dependent => :destroy
52
  has_many :changesets, :through => :repository
53
  has_one :wiki, :dependent => :destroy
54
  # Custom field for the project issues
55
  has_and_belongs_to_many :issue_custom_fields,
56
                          :class_name => 'IssueCustomField',
57
                          :order => "#{CustomField.table_name}.position",
58
                          :join_table => "#{table_name_prefix}custom_fields_projects#{table_name_suffix}",
59
                          :association_foreign_key => 'custom_field_id'
60

  
61
  acts_as_nested_set :order => 'name', :dependent => :destroy
62
  acts_as_attachable :view_permission => :view_files,
63
                     :delete_permission => :manage_files
64

  
65
  acts_as_customizable
66
  acts_as_searchable :columns => ['name', 'identifier', 'description'], :project_key => 'id', :permission => nil
67
  acts_as_event :title => Proc.new {|o| "#{l(:label_project)}: #{o.name}"},
68
                :url => Proc.new {|o| {:controller => 'projects', :action => 'show', :id => o}},
69
                :author => nil
70

  
71
  attr_protected :status
72

  
73
  validates_presence_of :name, :identifier
74
  validates_uniqueness_of :identifier
75
  validates_associated :repository, :wiki
76
  validates_length_of :name, :maximum => 255
77
  validates_length_of :homepage, :maximum => 255
78
  validates_length_of :identifier, :in => 1..IDENTIFIER_MAX_LENGTH
79
  # donwcase letters, digits, dashes but not digits only
80
  validates_format_of :identifier, :with => /^(?!\d+$)[a-z0-9\-_]*$/, :if => Proc.new { |p| p.identifier_changed? }
81
  # reserved words
82
  validates_exclusion_of :identifier, :in => %w( new )
83

  
84
  after_save :update_position_under_parent, :if => Proc.new {|project| project.name_changed?}
85
  before_destroy :delete_all_members
86

  
87
  scope :has_module, lambda { |mod| { :conditions => ["#{Project.table_name}.id IN (SELECT em.project_id FROM #{EnabledModule.table_name} em WHERE em.name=?)", mod.to_s] } }
88
  scope :active, { :conditions => "#{Project.table_name}.status = #{STATUS_ACTIVE}"}
89
  scope :status, lambda {|arg| arg.blank? ? {} : {:conditions => {:status => arg.to_i}} }
90
  scope :all_public, { :conditions => { :is_public => true } }
91
  scope :visible, lambda {|*args| {:conditions => Project.visible_condition(args.shift || User.current, *args) }}
92
  scope :allowed_to, lambda {|*args| 
93
    user = User.current
94
    permission = nil
95
    if args.first.is_a?(Symbol)
96
      permission = args.shift
97
    else
98
      user = args.shift
99
      permission = args.shift
100
    end
101
    { :conditions => Project.allowed_to_condition(user, permission, *args) }
102
  }
103
  scope :like, lambda {|arg|
104
    if arg.blank?
105
      {}
106
    else
107
      pattern = "%#{arg.to_s.strip.downcase}%"
108
      {:conditions => ["LOWER(identifier) LIKE :p OR LOWER(name) LIKE :p", {:p => pattern}]}
109
    end
110
  }
111

  
112
  def initialize(attributes=nil, *args)
113
    super
114

  
115
    initialized = (attributes || {}).stringify_keys
116
    if !initialized.key?('identifier') && Setting.sequential_project_identifiers?
117
      self.identifier = Project.next_identifier
118
    end
119
    if !initialized.key?('is_public')
120
      self.is_public = Setting.default_projects_public?
121
    end
122
    if !initialized.key?('enabled_module_names')
123
      self.enabled_module_names = Setting.default_projects_modules
124
    end
125
    if !initialized.key?('trackers') && !initialized.key?('tracker_ids')
126
      self.trackers = Tracker.sorted.all
127
    end
128
  end
129

  
130
  def identifier=(identifier)
131
    super unless identifier_frozen?
132
  end
133

  
134
  def identifier_frozen?
135
    errors[:identifier].blank? && !(new_record? || identifier.blank?)
136
  end
137

  
138
  # returns latest created projects
139
  # non public projects will be returned only if user is a member of those
140
  def self.latest(user=nil, count=5)
141
    visible(user).find(:all, :limit => count, :order => "created_on DESC")	
142
  end	
143

  
144
  # Returns true if the project is visible to +user+ or to the current user.
145
  def visible?(user=User.current)
146
    user.allowed_to?(:view_project, self)
147
  end
148

  
149
  # Returns a SQL conditions string used to find all projects visible by the specified user.
150
  #
151
  # Examples:
152
  #   Project.visible_condition(admin)        => "projects.status = 1"
153
  #   Project.visible_condition(normal_user)  => "((projects.status = 1) AND (projects.is_public = 1 OR projects.id IN (1,3,4)))"
154
  #   Project.visible_condition(anonymous)    => "((projects.status = 1) AND (projects.is_public = 1))"
155
  def self.visible_condition(user, options={})
156
    allowed_to_condition(user, :view_project, options)
157
  end
158

  
159
  # Returns a SQL conditions string used to find all projects for which +user+ has the given +permission+
160
  #
161
  # Valid options:
162
  # * :project => limit the condition to project
163
  # * :with_subprojects => limit the condition to project and its subprojects
164
  # * :member => limit the condition to the user projects
165
  def self.allowed_to_condition(user, permission, options={})
166
    perm = Redmine::AccessControl.permission(permission)
167
    base_statement = (perm && perm.read? ? "#{Project.table_name}.status <> #{Project::STATUS_ARCHIVED}" : "#{Project.table_name}.status = #{Project::STATUS_ACTIVE}")
168
    if perm && perm.project_module
169
      # If the permission belongs to a project module, make sure the module is enabled
170
      base_statement << " AND #{Project.table_name}.id IN (SELECT em.project_id FROM #{EnabledModule.table_name} em WHERE em.name='#{perm.project_module}')"
171
    end
172
    if options[:project]
173
      project_statement = "#{Project.table_name}.id = #{options[:project].id}"
174
      project_statement << " OR (#{Project.table_name}.lft > #{options[:project].lft} AND #{Project.table_name}.rgt < #{options[:project].rgt})" if options[:with_subprojects]
175
      base_statement = "(#{project_statement}) AND (#{base_statement})"
176
    end
177

  
178
    if user.admin?
179
      base_statement
180
    else
181
      statement_by_role = {}
182
      unless options[:member]
183
        role = user.logged? ? Role.non_member : Role.anonymous
184
        if role.allowed_to?(permission)
185
          statement_by_role[role] = "#{Project.table_name}.is_public = #{connection.quoted_true}"
186
        end
187
      end
188
      if user.logged?
189
        user.projects_by_role.each do |role, projects|
190
          if role.allowed_to?(permission) && projects.any?
191
            statement_by_role[role] = "#{Project.table_name}.id IN (#{projects.collect(&:id).join(',')})"
192
          end
193
        end
194
      end
195
      if statement_by_role.empty?
196
        "1=0"
197
      else
198
        if block_given?
199
          statement_by_role.each do |role, statement|
200
            if s = yield(role, user)
201
              statement_by_role[role] = "(#{statement} AND (#{s}))"
202
            end
203
          end
204
        end
205
        "((#{base_statement}) AND (#{statement_by_role.values.join(' OR ')}))"
206
      end
207
    end
208
  end
209

  
210
  # Returns the Systemwide and project specific activities
211
  def activities(include_inactive=false)
212
    if include_inactive
213
      return all_activities
214
    else
215
      return active_activities
216
    end
217
  end
218

  
219
  # Will create a new Project specific Activity or update an existing one
220
  #
221
  # This will raise a ActiveRecord::Rollback if the TimeEntryActivity
222
  # does not successfully save.
223
  def update_or_create_time_entry_activity(id, activity_hash)
224
    if activity_hash.respond_to?(:has_key?) && activity_hash.has_key?('parent_id')
225
      self.create_time_entry_activity_if_needed(activity_hash)
226
    else
227
      activity = project.time_entry_activities.find_by_id(id.to_i)
228
      activity.update_attributes(activity_hash) if activity
229
    end
230
  end
231

  
232
  # Create a new TimeEntryActivity if it overrides a system TimeEntryActivity
233
  #
234
  # This will raise a ActiveRecord::Rollback if the TimeEntryActivity
235
  # does not successfully save.
236
  def create_time_entry_activity_if_needed(activity)
237
    if activity['parent_id']
238

  
239
      parent_activity = TimeEntryActivity.find(activity['parent_id'])
240
      activity['name'] = parent_activity.name
241
      activity['position'] = parent_activity.position
242

  
243
      if Enumeration.overridding_change?(activity, parent_activity)
244
        project_activity = self.time_entry_activities.create(activity)
245

  
246
        if project_activity.new_record?
247
          raise ActiveRecord::Rollback, "Overridding TimeEntryActivity was not successfully saved"
248
        else
249
          self.time_entries.update_all("activity_id = #{project_activity.id}", ["activity_id = ?", parent_activity.id])
250
        end
251
      end
252
    end
253
  end
254

  
255
  # Returns a :conditions SQL string that can be used to find the issues associated with this project.
256
  #
257
  # Examples:
258
  #   project.project_condition(true)  => "(projects.id = 1 OR (projects.lft > 1 AND projects.rgt < 10))"
259
  #   project.project_condition(false) => "projects.id = 1"
260
  def project_condition(with_subprojects)
261
    cond = "#{Project.table_name}.id = #{id}"
262
    cond = "(#{cond} OR (#{Project.table_name}.lft > #{lft} AND #{Project.table_name}.rgt < #{rgt}))" if with_subprojects
263
    cond
264
  end
265

  
266
  def self.find(*args)
267
    if args.first && args.first.is_a?(String) && !args.first.match(/^\d*$/)
268
      project = find_by_identifier(*args)
269
      raise ActiveRecord::RecordNotFound, "Couldn't find Project with identifier=#{args.first}" if project.nil?
270
      project
271
    else
272
      super
273
    end
274
  end
275

  
276
  def self.find_by_param(*args)
277
    self.find(*args)
278
  end
279

  
280
  def reload(*args)
281
    @shared_versions = nil
282
    @rolled_up_versions = nil
283
    @rolled_up_trackers = nil
284
    @all_issue_custom_fields = nil
285
    @all_time_entry_custom_fields = nil
286
    @to_param = nil
287
    @allowed_parents = nil
288
    @allowed_permissions = nil
289
    @actions_allowed = nil
290
    super
291
  end
292

  
293
  def to_param
294
    # id is used for projects with a numeric identifier (compatibility)
295
    @to_param ||= (identifier.to_s =~ %r{^\d*$} ? id.to_s : identifier)
296
  end
297

  
298
  def active?
299
    self.status == STATUS_ACTIVE
300
  end
301

  
302
  def archived?
303
    self.status == STATUS_ARCHIVED
304
  end
305

  
306
  # Archives the project and its descendants
307
  def archive
308
    # Check that there is no issue of a non descendant project that is assigned
309
    # to one of the project or descendant versions
310
    v_ids = self_and_descendants.collect {|p| p.version_ids}.flatten
311
    if v_ids.any? && Issue.find(:first, :include => :project,
312
                                        :conditions => ["(#{Project.table_name}.lft < ? OR #{Project.table_name}.rgt > ?)" +
313
                                                        " AND #{Issue.table_name}.fixed_version_id IN (?)", lft, rgt, v_ids])
314
      return false
315
    end
316
    Project.transaction do
317
      archive!
318
    end
319
    true
320
  end
321

  
322
  # Unarchives the project
323
  # All its ancestors must be active
324
  def unarchive
325
    return false if ancestors.detect {|a| !a.active?}
326
    update_attribute :status, STATUS_ACTIVE
327
  end
328

  
329
  def close
330
    self_and_descendants.status(STATUS_ACTIVE).update_all :status => STATUS_CLOSED
331
  end
332

  
333
  def reopen
334
    self_and_descendants.status(STATUS_CLOSED).update_all :status => STATUS_ACTIVE
335
  end
336

  
337
  # Returns an array of projects the project can be moved to
338
  # by the current user
339
  def allowed_parents
340
    return @allowed_parents if @allowed_parents
341
    @allowed_parents = Project.find(:all, :conditions => Project.allowed_to_condition(User.current, :add_subprojects))
342
    @allowed_parents = @allowed_parents - self_and_descendants
343
    if User.current.allowed_to?(:add_project, nil, :global => true) || (!new_record? && parent.nil?)
344
      @allowed_parents << nil
345
    end
346
    unless parent.nil? || @allowed_parents.empty? || @allowed_parents.include?(parent)
347
      @allowed_parents << parent
348
    end
349
    @allowed_parents
350
  end
351

  
352
  # Sets the parent of the project with authorization check
353
  def set_allowed_parent!(p)
354
    unless p.nil? || p.is_a?(Project)
355
      if p.to_s.blank?
356
        p = nil
357
      else
358
        p = Project.find_by_id(p)
359
        return false unless p
360
      end
361
    end
362
    if p.nil?
363
      if !new_record? && allowed_parents.empty?
364
        return false
365
      end
366
    elsif !allowed_parents.include?(p)
367
      return false
368
    end
369
    set_parent!(p)
370
  end
371

  
372
  # Sets the parent of the project
373
  # Argument can be either a Project, a String, a Fixnum or nil
374
  def set_parent!(p)
375
    unless p.nil? || p.is_a?(Project)
376
      if p.to_s.blank?
377
        p = nil
378
      else
379
        p = Project.find_by_id(p)
380
        return false unless p
381
      end
382
    end
383
    if p == parent && !p.nil?
384
      # Nothing to do
385
      true
386
    elsif p.nil? || (p.active? && move_possible?(p))
387
      set_or_update_position_under(p)
388
      Issue.update_versions_from_hierarchy_change(self)
389
      true
390
    else
391
      # Can not move to the given target
392
      false
393
    end
394
  end
395

  
396
  # Recalculates all lft and rgt values based on project names
397
  # Unlike Project.rebuild!, these values are recalculated even if the tree "looks" valid
398
  # Used in BuildProjectsTree migration
399
  def self.rebuild_tree!
400
    transaction do
401
      update_all "lft = NULL, rgt = NULL"
402
      rebuild!(false)
403
    end
404
  end
405

  
406
  # Returns an array of the trackers used by the project and its active sub projects
407
  def rolled_up_trackers
408
    @rolled_up_trackers ||=
409
      Tracker.find(:all, :joins => :projects,
410
                         :select => "DISTINCT #{Tracker.table_name}.*",
411
                         :conditions => ["#{Project.table_name}.lft >= ? AND #{Project.table_name}.rgt <= ? AND #{Project.table_name}.status <> #{STATUS_ARCHIVED}", lft, rgt],
412
                         :order => "#{Tracker.table_name}.position")
413
  end
414

  
415
  # Closes open and locked project versions that are completed
416
  def close_completed_versions
417
    Version.transaction do
418
      versions.find(:all, :conditions => {:status => %w(open locked)}).each do |version|
419
        if version.completed?
420
          version.update_attribute(:status, 'closed')
421
        end
422
      end
423
    end
424
  end
425

  
426
  # Returns a scope of the Versions on subprojects
427
  def rolled_up_versions
428
    @rolled_up_versions ||=
429
      Version.scoped(:include => :project,
430
                     :conditions => ["#{Project.table_name}.lft >= ? AND #{Project.table_name}.rgt <= ? AND #{Project.table_name}.status <> #{STATUS_ARCHIVED}", lft, rgt])
431
  end
432

  
433
  # Returns a scope of the Versions used by the project
434
  def shared_versions
435
    if new_record?
436
      Version.scoped(:include => :project,
437
                     :conditions => "#{Project.table_name}.status <> #{Project::STATUS_ARCHIVED} AND #{Version.table_name}.sharing = 'system'")
438
    else
439
      @shared_versions ||= begin
440
        r = root? ? self : root
441
        Version.scoped(:include => :project,
442
                       :conditions => "#{Project.table_name}.id = #{id}" +
443
                                      " OR (#{Project.table_name}.status <> #{Project::STATUS_ARCHIVED} AND (" +
444
                                          " #{Version.table_name}.sharing = 'system'" +
445
                                          " OR (#{Project.table_name}.lft >= #{r.lft} AND #{Project.table_name}.rgt <= #{r.rgt} AND #{Version.table_name}.sharing = 'tree')" +
446
                                          " OR (#{Project.table_name}.lft < #{lft} AND #{Project.table_name}.rgt > #{rgt} AND #{Version.table_name}.sharing IN ('hierarchy', 'descendants'))" +
447
                                          " OR (#{Project.table_name}.lft > #{lft} AND #{Project.table_name}.rgt < #{rgt} AND #{Version.table_name}.sharing = 'hierarchy')" +
448
                                          "))")
449
      end
450
    end
451
  end
452

  
453
  # Returns a hash of project users grouped by role
454
  def users_by_role
455
    members.find(:all, :include => [:user, :roles]).inject({}) do |h, m|
456
      m.roles.each do |r|
457
        h[r] ||= []
458
        h[r] << m.user
459
      end
460
      h
461
    end
462
  end
463

  
464
  # Deletes all project's members
465
  def delete_all_members
466
    me, mr = Member.table_name, MemberRole.table_name
467
    connection.delete("DELETE FROM #{mr} WHERE #{mr}.member_id IN (SELECT #{me}.id FROM #{me} WHERE #{me}.project_id = #{id})")
468
    Member.delete_all(['project_id = ?', id])
469
  end
470

  
471
  # Users/groups issues can be assigned to
472
  def assignable_users
473
    assignable = Setting.issue_group_assignment? ? member_principals : members
474
    assignable.select {|m| m.roles.detect {|role| role.assignable?}}.collect {|m| m.principal}.sort
475
  end
476

  
477
  # Returns the mail adresses of users that should be always notified on project events
478
  def recipients
479
    notified_users.collect {|user| user.mail}
480
  end
481

  
482
  # Returns the users that should be notified on project events
483
  def notified_users
484
    # TODO: User part should be extracted to User#notify_about?
485
    members.select {|m| m.principal.present? && (m.mail_notification? || m.principal.mail_notification == 'all')}.collect {|m| m.principal}
486
  end
487

  
488
  # Returns an array of all custom fields enabled for project issues
489
  # (explictly associated custom fields and custom fields enabled for all projects)
490
  def all_issue_custom_fields
491
    @all_issue_custom_fields ||= (IssueCustomField.for_all + issue_custom_fields).uniq.sort
492
  end
493

  
494
  # Returns an array of all custom fields enabled for project time entries
495
  # (explictly associated custom fields and custom fields enabled for all projects)
496
  def all_time_entry_custom_fields
497
    @all_time_entry_custom_fields ||= (TimeEntryCustomField.for_all + time_entry_custom_fields).uniq.sort
498
  end
499

  
500
  def project
501
    self
502
  end
503

  
504
  def <=>(project)
505
    name.downcase <=> project.name.downcase
506
  end
507

  
508
  def to_s
509
    name
510
  end
511

  
512
  # Returns a short description of the projects (first lines)
513
  def short_description(length = 255)
514
    description.gsub(/^(.{#{length}}[^\n\r]*).*$/m, '\1...').strip if description
515
  end
516

  
517
  def css_classes
518
    s = 'project'
519
    s << ' root' if root?
520
    s << ' child' if child?
521
    s << (leaf? ? ' leaf' : ' parent')
522
    unless active?
523
      if archived?
524
        s << ' archived'
525
      else
526
        s << ' closed'
527
      end
528
    end
529
    s
530
  end
531

  
532
  # The earliest start date of a project, based on it's issues and versions
533
  def start_date
534
    [
535
     issues.minimum('start_date'),
536
     shared_versions.collect(&:effective_date),
537
     shared_versions.collect(&:start_date)
538
    ].flatten.compact.min
539
  end
540

  
541
  # The latest due date of an issue or version
542
  def due_date
543
    [
544
     issues.maximum('due_date'),
545
     shared_versions.collect(&:effective_date),
546
     shared_versions.collect {|v| v.fixed_issues.maximum('due_date')}
547
    ].flatten.compact.max
548
  end
549

  
550
  def overdue?
551
    active? && !due_date.nil? && (due_date < Date.today)
552
  end
553

  
554
  # Returns the percent completed for this project, based on the
555
  # progress on it's versions.
556
  def completed_percent(options={:include_subprojects => false})
557
    if options.delete(:include_subprojects)
558
      total = self_and_descendants.collect(&:completed_percent).sum
559

  
560
      total / self_and_descendants.count
561
    else
562
      if versions.count > 0
563
        total = versions.collect(&:completed_pourcent).sum
564

  
565
        total / versions.count
566
      else
567
        100
568
      end
569
    end
570
  end
571

  
572
  # Return true if this project allows to do the specified action.
573
  # action can be:
574
  # * a parameter-like Hash (eg. :controller => 'projects', :action => 'edit')
575
  # * a permission Symbol (eg. :edit_project)
576
  def allows_to?(action)
577
    if archived?
578
      # No action allowed on archived projects
579
      return false
580
    end
581
    unless active? || Redmine::AccessControl.read_action?(action)
582
      # No write action allowed on closed projects
583
      return false
584
    end
585
    # No action allowed on disabled modules
586
    if action.is_a? Hash
587
      allowed_actions.include? "#{action[:controller]}/#{action[:action]}"
588
    else
589
      allowed_permissions.include? action
590
    end
591
  end
592

  
593
  def module_enabled?(module_name)
594
    module_name = module_name.to_s
595
    enabled_modules.detect {|m| m.name == module_name}
596
  end
597

  
598
  def enabled_module_names=(module_names)
599
    if module_names && module_names.is_a?(Array)
600
      module_names = module_names.collect(&:to_s).reject(&:blank?)
601
      self.enabled_modules = module_names.collect {|name| enabled_modules.detect {|mod| mod.name == name} || EnabledModule.new(:name => name)}
602
    else
603
      enabled_modules.clear
604
    end
605
  end
606

  
607
  # Returns an array of the enabled modules names
608
  def enabled_module_names
609
    enabled_modules.collect(&:name)
610
  end
611

  
612
  # Enable a specific module
613
  #
614
  # Examples:
615
  #   project.enable_module!(:issue_tracking)
616
  #   project.enable_module!("issue_tracking")
617
  def enable_module!(name)
618
    enabled_modules << EnabledModule.new(:name => name.to_s) unless module_enabled?(name)
619
  end
620

  
621
  # Disable a module if it exists
622
  #
623
  # Examples:
624
  #   project.disable_module!(:issue_tracking)
625
  #   project.disable_module!("issue_tracking")
626
  #   project.disable_module!(project.enabled_modules.first)
627
  def disable_module!(target)
628
    target = enabled_modules.detect{|mod| target.to_s == mod.name} unless enabled_modules.include?(target)
629
    target.destroy unless target.blank?
630
  end
631

  
632
  safe_attributes 'name',
633
    'description',
634
    'homepage',
635
    'is_public',
636
    'identifier',
637
    'custom_field_values',
638
    'custom_fields',
639
    'tracker_ids',
640
    'issue_custom_field_ids'
641

  
642
  safe_attributes 'enabled_module_names',
643
    :if => lambda {|project, user| project.new_record? || user.allowed_to?(:select_project_modules, project) }
644

  
645
  # Returns an array of projects that are in this project's hierarchy
646
  #
647
  # Example: parents, children, siblings
648
  def hierarchy
649
    parents = project.self_and_ancestors || []
650
    descendants = project.descendants || []
651
    project_hierarchy = parents | descendants # Set union
652
  end
653

  
654
  # Returns an auto-generated project identifier based on the last identifier used
655
  def self.next_identifier
656
    p = Project.find(:first, :order => 'created_on DESC')
657
    p.nil? ? nil : p.identifier.to_s.succ
658
  end
659

  
660
  # Copies and saves the Project instance based on the +project+.
661
  # Duplicates the source project's:
662
  # * Wiki
663
  # * Versions
664
  # * Categories
665
  # * Issues
666
  # * Members
667
  # * Queries
668
  #
669
  # Accepts an +options+ argument to specify what to copy
670
  #
671
  # Examples:
672
  #   project.copy(1)                                    # => copies everything
673
  #   project.copy(1, :only => 'members')                # => copies members only
674
  #   project.copy(1, :only => ['members', 'versions'])  # => copies members and versions
675
  def copy(project, options={})
676
    project = project.is_a?(Project) ? project : Project.find(project)
677

  
678
    to_be_copied = %w(wiki versions issue_categories issues members queries boards)
679
    to_be_copied = to_be_copied & options[:only].to_a unless options[:only].nil?
680

  
681
    Project.transaction do
682
      if save
683
        reload
684
        to_be_copied.each do |name|
685
          send "copy_#{name}", project
686
        end
687
        Redmine::Hook.call_hook(:model_project_copy_before_save, :source_project => project, :destination_project => self)
688
        save
689
      end
690
    end
691
  end
692

  
693

  
694
  # Copies +project+ and returns the new instance.  This will not save
695
  # the copy
696
  def self.copy_from(project)
697
    begin
698
      project = project.is_a?(Project) ? project : Project.find(project)
699
      if project
700
        # clear unique attributes
701
        attributes = project.attributes.dup.except('id', 'name', 'identifier', 'status', 'parent_id', 'lft', 'rgt')
702
        copy = Project.new(attributes)
703
        copy.enabled_modules = project.enabled_modules
704
        copy.trackers = project.trackers
705
        copy.custom_values = project.custom_values.collect {|v| v.clone}
706
        copy.issue_custom_fields = project.issue_custom_fields
707
        return copy
708
      else
709
        return nil
710
      end
711
    rescue ActiveRecord::RecordNotFound
712
      return nil
713
    end
714
  end
715

  
716
  # Yields the given block for each project with its level in the tree
717
  def self.project_tree(projects, &block)
718
    ancestors = []
719
    projects.sort_by(&:lft).each do |project|
720
      while (ancestors.any? && !project.is_descendant_of?(ancestors.last))
721
        ancestors.pop
722
      end
723
      yield project, ancestors.size
724
      ancestors << project
725
    end
726
  end
727

  
728
  private
729

  
730
  # Copies wiki from +project+
731
  def copy_wiki(project)
732
    # Check that the source project has a wiki first
733
    unless project.wiki.nil?
734
      wiki = self.wiki || Wiki.new
735
      wiki.attributes = project.wiki.attributes.dup.except("id", "project_id")
736
      wiki_pages_map = {}
737
      project.wiki.pages.each do |page|
738
        # Skip pages without content
739
        next if page.content.nil?
740
        new_wiki_content = WikiContent.new(page.content.attributes.dup.except("id", "page_id", "updated_on"))
741
        new_wiki_page = WikiPage.new(page.attributes.dup.except("id", "wiki_id", "created_on", "parent_id"))
742
        new_wiki_page.content = new_wiki_content
743
        wiki.pages << new_wiki_page
744
        wiki_pages_map[page.id] = new_wiki_page
745
      end
746

  
747
      self.wiki = wiki
748
      wiki.save
749
      # Reproduce page hierarchy
750
      project.wiki.pages.each do |page|
751
        if page.parent_id && wiki_pages_map[page.id]
752
          wiki_pages_map[page.id].parent = wiki_pages_map[page.parent_id]
753
          wiki_pages_map[page.id].save
754
        end
755
      end
756
    end
757
  end
758

  
759
  # Copies versions from +project+
760
  def copy_versions(project)
761
    project.versions.each do |version|
762
      new_version = Version.new
763
      new_version.attributes = version.attributes.dup.except("id", "project_id", "created_on", "updated_on")
764
      self.versions << new_version
765
    end
766
  end
767

  
768
  # Copies issue categories from +project+
769
  def copy_issue_categories(project)
770
    project.issue_categories.each do |issue_category|
771
      new_issue_category = IssueCategory.new
772
      new_issue_category.attributes = issue_category.attributes.dup.except("id", "project_id")
773
      self.issue_categories << new_issue_category
774
    end
775
  end
776

  
777
  # Copies issues from +project+
778
  def copy_issues(project)
779
    # Stores the source issue id as a key and the copied issues as the
780
    # value.  Used to map the two togeather for issue relations.
781
    issues_map = {}
782

  
783
    # Store status and reopen locked/closed versions
784
    version_statuses = versions.reject(&:open?).map {|version| [version, version.status]}
785
    version_statuses.each do |version, status|
786
      version.update_attribute :status, 'open'
787
    end
788

  
789
    # Get issues sorted by root_id, lft so that parent issues
790
    # get copied before their children
791
    project.issues.find(:all, :order => 'root_id, lft').each do |issue|
792
      new_issue = Issue.new
793
      new_issue.copy_from(issue, :subtasks => false, :link => false)
794
      new_issue.project = self
795
      # Reassign fixed_versions by name, since names are unique per project
796
      if issue.fixed_version && issue.fixed_version.project == project
797
        new_issue.fixed_version = self.versions.detect {|v| v.name == issue.fixed_version.name}
798
      end
799
      # Reassign the category by name, since names are unique per project
800
      if issue.category
801
        new_issue.category = self.issue_categories.detect {|c| c.name == issue.category.name}
802
      end
803
      # Parent issue
804
      if issue.parent_id
805
        if copied_parent = issues_map[issue.parent_id]
806
          new_issue.parent_issue_id = copied_parent.id
807
        end
808
      end
809

  
810
      self.issues << new_issue
811
      if new_issue.new_record?
812
        logger.info "Project#copy_issues: issue ##{issue.id} could not be copied: #{new_issue.errors.full_messages}" if logger && logger.info
813
      else
814
        issues_map[issue.id] = new_issue unless new_issue.new_record?
815
      end
816
    end
817

  
818
    # Restore locked/closed version statuses
819
    version_statuses.each do |version, status|
820
      version.update_attribute :status, status
821
    end
822

  
823
    # Relations after in case issues related each other
824
    project.issues.each do |issue|
825
      new_issue = issues_map[issue.id]
826
      unless new_issue
827
        # Issue was not copied
828
        next
829
      end
830

  
831
      # Relations
832
      issue.relations_from.each do |source_relation|
833
        new_issue_relation = IssueRelation.new
834
        new_issue_relation.attributes = source_relation.attributes.dup.except("id", "issue_from_id", "issue_to_id")
835
        new_issue_relation.issue_to = issues_map[source_relation.issue_to_id]
836
        if new_issue_relation.issue_to.nil? && Setting.cross_project_issue_relations?
837
          new_issue_relation.issue_to = source_relation.issue_to
838
        end
839
        new_issue.relations_from << new_issue_relation
840
      end
841

  
842
      issue.relations_to.each do |source_relation|
843
        new_issue_relation = IssueRelation.new
844
        new_issue_relation.attributes = source_relation.attributes.dup.except("id", "issue_from_id", "issue_to_id")
845
        new_issue_relation.issue_from = issues_map[source_relation.issue_from_id]
846
        if new_issue_relation.issue_from.nil? && Setting.cross_project_issue_relations?
847
          new_issue_relation.issue_from = source_relation.issue_from
848
        end
849
        new_issue.relations_to << new_issue_relation
850
      end
851
    end
852
  end
853

  
854
  # Copies members from +project+
855
  def copy_members(project)
856
    # Copy users first, then groups to handle members with inherited and given roles
857
    members_to_copy = []
858
    members_to_copy += project.memberships.select {|m| m.principal.is_a?(User)}
859
    members_to_copy += project.memberships.select {|m| !m.principal.is_a?(User)}
860

  
861
    members_to_copy.each do |member|
862
      new_member = Member.new
863
      new_member.attributes = member.attributes.dup.except("id", "project_id", "created_on")
864
      # only copy non inherited roles
865
      # inherited roles will be added when copying the group membership
866
      role_ids = member.member_roles.reject(&:inherited?).collect(&:role_id)
867
      next if role_ids.empty?
868
      new_member.role_ids = role_ids
869
      new_member.project = self
870
      self.members << new_member
871
    end
872
  end
873

  
874
  # Copies queries from +project+
875
  def copy_queries(project)
876
    project.queries.each do |query|
877
      new_query = ::Query.new
878
      new_query.attributes = query.attributes.dup.except("id", "project_id", "sort_criteria")
879
      new_query.sort_criteria = query.sort_criteria if query.sort_criteria
880
      new_query.project = self
881
      new_query.user_id = query.user_id
882
      self.queries << new_query
883
    end
884
  end
885

  
886
  # Copies boards from +project+
887
  def copy_boards(project)
888
    project.boards.each do |board|
889
      new_board = Board.new
890
      new_board.attributes = board.attributes.dup.except("id", "project_id", "topics_count", "messages_count", "last_message_id")
891
      new_board.project = self
892
      self.boards << new_board
893
    end
894
  end
895

  
896
  def allowed_permissions
897
    @allowed_permissions ||= begin
898
      module_names = enabled_modules.all(:select => :name).collect {|m| m.name}
899
      Redmine::AccessControl.modules_permissions(module_names).collect {|p| p.name}
900
    end
901
  end
902

  
903
  def allowed_actions
904
    @actions_allowed ||= allowed_permissions.inject([]) { |actions, permission| actions += Redmine::AccessControl.allowed_actions(permission) }.flatten
905
  end
906

  
907
  # Returns all the active Systemwide and project specific activities
908
  def active_activities
909
    overridden_activity_ids = self.time_entry_activities.collect(&:parent_id)
910

  
911
    if overridden_activity_ids.empty?
912
      return TimeEntryActivity.shared.active
913
    else
914
      return system_activities_and_project_overrides
915
    end
916
  end
917

  
918
  # Returns all the Systemwide and project specific activities
919
  # (inactive and active)
920
  def all_activities
921
    overridden_activity_ids = self.time_entry_activities.collect(&:parent_id)
922

  
923
    if overridden_activity_ids.empty?
924
      return TimeEntryActivity.shared
925
    else
926
      return system_activities_and_project_overrides(true)
927
    end
928
  end
929

  
930
  # Returns the systemwide active activities merged with the project specific overrides
931
  def system_activities_and_project_overrides(include_inactive=false)
932
    if include_inactive
933
      return TimeEntryActivity.shared.
934
        find(:all,
935
             :conditions => ["id NOT IN (?)", self.time_entry_activities.collect(&:parent_id)]) +
936
        self.time_entry_activities
937
    else
938
      return TimeEntryActivity.shared.active.
939
        find(:all,
940
             :conditions => ["id NOT IN (?)", self.time_entry_activities.collect(&:parent_id)]) +
941
        self.time_entry_activities.active
942
    end
943
  end
944

  
945
  # Archives subprojects recursively
946
  def archive!
947
    children.each do |subproject|
948
      subproject.send :archive!
949
    end
950
    update_attribute :status, STATUS_ARCHIVED
951
  end
952

  
953
  def update_position_under_parent
954
    set_or_update_position_under(parent)
955
  end
956

  
957
  # Inserts/moves the project so that target's children or root projects stay alphabetically sorted
958
  def set_or_update_position_under(target_parent)
959
    sibs = (target_parent.nil? ? self.class.roots : target_parent.children)
960
    to_be_inserted_before = sibs.sort_by {|c| c.name.to_s.downcase}.detect {|c| c.name.to_s.downcase > name.to_s.downcase }
961

  
962
    if to_be_inserted_before
963
      move_to_left_of(to_be_inserted_before)
964
    elsif target_parent.nil?
965
      if sibs.empty?
966
        # move_to_root adds the project in first (ie. left) position
967
        move_to_root
968
      else
969
        move_to_right_of(sibs.last) unless self == sibs.last
970
      end
971
    else
972
      # move_to_child_of adds the project in last (ie.right) position
973
      move_to_child_of(target_parent)
974
    end
975
  end
976
end
.svn/pristine/a6/a6efcd2a9494eb4735ea6a6c086fa81d63854920.svn-base
1
# Russian localization for Ruby on Rails 2.2+
2
# by Yaroslav Markin <yaroslav@markin.net>
3
#
4
# Be sure to check out "russian" gem (http://github.com/yaroslav/russian) for
5
# full Russian language support in Rails (month names, pluralization, etc).
6
# The following is an excerpt from that gem.
7
#
8
# Для полноценной поддержки русского языка (варианты названий месяцев,
9
# плюрализация и так далее) в Rails 2.2 нужно использовать gem "russian"
10
# (http://github.com/yaroslav/russian). Следующие данные -- выдержка их него, чтобы
11
# была возможность минимальной локализации приложения на русский язык.
12

  
13
ru:
14
  direction: ltr
15
  date:
16
    formats:
17
      default: "%d.%m.%Y"
18
      short: "%d %b"
19
      long: "%d %B %Y"
20

  
21
    day_names: [воскресенье, понедельник, вторник, среда, четверг, пятница, суббота]
22
    standalone_day_names: [Воскресенье, Понедельник, Вторник, Среда, Четверг, Пятница, Суббота]
23
    abbr_day_names: [Вс, Пн, Вт, Ср, Чт, Пт, Сб]
24

  
25
    month_names: [~, января, февраля, марта, апреля, мая, июня, июля, августа, сентября, октября, ноября, декабря]
26
    # see russian gem for info on "standalone" day names
27
    standalone_month_names: [~, Январь, Февраль, Март, Апрель, Май, Июнь, Июль, Август, Сентябрь, Октябрь, Ноябрь, Декабрь]
28
    abbr_month_names: [~, янв., февр., марта, апр., мая, июня, июля, авг., сент., окт., нояб., дек.]
29
    standalone_abbr_month_names: [~, янв., февр., март, апр., май, июнь, июль, авг., сент., окт., нояб., дек.]
30

  
31
    order:
32
      - :day
33
      - :month
34
      - :year
35

  
36
  time:
37
    formats:
38
      default: "%a, %d %b %Y, %H:%M:%S %z"
39
      time: "%H:%M"
40
      short: "%d %b, %H:%M"
41
      long: "%d %B %Y, %H:%M"
42

  
43
    am: "утра"
44
    pm: "вечера"
45

  
46
  number:
47
    format:
48
      separator: ","
49
      delimiter: " "
50
      precision: 3
51

  
52
    currency:
53
      format:
54
        format: "%n %u"
55
        unit: "руб."
56
        separator: "."
57
        delimiter: " "
58
        precision: 2
59

  
60
    percentage:
61
      format:
62
        delimiter: ""
63

  
64
    precision:
65
      format:
66
        delimiter: ""
67

  
68
    human:
69
      format:
70
        delimiter: ""
71
        precision: 3
72
      # Rails 2.2
73
      # storage_units: [байт, КБ, МБ, ГБ, ТБ]
74

  
75
      # Rails 2.3
76
      storage_units:
77
        # Storage units output formatting.
78
        # %u is the storage unit, %n is the number (default: 2 MB)
79
        format: "%n %u"
80
        units:
81
          byte:
82
            one:   "байт"
83
            few:   "байта"
84
            many:  "байт"
85
            other: "байта"
86
          kb: "КБ"
87
          mb: "МБ"
88
          gb: "ГБ"
89
          tb: "ТБ"
90

  
91
  datetime:
92
    distance_in_words:
93
      half_a_minute: "меньше минуты"
94
      less_than_x_seconds:
95
        one:   "меньше %{count} секунды"
96
        few:   "меньше %{count} секунд"
97
        many:  "меньше %{count} секунд"
98
        other: "меньше %{count} секунды"
99
      x_seconds:
100
        one:   "%{count} секунда"
101
        few:   "%{count} секунды"
102
        many:  "%{count} секунд"
103
        other: "%{count} секунды"
104
      less_than_x_minutes:
105
        one:   "меньше %{count} минуты"
106
        few:   "меньше %{count} минут"
107
        many:  "меньше %{count} минут"
108
        other: "меньше %{count} минуты"
109
      x_minutes:
110
        one:   "%{count} минуту"
111
        few:   "%{count} минуты"
112
        many:  "%{count} минут"
113
        other: "%{count} минуты"
114
      about_x_hours:
115
        one:   "около %{count} часа"
116
        few:   "около %{count} часов"
117
        many:  "около %{count} часов"
118
        other: "около %{count} часа"
119
      x_hours:
120
        one:   "1 час"
121
        other: "%{count} часов"
122
      x_days:
123
        one:   "%{count} день"
124
        few:   "%{count} дня"
125
        many:  "%{count} дней"
126
        other: "%{count} дня"
127
      about_x_months:
128
        one:   "около %{count} месяца"
129
        few:   "около %{count} месяцев"
130
        many:  "около %{count} месяцев"
131
        other: "около %{count} месяца"
132
      x_months:
133
        one:   "%{count} месяц"
134
        few:   "%{count} месяца"
135
        many:  "%{count} месяцев"
136
        other: "%{count} месяца"
137
      about_x_years:
138
        one:   "около %{count} года"
139
        few:   "около %{count} лет"
140
        many:  "около %{count} лет"
141
        other: "около %{count} лет"
142
      over_x_years:
143
        one:   "больше %{count} года"
144
        few:   "больше %{count} лет"
145
        many:  "больше %{count} лет"
146
        other: "больше %{count} лет"
147
      almost_x_years:
148
        one:   "почти 1 год"
149
        few:   "почти %{count} года"
150
        many:  "почти %{count} лет"
151
        other: "почти %{count} года"
152
    prompts:
153
      year: "Год"
154
      month: "Месяц"
155
      day: "День"
156
      hour: "Часов"
157
      minute: "Минут"
158
      second: "Секунд"
159

  
160
  activerecord:
161
    errors:
162
      template:
163
        header:
164
          one:   "%{model}: сохранение не удалось из-за %{count} ошибки"
165
          few:   "%{model}: сохранение не удалось из-за %{count} ошибок"
166
          many:  "%{model}: сохранение не удалось из-за %{count} ошибок"
167
          other: "%{model}: сохранение не удалось из-за %{count} ошибки"
168

  
169
        body: "Проблемы возникли со следующими полями:"
170

  
171
      messages:
172
        inclusion: "имеет непредусмотренное значение"
173
        exclusion: "имеет зарезервированное значение"
174
        invalid: "имеет неверное значение"
175
        confirmation: "не совпадает с подтверждением"
176
        accepted: "нужно подтвердить"
177
        empty: "не может быть пустым"
178
        blank: "не может быть пустым"
179
        too_long:
180
          one:   "слишком большой длины (не может быть больше чем %{count} символ)"
181
          few:   "слишком большой длины (не может быть больше чем %{count} символа)"
182
          many:  "слишком большой длины (не может быть больше чем %{count} символов)"
183
          other: "слишком большой длины (не может быть больше чем %{count} символа)"
184
        too_short:
185
          one:   "недостаточной длины (не может быть меньше %{count} символа)"
186
          few:   "недостаточной длины (не может быть меньше %{count} символов)"
187
          many:  "недостаточной длины (не может быть меньше %{count} символов)"
188
          other: "недостаточной длины (не может быть меньше %{count} символа)"
189
        wrong_length:
190
          one:   "неверной длины (может быть длиной ровно %{count} символ)"
191
          few:   "неверной длины (может быть длиной ровно %{count} символа)"
192
          many:  "неверной длины (может быть длиной ровно %{count} символов)"
193
          other: "неверной длины (может быть длиной ровно %{count} символа)"
194
        taken: "уже существует"
195
        not_a_number: "не является числом"
196
        greater_than: "может иметь значение большее %{count}"
197
        greater_than_or_equal_to: "может иметь значение большее или равное %{count}"
198
        equal_to: "может иметь лишь значение, равное %{count}"
199
        less_than: "может иметь значение меньшее чем %{count}"
200
        less_than_or_equal_to: "может иметь значение меньшее или равное %{count}"
201
        odd: "может иметь лишь нечетное значение"
202
        even: "может иметь лишь четное значение"
203
        greater_than_start_date: "должна быть позднее даты начала"
204
        not_same_project: "не относится к одному проекту"
205
        circular_dependency: "Такая связь приведет к циклической зависимости"
206
        cant_link_an_issue_with_a_descendant: "Задача не может быть связана со своей подзадачей"
207

  
208
  support:
209
    array:
210
      # Rails 2.2
211
      sentence_connector: "и"
212
      skip_last_comma: true
213

  
214
      # Rails 2.3
215
      words_connector: ", "
216
      two_words_connector: " и "
217
      last_word_connector: " и "
218

  
219
  actionview_instancetag_blank_option: Выберите
220

  
221
  button_activate: Активировать
222
  button_add: Добавить
223
  button_annotate: Авторство
224
  button_apply: Применить
225
  button_archive: Архивировать
226
  button_back: Назад
227
  button_cancel: Отмена
228
  button_change_password: Изменить пароль
229
  button_change: Изменить
230
  button_check_all: Отметить все
231
  button_clear: Очистить
232
  button_configure: Параметры
233
  button_copy: Копировать
234
  button_create: Создать
235
  button_create_and_continue: Создать и продолжить
236
  button_delete: Удалить
237
  button_download: Загрузить
238
  button_edit: Редактировать
239
  button_edit_associated_wikipage: "Редактировать связанную wiki-страницу: %{page_title}"
240
  button_list: Список
241
  button_lock: Заблокировать
242
  button_login: Вход
243
  button_log_time: Затраченное время
244
  button_move: Переместить
245
  button_quote: Цитировать
246
  button_rename: Переименовать
247
  button_reply: Ответить
248
  button_reset: Сбросить
249
  button_rollback: Вернуться к данной версии
250
  button_save: Сохранить
251
  button_sort: Сортировать
252
  button_submit: Принять
253
  button_test: Проверить
254
  button_unarchive: Разархивировать
255
  button_uncheck_all: Очистить
256
  button_unlock: Разблокировать
257
  button_unwatch: Не следить
258
  button_update: Обновить
259
  button_view: Просмотреть
260
  button_watch: Следить
261

  
262
  default_activity_design: Проектирование
263
  default_activity_development: Разработка
264
  default_doc_category_tech: Техническая документация
265
  default_doc_category_user: Пользовательская документация
266
  default_issue_status_in_progress: В работе
267
  default_issue_status_closed: Закрыта
268
  default_issue_status_feedback: Обратная связь
269
  default_issue_status_new: Новая
270
  default_issue_status_rejected: Отклонена
271
  default_issue_status_resolved: Решена
272
  default_priority_high: Высокий
273
  default_priority_immediate: Немедленный
274
  default_priority_low: Низкий
275
  default_priority_normal: Нормальный
276
  default_priority_urgent: Срочный
277
  default_role_developer: Разработчик
278
  default_role_manager: Менеджер
279
  default_role_reporter: Репортёр
280
  default_tracker_bug: Ошибка
281
  default_tracker_feature: Улучшение
282
  default_tracker_support: Поддержка
283

  
284
  enumeration_activities: Действия (учёт времени)
285
  enumeration_doc_categories: Категории документов
286
  enumeration_issue_priorities: Приоритеты задач
287

  
288
  error_can_not_remove_role: Эта роль используется и не может быть удалена.
289
  error_can_not_delete_custom_field: Невозможно удалить настраиваемое поле
290
  error_can_not_delete_tracker: Этот трекер содержит задачи и не может быть удален.
291
  error_can_t_load_default_data: "Конфигурация по умолчанию не была загружена: %{value}"
292
  error_issue_not_found_in_project: Задача не была найдена или не прикреплена к этому проекту
293
  error_scm_annotate: "Данные отсутствуют или не могут быть подписаны."
294
  error_scm_command_failed: "Ошибка доступа к хранилищу: %{value}"
295
  error_scm_not_found: Хранилище не содержит записи и/или исправления.
296
  error_unable_to_connect: Невозможно подключиться (%{value})
297
  error_unable_delete_issue_status: Невозможно удалить статус задачи
298

  
299
  field_account: Учётная запись
300
  field_activity: Деятельность
301
  field_admin: Администратор
302
  field_assignable: Задача может быть назначена этой роли
303
  field_assigned_to: Назначена
304
  field_attr_firstname: Имя
305
  field_attr_lastname: Фамилия
306
  field_attr_login: Атрибут Login
307
  field_attr_mail: email
308
  field_author: Автор
309
  field_auth_source: Режим аутентификации
310
  field_base_dn: BaseDN
311
  field_category: Категория
312
  field_column_names: Столбцы
313
  field_comments: Комментарий
314
  field_comments_sorting: Отображение комментариев
315
  field_content: Content
316
  field_created_on: Создано
317
  field_default_value: Значение по умолчанию
318
  field_delay: Отложить
319
  field_description: Описание
320
  field_done_ratio: Готовность
321
  field_downloads: Загрузки
322
  field_due_date: Дата выполнения
323
  field_editable: Редактируемое
324
  field_effective_date: Дата
325
  field_estimated_hours: Оценка времени
326
  field_field_format: Формат
327
  field_filename: Файл
328
  field_filesize: Размер
329
  field_firstname: Имя
330
  field_fixed_version: Версия
331
  field_hide_mail: Скрывать мой email
332
  field_homepage: Стартовая страница
333
  field_host: Компьютер
334
  field_hours: час(а,ов)
335
  field_identifier: Уникальный идентификатор
336
  field_identity_url: OpenID URL
337
  field_is_closed: Задача закрыта
338
  field_is_default: Значение по умолчанию
339
  field_is_filter: Используется в качестве фильтра
340
  field_is_for_all: Для всех проектов
341
  field_is_in_roadmap: Задачи, отображаемые в оперативном плане
342
  field_is_public: Общедоступный
343
  field_is_required: Обязательное
344
  field_issue_to: Связанные задачи
345
  field_issue: Задача
346
  field_language: Язык
347
  field_last_login_on: Последнее подключение
348
  field_lastname: Фамилия
349
  field_login: Пользователь
350
  field_mail: Email
351
  field_mail_notification: Уведомления по email
352
  field_max_length: Максимальная длина
353
  field_min_length: Минимальная длина
354
  field_name: Имя
355
  field_new_password: Новый пароль
356
  field_notes: Примечания
357
  field_onthefly: Создание пользователя на лету
358
  field_parent_title: Родительская страница
359
  field_parent: Родительский проект
360
  field_parent_issue: Родительская задача
361
  field_password_confirmation: Подтверждение
362
  field_password: Пароль
363
  field_port: Порт
364
  field_possible_values: Возможные значения
365
  field_priority: Приоритет
366
  field_project: Проект
367
  field_redirect_existing_links: Перенаправить существующие ссылки
368
  field_regexp: Регулярное выражение
369
  field_role: Роль
370
  field_searchable: Доступно для поиска
371
  field_spent_on: Дата
372
  field_start_date: Начата
373
  field_start_page: Стартовая страница
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff