##// END OF EJS Templates
Lists can be reordered with drag and drop (#12909)....
Lists can be reordered with drag and drop (#12909). git-svn-id: http://svn.redmine.org/redmine/trunk@15336 e93f8b46-1217-0410-a6f0-8f06a7374b81

File last commit:

r14856:cda9c63d9c21
r14954:42b5c332b2c2
Show More
document.rb
75 lines | 2.5 KiB | text/x-ruby | RubyLexer
Jean-Philippe Lang
Changes RedMine to Redmine in copyright notices....
r9454 # Redmine - project management software
Jean-Philippe Lang
Updates copyright for 2016....
r14856 # Copyright (C) 2006-2016 Jean-Philippe Lang
Jean-Philippe Lang
added svn:eol-style native property on /app files...
r330 #
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
Toshi MARUYAMA
remove trailing white-spaces from Document model source....
r5674 #
Jean-Philippe Lang
added svn:eol-style native property on /app files...
r330 # This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
Toshi MARUYAMA
remove trailing white-spaces from Document model source....
r5674 #
Jean-Philippe Lang
added svn:eol-style native property on /app files...
r330 # You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
class Document < ActiveRecord::Base
Jean-Philippe Lang
Prevent mass-assignment when adding/updating a document (#10390)....
r9010 include Redmine::SafeAttributes
Jean-Philippe Lang
added svn:eol-style native property on /app files...
r330 belongs_to :project
Jean-Philippe Lang
Removed unneeded :foreign_key option on belongs_to associations....
r13102 belongs_to :category, :class_name => "DocumentCategory"
Jean-Philippe Lang
Split "Manage documents" permission into create, edit and delete permissions (#12401)....
r10976 acts_as_attachable :delete_permission => :delete_documents
Jean-Philippe Lang
Adds custom fields to documents (#7249)....
r13622 acts_as_customizable
Jean-Philippe Lang
added svn:eol-style native property on /app files...
r330
Jean-Philippe Lang
Merged rails-4.1 branch (#14534)....
r13100 acts_as_searchable :columns => ['title', "#{table_name}.description"],
Jean-Philippe Lang
Rewrites search engine to properly paginate results (#18631)....
r13357 :preload => :project
Jean-Philippe Lang
Search engines now supports pagination....
r755 acts_as_event :title => Proc.new {|o| "#{l(:label_document)}: #{o.title}"},
Jean-Philippe Lang
Replaces find(:first) calls....
r10701 :author => Proc.new {|o| o.attachments.reorder("#{Attachment.table_name}.created_on ASC").first.try(:author) },
Jean-Philippe Lang
Search engines now supports pagination....
r755 :url => Proc.new {|o| {:controller => 'documents', :action => 'show', :id => o.id}}
Jean-Philippe Lang
Merged rails-4.1 branch (#14534)....
r13100 acts_as_activity_provider :scope => preload(:project)
Toshi MARUYAMA
remove trailing white-spaces from Document model source....
r5674
Jean-Philippe Lang
0.3 unstable...
r10 validates_presence_of :project, :title, :category
Jean-Philippe Lang
Raises 60-character limit for document titles to 255 (#12312)....
r13879 validates_length_of :title, :maximum => 255
Jean-Philippe Lang
Merged rails-4.1 branch (#14534)....
r13100 attr_protected :id
Toshi MARUYAMA
remove trailing white-spaces from Document model source....
r5674
Jean-Philippe Lang
Use AR callbacks instead of observers (removed in Rails4) for notifications....
r11791 after_create :send_notification
Jean-Philippe Lang
Rewrites named scopes with ARel queries....
r10723 scope :visible, lambda {|*args|
Jean-Philippe Lang
Merged rails-4.1 branch (#14534)....
r13100 joins(:project).
where(Project.allowed_to_condition(args.shift || User.current, :view_documents, *args))
Jean-Philippe Lang
Rewrites named scopes with ARel queries....
r10723 }
Toshi MARUYAMA
remove trailing white-spaces from Document model source....
r5674
Jean-Philippe Lang
Adds custom fields to documents (#7249)....
r13622 safe_attributes 'category_id', 'title', 'description', 'custom_fields', 'custom_field_values'
Jean-Philippe Lang
Prevent mass-assignment when adding/updating a document (#10390)....
r9010
Jean-Philippe Lang
Make sure users don't get notified for thing they can not view (#3589)....
r3055 def visible?(user=User.current)
!user.nil? && user.allowed_to?(:view_documents, project)
end
Toshi MARUYAMA
remove trailing white-spaces from Document model source....
r5674
Jean-Philippe Lang
Removed after_initialize methods....
r8168 def initialize(attributes=nil, *args)
super
Jean-Philippe Lang
Fixed: default category ignored when adding a document (#2328)....
r2122 if new_record?
Eric Davis
Changed Enumerations to use a Single Table Inheritance...
r2677 self.category ||= DocumentCategory.default
Jean-Philippe Lang
Fixed: default category ignored when adding a document (#2328)....
r2122 end
end
Toshi MARUYAMA
remove trailing white-spaces from Document model source....
r5674
Jean-Philippe Lang
Show last update datetime (last attachment added) on document list (#4232)....
r2981 def updated_on
unless @updated_on
Jean-Philippe Lang
Order is already defined on attachments association....
r8338 a = attachments.last
Jean-Philippe Lang
Show last update datetime (last attachment added) on document list (#4232)....
r2981 @updated_on = (a && a.created_on) || created_on
end
@updated_on
end
Jean-Philippe Lang
Use AR callbacks instead of observers (removed in Rails4) for notifications....
r11791
Jean-Philippe Lang
Add support for multiple email addresses per user (#4244)....
r13504 def notified_users
project.notified_users.reject {|user| !visible?(user)}
end
Jean-Philippe Lang
Use AR callbacks instead of observers (removed in Rails4) for notifications....
r11791 private
def send_notification
if Setting.notified_events.include?('document_added')
Mailer.document_added(self).deliver
end
end
Jean-Philippe Lang
Initial commit...
r2 end