diff options
author | Stan Hu <stanhu@gmail.com> | 2015-03-20 05:11:12 -0700 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2015-04-02 00:04:08 -0700 |
commit | dfd256f29ee817b5ffc563bb554a02d26ae44502 (patch) | |
tree | c28e943c541df30a2a0ab03905bf5d7bbe61b3ba /app/models/note.rb | |
parent | 16a6ea2d1769f68157976b83bf6da468dd38853d (diff) | |
download | gitlab-ce-dfd256f29ee817b5ffc563bb554a02d26ae44502.tar.gz |
Support configurable attachment size via Application Settings
Fix bug where error messages from Dropzone would not be displayed on the issues page
Closes #1258
Diffstat (limited to 'app/models/note.rb')
-rw-r--r-- | app/models/note.rb | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/app/models/note.rb b/app/models/note.rb index e86160e7cd9..fdab4517df3 100644 --- a/app/models/note.rb +++ b/app/models/note.rb @@ -22,6 +22,7 @@ require 'file_size_validator' class Note < ActiveRecord::Base include Mentionable + include Gitlab::CurrentSettings default_value_for :system, false @@ -36,7 +37,8 @@ class Note < ActiveRecord::Base validates :note, :project, presence: true validates :line_code, format: { with: /\A[a-z0-9]+_\d+_\d+\Z/ }, allow_blank: true - validates :attachment, file_size: { maximum: 10.megabytes.to_i } + # Attachments are deprecated and are handled by Markdown uploader + validates :attachment, file_size: { maximum: :max_attachment_size } validates :noteable_id, presence: true, if: ->(n) { n.noteable_type.present? && n.noteable_type != 'Commit' } validates :commit_id, presence: true, if: ->(n) { n.noteable_type == 'Commit' } @@ -321,6 +323,10 @@ class Note < ActiveRecord::Base end end + def max_attachment_size + current_application_settings.max_attachment_size.megabytes.to_i + end + def commit_author @commit_author ||= project.team.users.find_by(email: noteable.author_email) || @@ -451,7 +457,7 @@ class Note < ActiveRecord::Base prev_match_line = line else prev_lines << line - + break if generate_line_code(line) == self.line_code prev_lines.shift if prev_lines.length >= max_number_of_lines |