Revision 912:5e80956cc792 .svn/pristine/11

View differences:

.svn/pristine/11/111782291673fa0d25a1477bea1c5d346d154c35.svn-base
1
# Copyright (c) 2009 Michael Koziarski <michael@koziarski.com>
2
# 
3
# Permission to use, copy, modify, and/or distribute this software for any
4
# purpose with or without fee is hereby granted, provided that the above
5
# copyright notice and this permission notice appear in all copies.
6
# 
7
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
8
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
9
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
10
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
11
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
12
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
13
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
14

  
15
require 'bigdecimal'
16

  
17
alias BigDecimalUnsafe BigDecimal
18

  
19

  
20
# This fixes CVE-2009-1904 however it removes legitimate functionality that your
21
# application may depend on.  You are *strongly* advised to upgrade your ruby
22
# rather than relying on this fix for an extended period of time.
23

  
24
def BigDecimal(initial, digits=0)
25
  if initial.size > 255 || initial =~ /e/i
26
    raise "Invalid big Decimal Value"
27
  end
28
  BigDecimalUnsafe(initial, digits)
29
end
30

  
.svn/pristine/11/1126b71d1361e2719f05011613589ea2d0df072c.svn-base
1
# Copyright (c) 2005 Rick Olson
2
# 
3
# Permission is hereby granted, free of charge, to any person obtaining
4
# a copy of this software and associated documentation files (the
5
# "Software"), to deal in the Software without restriction, including
6
# without limitation the rights to use, copy, modify, merge, publish,
7
# distribute, sublicense, and/or sell copies of the Software, and to
8
# permit persons to whom the Software is furnished to do so, subject to
9
# the following conditions:
10
# 
11
# The above copyright notice and this permission notice shall be
12
# included in all copies or substantial portions of the Software.
13
# 
14
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21

  
22
module ActiveRecord #:nodoc:
23
  module Acts #:nodoc:
24
    # Specify this act if you want to save a copy of the row in a versioned table.  This assumes there is a 
25
    # versioned table ready and that your model has a version field.  This works with optimistic locking if the lock_version
26
    # column is present as well.
27
    #
28
    # The class for the versioned model is derived the first time it is seen. Therefore, if you change your database schema you have to restart
29
    # your container for the changes to be reflected. In development mode this usually means restarting WEBrick.
30
    #
31
    #   class Page < ActiveRecord::Base
32
    #     # assumes pages_versions table
33
    #     acts_as_versioned
34
    #   end
35
    #
36
    # Example:
37
    #
38
    #   page = Page.create(:title => 'hello world!')
39
    #   page.version       # => 1
40
    #
41
    #   page.title = 'hello world'
42
    #   page.save
43
    #   page.version       # => 2
44
    #   page.versions.size # => 2
45
    #
46
    #   page.revert_to(1)  # using version number
47
    #   page.title         # => 'hello world!'
48
    #
49
    #   page.revert_to(page.versions.last) # using versioned instance
50
    #   page.title         # => 'hello world'
51
    #
52
    #   page.versions.earliest # efficient query to find the first version
53
    #   page.versions.latest   # efficient query to find the most recently created version
54
    #
55
    #
56
    # Simple Queries to page between versions
57
    #
58
    #   page.versions.before(version) 
59
    #   page.versions.after(version)
60
    #
61
    # Access the previous/next versions from the versioned model itself
62
    #
63
    #   version = page.versions.latest
64
    #   version.previous # go back one version
65
    #   version.next     # go forward one version
66
    #
67
    # See ActiveRecord::Acts::Versioned::ClassMethods#acts_as_versioned for configuration options
68
    module Versioned
69
      CALLBACKS = [:set_new_version, :save_version_on_create, :save_version?, :clear_altered_attributes]
70
      def self.included(base) # :nodoc:
71
        base.extend ClassMethods
72
      end
73

  
74
      module ClassMethods
75
        # == Configuration options
76
        #
77
        # * <tt>class_name</tt> - versioned model class name (default: PageVersion in the above example)
78
        # * <tt>table_name</tt> - versioned model table name (default: page_versions in the above example)
79
        # * <tt>foreign_key</tt> - foreign key used to relate the versioned model to the original model (default: page_id in the above example)
80
        # * <tt>inheritance_column</tt> - name of the column to save the model's inheritance_column value for STI.  (default: versioned_type)
81
        # * <tt>version_column</tt> - name of the column in the model that keeps the version number (default: version)
82
        # * <tt>sequence_name</tt> - name of the custom sequence to be used by the versioned model.
83
        # * <tt>limit</tt> - number of revisions to keep, defaults to unlimited
84
        # * <tt>if</tt> - symbol of method to check before saving a new version.  If this method returns false, a new version is not saved.
85
        #   For finer control, pass either a Proc or modify Model#version_condition_met?
86
        #
87
        #     acts_as_versioned :if => Proc.new { |auction| !auction.expired? }
88
        #
89
        #   or...
90
        #
91
        #     class Auction
92
        #       def version_condition_met? # totally bypasses the <tt>:if</tt> option
93
        #         !expired?
94
        #       end
95
        #     end
96
        #
97
        # * <tt>if_changed</tt> - Simple way of specifying attributes that are required to be changed before saving a model.  This takes
98
        #   either a symbol or array of symbols.  WARNING - This will attempt to overwrite any attribute setters you may have.
99
        #   Use this instead if you want to write your own attribute setters (and ignore if_changed):
100
        # 
101
        #     def name=(new_name)
102
        #       write_changed_attribute :name, new_name
103
        #     end
104
        #
105
        # * <tt>extend</tt> - Lets you specify a module to be mixed in both the original and versioned models.  You can also just pass a block
106
        #   to create an anonymous mixin:
107
        #
108
        #     class Auction
109
        #       acts_as_versioned do
110
        #         def started?
111
        #           !started_at.nil?
112
        #         end
113
        #       end
114
        #     end
115
        #
116
        #   or...
117
        #
118
        #     module AuctionExtension
119
        #       def started?
120
        #         !started_at.nil?
121
        #       end
122
        #     end
123
        #     class Auction
124
        #       acts_as_versioned :extend => AuctionExtension
125
        #     end
126
        #
127
        #  Example code:
128
        #
129
        #    @auction = Auction.find(1)
130
        #    @auction.started?
131
        #    @auction.versions.first.started?
132
        #
133
        # == Database Schema
134
        #
135
        # The model that you're versioning needs to have a 'version' attribute. The model is versioned 
136
        # into a table called #{model}_versions where the model name is singlular. The _versions table should 
137
        # contain all the fields you want versioned, the same version column, and a #{model}_id foreign key field.
138
        #
139
        # A lock_version field is also accepted if your model uses Optimistic Locking.  If your table uses Single Table inheritance,
140
        # then that field is reflected in the versioned model as 'versioned_type' by default.
141
        #
142
        # Acts_as_versioned comes prepared with the ActiveRecord::Acts::Versioned::ActMethods::ClassMethods#create_versioned_table 
143
        # method, perfect for a migration.  It will also create the version column if the main model does not already have it.
144
        #
145
        #   class AddVersions < ActiveRecord::Migration
146
        #     def self.up
147
        #       # create_versioned_table takes the same options hash
148
        #       # that create_table does
149
        #       Post.create_versioned_table
150
        #     end
151
        # 
152
        #     def self.down
153
        #       Post.drop_versioned_table
154
        #     end
155
        #   end
156
        # 
157
        # == Changing What Fields Are Versioned
158
        #
159
        # By default, acts_as_versioned will version all but these fields: 
160
        # 
161
        #   [self.primary_key, inheritance_column, 'version', 'lock_version', versioned_inheritance_column]
162
        #
163
        # You can add or change those by modifying #non_versioned_columns.  Note that this takes strings and not symbols.
164
        #
165
        #   class Post < ActiveRecord::Base
166
        #     acts_as_versioned
167
        #     self.non_versioned_columns << 'comments_count'
168
        #   end
169
        # 
170
        def acts_as_versioned(options = {}, &extension)
171
          # don't allow multiple calls
172
          return if self.included_modules.include?(ActiveRecord::Acts::Versioned::ActMethods)
173

  
174
          send :include, ActiveRecord::Acts::Versioned::ActMethods
175

  
176
          cattr_accessor :versioned_class_name, :versioned_foreign_key, :versioned_table_name, :versioned_inheritance_column, 
177
            :version_column, :max_version_limit, :track_altered_attributes, :version_condition, :version_sequence_name, :non_versioned_columns,
178
            :version_association_options
179

  
180
          # legacy
181
          alias_method :non_versioned_fields,  :non_versioned_columns
182
          alias_method :non_versioned_fields=, :non_versioned_columns=
183

  
184
          class << self
185
            alias_method :non_versioned_fields,  :non_versioned_columns
186
            alias_method :non_versioned_fields=, :non_versioned_columns=
187
          end
188

  
189
          send :attr_accessor, :altered_attributes
190

  
191
          self.versioned_class_name         = options[:class_name]  || "Version"
192
          self.versioned_foreign_key        = options[:foreign_key] || self.to_s.foreign_key
193
          self.versioned_table_name         = options[:table_name]  || "#{table_name_prefix}#{base_class.name.demodulize.underscore}_versions#{table_name_suffix}"
194
          self.versioned_inheritance_column = options[:inheritance_column] || "versioned_#{inheritance_column}"
195
          self.version_column               = options[:version_column]     || 'version'
196
          self.version_sequence_name        = options[:sequence_name]
197
          self.max_version_limit            = options[:limit].to_i
198
          self.version_condition            = options[:if] || true
199
          self.non_versioned_columns        = [self.primary_key, inheritance_column, 'version', 'lock_version', versioned_inheritance_column]
200
          self.version_association_options  = {
201
                                                :class_name  => "#{self.to_s}::#{versioned_class_name}",
202
                                                :foreign_key => versioned_foreign_key,
203
                                                :dependent   => :delete_all
204
                                              }.merge(options[:association_options] || {})
205

  
206
          if block_given?
207
            extension_module_name = "#{versioned_class_name}Extension"
208
            silence_warnings do
209
              self.const_set(extension_module_name, Module.new(&extension))
210
            end
211

  
212
            options[:extend] = self.const_get(extension_module_name)
213
          end
214

  
215
          class_eval do
216
            has_many :versions, version_association_options do
217
              # finds earliest version of this record
218
              def earliest
219
                @earliest ||= find(:first, :order => 'version')
220
              end
221

  
222
              # find latest version of this record
223
              def latest
224
                @latest ||= find(:first, :order => 'version desc')
225
              end
226
            end
227
            before_save  :set_new_version
228
            after_create :save_version_on_create
229
            after_update :save_version
230
            after_save   :clear_old_versions
231
            after_save   :clear_altered_attributes
232

  
233
            unless options[:if_changed].nil?
234
              self.track_altered_attributes = true
235
              options[:if_changed] = [options[:if_changed]] unless options[:if_changed].is_a?(Array)
236
              options[:if_changed].each do |attr_name|
237
                define_method("#{attr_name}=") do |value|
238
                  write_changed_attribute attr_name, value
239
                end
240
              end
241
            end
242

  
243
            include options[:extend] if options[:extend].is_a?(Module)
244
          end
245

  
246
          # create the dynamic versioned model
247
          const_set(versioned_class_name, Class.new(ActiveRecord::Base)).class_eval do
248
            def self.reloadable? ; false ; end
249
            # find first version before the given version
250
            def self.before(version)
251
              find :first, :order => 'version desc',
252
                :conditions => ["#{original_class.versioned_foreign_key} = ? and version < ?", version.send(original_class.versioned_foreign_key), version.version]
253
            end
254

  
255
            # find first version after the given version.
256
            def self.after(version)
257
              find :first, :order => 'version',
258
                :conditions => ["#{original_class.versioned_foreign_key} = ? and version > ?", version.send(original_class.versioned_foreign_key), version.version]
259
            end
260

  
261
            def previous
262
              self.class.before(self)
263
            end
264

  
265
            def next
266
              self.class.after(self)
267
            end
268

  
269
            def versions_count
270
              page.version
271
            end
272
          end
273

  
274
          versioned_class.cattr_accessor :original_class
275
          versioned_class.original_class = self
276
          versioned_class.set_table_name versioned_table_name
277
          versioned_class.belongs_to self.to_s.demodulize.underscore.to_sym, 
278
            :class_name  => "::#{self.to_s}", 
279
            :foreign_key => versioned_foreign_key
280
          versioned_class.send :include, options[:extend]         if options[:extend].is_a?(Module)
281
          versioned_class.set_sequence_name version_sequence_name if version_sequence_name
282
        end
283
      end
284

  
285
      module ActMethods
286
        def self.included(base) # :nodoc:
287
          base.extend ClassMethods
288
        end
289

  
290
        # Finds a specific version of this record
291
        def find_version(version = nil)
292
          self.class.find_version(id, version)
293
        end
294

  
295
        # Saves a version of the model if applicable
296
        def save_version
297
          save_version_on_create if save_version?
298
        end
299

  
300
        # Saves a version of the model in the versioned table.  This is called in the after_save callback by default
301
        def save_version_on_create
302
          rev = self.class.versioned_class.new
303
          self.clone_versioned_model(self, rev)
304
          rev.version = send(self.class.version_column)
305
          rev.send("#{self.class.versioned_foreign_key}=", self.id)
306
          rev.save
307
        end
308

  
309
        # Clears old revisions if a limit is set with the :limit option in <tt>acts_as_versioned</tt>.
310
        # Override this method to set your own criteria for clearing old versions.
311
        def clear_old_versions
312
          return if self.class.max_version_limit == 0
313
          excess_baggage = send(self.class.version_column).to_i - self.class.max_version_limit
314
          if excess_baggage > 0
315
            sql = "DELETE FROM #{self.class.versioned_table_name} WHERE version <= #{excess_baggage} AND #{self.class.versioned_foreign_key} = #{self.id}"
316
            self.class.versioned_class.connection.execute sql
317
          end
318
        end
319

  
320
        def versions_count
321
          version
322
        end
323

  
324
        # Reverts a model to a given version.  Takes either a version number or an instance of the versioned model
325
        def revert_to(version)
326
          if version.is_a?(self.class.versioned_class)
327
            return false unless version.send(self.class.versioned_foreign_key) == self.id and !version.new_record?
328
          else
329
            return false unless version = versions.find_by_version(version)
330
          end
331
          self.clone_versioned_model(version, self)
332
          self.send("#{self.class.version_column}=", version.version)
333
          true
334
        end
335

  
336
        # Reverts a model to a given version and saves the model.
337
        # Takes either a version number or an instance of the versioned model
338
        def revert_to!(version)
339
          revert_to(version) ? save_without_revision : false
340
        end
341

  
342
        # Temporarily turns off Optimistic Locking while saving.  Used when reverting so that a new version is not created.
343
        def save_without_revision
344
          save_without_revision!
345
          true
346
        rescue
347
          false
348
        end
349

  
350
        def save_without_revision!
351
          without_locking do
352
            without_revision do
353
              save!
354
            end
355
          end
356
        end
357

  
358
        # Returns an array of attribute keys that are versioned.  See non_versioned_columns
359
        def versioned_attributes
360
          self.attributes.keys.select { |k| !self.class.non_versioned_columns.include?(k) }
361
        end
362

  
363
        # If called with no parameters, gets whether the current model has changed and needs to be versioned.
364
        # If called with a single parameter, gets whether the parameter has changed.
365
        def changed?(attr_name = nil)
366
          attr_name.nil? ?
367
            (!self.class.track_altered_attributes || (altered_attributes && altered_attributes.length > 0)) :
368
            (altered_attributes && altered_attributes.include?(attr_name.to_s))
369
        end
370

  
371
        # keep old dirty? method
372
        alias_method :dirty?, :changed?
373

  
374
        # Clones a model.  Used when saving a new version or reverting a model's version.
375
        def clone_versioned_model(orig_model, new_model)
376
          self.versioned_attributes.each do |key|
377
            new_model.send("#{key}=", orig_model.send(key)) if orig_model.has_attribute?(key)
378
          end
379

  
380
          if orig_model.is_a?(self.class.versioned_class)
381
            new_model[new_model.class.inheritance_column] = orig_model[self.class.versioned_inheritance_column]
382
          elsif new_model.is_a?(self.class.versioned_class)
383
            new_model[self.class.versioned_inheritance_column] = orig_model[orig_model.class.inheritance_column]
384
          end
385
        end
386

  
387
        # Checks whether a new version shall be saved or not.  Calls <tt>version_condition_met?</tt> and <tt>changed?</tt>.
388
        def save_version?
389
          version_condition_met? && changed?
390
        end
391

  
392
        # Checks condition set in the :if option to check whether a revision should be created or not.  Override this for
393
        # custom version condition checking.
394
        def version_condition_met?
395
          case
396
          when version_condition.is_a?(Symbol)
397
            send(version_condition)
398
          when version_condition.respond_to?(:call) && (version_condition.arity == 1 || version_condition.arity == -1)
399
            version_condition.call(self)
400
          else
401
            version_condition
402
          end
403
        end
404

  
405
        # Executes the block with the versioning callbacks disabled.
406
        #
407
        #   @foo.without_revision do
408
        #     @foo.save
409
        #   end
410
        #
411
        def without_revision(&block)
412
          self.class.without_revision(&block)
413
        end
414

  
415
        # Turns off optimistic locking for the duration of the block
416
        #
417
        #   @foo.without_locking do
418
        #     @foo.save
419
        #   end
420
        #
421
        def without_locking(&block)
422
          self.class.without_locking(&block)
423
        end
424

  
425
        def empty_callback() end #:nodoc:
426

  
427
        protected
428
          # sets the new version before saving, unless you're using optimistic locking.  In that case, let it take care of the version.
429
          def set_new_version
430
            self.send("#{self.class.version_column}=", self.next_version) if new_record? || (!locking_enabled? && save_version?)
431
          end
432

  
433
          # Gets the next available version for the current record, or 1 for a new record
434
          def next_version
435
            return 1 if new_record?
436
            (versions.calculate(:max, :version) || 0) + 1
437
          end
438

  
439
          # clears current changed attributes.  Called after save.
440
          def clear_altered_attributes
441
            self.altered_attributes = []
442
          end
443

  
444
          def write_changed_attribute(attr_name, attr_value)
445
            # Convert to db type for comparison. Avoids failing Float<=>String comparisons.
446
            attr_value_for_db = self.class.columns_hash[attr_name.to_s].type_cast(attr_value)
447
            (self.altered_attributes ||= []) << attr_name.to_s unless self.changed?(attr_name) || self.send(attr_name) == attr_value_for_db
448
            write_attribute(attr_name, attr_value_for_db)
449
          end
450

  
451
        module ClassMethods
452
          # Finds a specific version of a specific row of this model
453
          def find_version(id, version = nil)
454
            return find(id) unless version
455

  
456
            conditions = ["#{versioned_foreign_key} = ? AND version = ?", id, version]
457
            options = { :conditions => conditions, :limit => 1 }
458

  
459
            if result = find_versions(id, options).first
460
              result
461
            else
462
              raise RecordNotFound, "Couldn't find #{name} with ID=#{id} and VERSION=#{version}"
463
            end
464
          end
465

  
466
          # Finds versions of a specific model.  Takes an options hash like <tt>find</tt>
467
          def find_versions(id, options = {})
468
            versioned_class.find :all, {
469
              :conditions => ["#{versioned_foreign_key} = ?", id],
470
              :order      => 'version' }.merge(options)
471
          end
472

  
473
          # Returns an array of columns that are versioned.  See non_versioned_columns
474
          def versioned_columns
475
            self.columns.select { |c| !non_versioned_columns.include?(c.name) }
476
          end
477

  
478
          # Returns an instance of the dynamic versioned model
479
          def versioned_class
480
            const_get versioned_class_name
481
          end
482

  
483
          # Rake migration task to create the versioned table using options passed to acts_as_versioned
484
          def create_versioned_table(create_table_options = {})
485
            # create version column in main table if it does not exist
486
            if !self.content_columns.find { |c| %w(version lock_version).include? c.name }
487
              self.connection.add_column table_name, :version, :integer
488
            end
489

  
490
            self.connection.create_table(versioned_table_name, create_table_options) do |t|
491
              t.column versioned_foreign_key, :integer
492
              t.column :version, :integer
493
            end
494

  
495
            updated_col = nil
496
            self.versioned_columns.each do |col| 
497
              updated_col = col if !updated_col && %(updated_at updated_on).include?(col.name)
498
              self.connection.add_column versioned_table_name, col.name, col.type, 
499
                :limit => col.limit, 
500
                :default => col.default,
501
                :scale => col.scale,
502
                :precision => col.precision
503
            end
504

  
505
            if type_col = self.columns_hash[inheritance_column]
506
              self.connection.add_column versioned_table_name, versioned_inheritance_column, type_col.type, 
507
                :limit => type_col.limit, 
508
                :default => type_col.default,
509
                :scale => type_col.scale,
510
                :precision => type_col.precision
511
            end
512

  
513
            if updated_col.nil?
514
              self.connection.add_column versioned_table_name, :updated_at, :timestamp
515
            end
516
          end
517

  
518
          # Rake migration task to drop the versioned table
519
          def drop_versioned_table
520
            self.connection.drop_table versioned_table_name
521
          end
522

  
523
          # Executes the block with the versioning callbacks disabled.
524
          #
525
          #   Foo.without_revision do
526
          #     @foo.save
527
          #   end
528
          #
529
          def without_revision(&block)
530
            class_eval do 
531
              CALLBACKS.each do |attr_name|
532
                alias_method "orig_#{attr_name}".to_sym, attr_name
533
                alias_method attr_name, :empty_callback
534
              end
535
            end
536
            block.call
537
          ensure
538
            class_eval do 
539
              CALLBACKS.each do |attr_name|
540
                alias_method attr_name, "orig_#{attr_name}".to_sym
541
              end
542
            end
543
          end
544

  
545
          # Turns off optimistic locking for the duration of the block
546
          #
547
          #   Foo.without_locking do
548
          #     @foo.save
549
          #   end
550
          #
551
          def without_locking(&block)
552
            current = ActiveRecord::Base.lock_optimistically
553
            ActiveRecord::Base.lock_optimistically = false if current
554
            result = block.call
555
            ActiveRecord::Base.lock_optimistically = true if current
556
            result
557
          end
558
        end
559
      end
560
    end
561
  end
562
end
563

  
564
ActiveRecord::Base.send :include, ActiveRecord::Acts::Versioned
.svn/pristine/11/114393c547ad97cfcaa80a6e77c3315b6cf82431.svn-base
1
module MailHelper
2
  def do_something_helpful(var)
3
    var.to_s.reverse
4
  end
5
end
.svn/pristine/11/114804002a97fae230bf3b7bfcc60886698c2dd0.svn-base
1
<% if @deliveries %>
2
<% form_tag({:action => 'edit', :tab => 'notifications'}) do %>
3

  
4
<div class="box tabular settings">
5
<p><%= setting_text_field :mail_from, :size => 60 %></p>
6

  
7
<p><%= setting_check_box :bcc_recipients %></p>
8

  
9
<p><%= setting_check_box :plain_text_mail %></p>
10

  
11
<p><%= setting_select(:default_notification_option, User.valid_notification_options.collect {|o| [l(o.last), o.first.to_s]}) %></p>
12

  
13
</div>
14

  
15
<fieldset class="box" id="notified_events"><legend><%=l(:text_select_mail_notifications)%></legend>
16
<%= hidden_field_tag 'settings[notified_events][]', '' %>
17
<% @notifiables.each do |notifiable| %>
18
<%= notification_field notifiable %>
19
<br />
20
<% end %>
21
<p><%= check_all_links('notified_events') %></p>
22
</fieldset>
23

  
24
<fieldset class="box"><legend><%= l(:setting_emails_header) %></legend>
25
<%= setting_text_area :emails_header, :label => false, :class => 'wiki-edit', :rows => 5 %>
26
</fieldset>
27

  
28
<fieldset class="box"><legend><%= l(:setting_emails_footer) %></legend>
29
<%= setting_text_area :emails_footer, :label => false, :class => 'wiki-edit', :rows => 5 %>
30
</fieldset>
31

  
32
<div style="float:right;">
33
<%= link_to l(:label_send_test_email), :controller => 'admin', :action => 'test_email' %>
34
</div>
35

  
36
<%= submit_tag l(:button_save) %>
37
<% end %>
38
<% else %>
39
<div class="nodata">
40
<%= simple_format(l(:text_email_delivery_not_configured)) %>
41
</div>
42
<% end %>
.svn/pristine/11/114bca33e13814e69bb30791d00e3851d89cb11c.svn-base
1
documents_001: 
2
  created_on: 2007-01-27 15:08:27 +01:00
3
  project_id: 1
4
  title: "Test document"
5
  id: 1
6
  description: "Document description"
7
  category_id: 1
8
documents_002: 
9
  created_on: 2007-02-12 15:08:27 +01:00
10
  project_id: 1
11
  title: "An other document"
12
  id: 2
13
  description: ""
14
  category_id: 1
.svn/pristine/11/116cfd340b5f6c9c6323607765d15102ca0bece3.svn-base
1
class IssueStartDate < ActiveRecord::Migration
2
  def self.up
3
    add_column :issues, :start_date, :date
4
    add_column :issues, :done_ratio, :integer, :default => 0, :null => false
5
  end
6

  
7
  def self.down
8
    remove_column :issues, :start_date
9
    remove_column :issues, :done_ratio
10
  end
11
end
.svn/pristine/11/119d49f6464bf67d20c576180ecf3171b1346824.svn-base
1
// ** I18N
2

  
3
// Calendar EN language
4
// Author: Gampol Thitinilnithi, <gampolt@gmail.com>
5
// Encoding: UTF-8
6
// Distributed under the same terms as the calendar itself.
7

  
8
// For translators: please use UTF-8 if possible.  We strongly believe that
9
// Unicode is the answer to a real internationalized world.  Also please
10
// include your contact information in the header, as can be seen above.
11

  
12
// full day names
13
Calendar._DN = new Array
14
("อาทิตย์",
15
 "จันทร์",
16
 "อังคาร",
17
 "พุธ",
18
 "พฤหัสบดี",
19
 "ศุกร์",
20
 "เสาร์",
21
 "อาทิตย์");
22

  
23
// Please note that the following array of short day names (and the same goes
24
// for short month names, _SMN) isn't absolutely necessary.  We give it here
25
// for exemplification on how one can customize the short day names, but if
26
// they are simply the first N letters of the full name you can simply say:
27
//
28
//   Calendar._SDN_len = N; // short day name length
29
//   Calendar._SMN_len = N; // short month name length
30
//
31
// If N = 3 then this is not needed either since we assume a value of 3 if not
32
// present, to be compatible with translation files that were written before
33
// this feature.
34

  
35
// short day names
36
Calendar._SDN = new Array
37
("อา.",
38
 "จ.",
39
 "อ.",
40
 "พ.",
41
 "พฤ.",
42
 "ศ.",
43
 "ส.",
44
 "อา.");
45

  
46
// First day of the week. "0" means display Sunday first, "1" means display
47
// Monday first, etc.
48
Calendar._FD = 1;
49

  
50
// full month names
51
Calendar._MN = new Array
52
("มกราคม",
53
 "กุมภาพันธ์",
54
 "มีนาคม",
55
 "เมษายน",
56
 "พฤษภาคม",
57
 "มิถุนายน",
58
 "กรกฎาคม",
59
 "สิงหาคม",
60
 "กันยายน",
61
 "ตุลาคม",
62
 "พฤศจิกายน",
63
 "ธันวาคม");
64

  
65
// short month names
66
Calendar._SMN = new Array
67
("ม.ค.",
68
 "ก.พ.",
69
 "มี.ค.",
70
 "เม.ย.",
71
 "พ.ค.",
72
 "มิ.ย.",
73
 "ก.ค.",
74
 "ส.ค.",
75
 "ก.ย.",
76
 "ต.ค.",
77
 "พ.ย.",
78
 "ธ.ค.");
79

  
80
// tooltips
81
Calendar._TT = {};
82
Calendar._TT["INFO"] = "เกี่ยวกับปฏิทิน";
83

  
84
Calendar._TT["ABOUT"] =
85
"DHTML Date/Time Selector\n" +
86
"(c) dynarch.com 2002-2005 / Author: Mihai Bazon\n" + // don't translate this this ;-)
87
"For latest version visit: http://www.dynarch.com/projects/calendar/\n" +
88
"Distributed under GNU LGPL.  See http://gnu.org/licenses/lgpl.html for details." +
89
"\n\n" +
90
"Date selection:\n" +
91
"- Use the \xab, \xbb buttons to select year\n" +
92
"- Use the " + String.fromCharCode(0x2039) + ", " + String.fromCharCode(0x203a) + " buttons to select month\n" +
93
"- Hold mouse button on any of the above buttons for faster selection.";
94
Calendar._TT["ABOUT_TIME"] = "\n\n" +
95
"Time selection:\n" +
96
"- Click on any of the time parts to increase it\n" +
97
"- or Shift-click to decrease it\n" +
98
"- or click and drag for faster selection.";
99

  
100
Calendar._TT["PREV_YEAR"] = "ปีที่แล้ว (ถ้ากดค้างจะมีเมนู)";
101
Calendar._TT["PREV_MONTH"] = "เดือนที่แล้ว (ถ้ากดค้างจะมีเมนู)";
102
Calendar._TT["GO_TODAY"] = "ไปที่วันนี้";
103
Calendar._TT["NEXT_MONTH"] = "เดือนหน้า (ถ้ากดค้างจะมีเมนู)";
104
Calendar._TT["NEXT_YEAR"] = "ปีหน้า (ถ้ากดค้างจะมีเมนู)";
105
Calendar._TT["SEL_DATE"] = "เลือกวัน";
106
Calendar._TT["DRAG_TO_MOVE"] = "กดแล้วลากเพื่อย้าย";
107
Calendar._TT["PART_TODAY"] = " (วันนี้)";
108

  
109
// the following is to inform that "%s" is to be the first day of week
110
// %s will be replaced with the day name.
111
Calendar._TT["DAY_FIRST"] = "แสดง %s เป็นวันแรก";
112

  
113
// This may be locale-dependent.  It specifies the week-end days, as an array
114
// of comma-separated numbers.  The numbers are from 0 to 6: 0 means Sunday, 1
115
// means Monday, etc.
116
Calendar._TT["WEEKEND"] = "0,6";
117

  
118
Calendar._TT["CLOSE"] = "ปิด";
119
Calendar._TT["TODAY"] = "วันนี้";
120
Calendar._TT["TIME_PART"] = "(Shift-)กดหรือกดแล้วลากเพื่อเปลี่ยนค่า";
121

  
122
// date formats
123
Calendar._TT["DEF_DATE_FORMAT"] = "%Y-%m-%d";
124
Calendar._TT["TT_DATE_FORMAT"] = "%a %e %b";
125

  
126
Calendar._TT["WK"] = "wk";
127
Calendar._TT["TIME"] = "เวลา:";
.svn/pristine/11/11caec7ba0e56486601495ed3e744468ec15f734.svn-base
1
# encoding: utf-8
2
#
3
# Redmine - project management software
4
# Copyright (C) 2006-2011  Jean-Philippe Lang
5
#
6
# This program is free software; you can redistribute it and/or
7
# modify it under the terms of the GNU General Public License
8
# as published by the Free Software Foundation; either version 2
9
# of the License, or (at your option) any later version.
10
#
11
# This program is distributed in the hope that it will be useful,
12
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
# GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License
17
# along with this program; if not, write to the Free Software
18
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
19

  
20
module VersionsHelper
21

  
22
  STATUS_BY_CRITERIAS = %w(category tracker status priority author assigned_to)
23

  
24
  def render_issue_status_by(version, criteria)
25
    criteria = 'category' unless STATUS_BY_CRITERIAS.include?(criteria)
26

  
27
    h = Hash.new {|k,v| k[v] = [0, 0]}
28
    begin
29
      # Total issue count
30
      Issue.count(:group => criteria,
31
                  :conditions => ["#{Issue.table_name}.fixed_version_id = ?", version.id]).each {|c,s| h[c][0] = s}
32
      # Open issues count
33
      Issue.count(:group => criteria,
34
                  :include => :status,
35
                  :conditions => ["#{Issue.table_name}.fixed_version_id = ? AND #{IssueStatus.table_name}.is_closed = ?", version.id, false]).each {|c,s| h[c][1] = s}
36
    rescue ActiveRecord::RecordNotFound
37
    # When grouping by an association, Rails throws this exception if there's no result (bug)
38
    end
39
    counts = h.keys.compact.sort.collect {|k| {:group => k, :total => h[k][0], :open => h[k][1], :closed => (h[k][0] - h[k][1])}}
40
    max = counts.collect {|c| c[:total]}.max
41

  
42
    render :partial => 'issue_counts', :locals => {:version => version, :criteria => criteria, :counts => counts, :max => max}
43
  end
44

  
45
  def status_by_options_for_select(value)
46
    options_for_select(STATUS_BY_CRITERIAS.collect {|criteria| [l("field_#{criteria}".to_sym), criteria]}, value)
47
  end
48
end
.svn/pristine/11/11f49f2c53a5591216f2864d819f2860ef3e3885.svn-base
1
<% if @user.auth_source %><%= l(:mail_body_account_information_external, @user.auth_source.name) %>
2
<% else %><%= l(:mail_body_account_information) %>:
3
* <%= l(:field_login) %>: <%= @user.login %>
4
* <%= l(:field_password) %>: <%= @password %>
5
<% end %>
6
<%= l(:label_login) %>: <%= @login_url %>

Also available in: Unified diff