Revision 443:350acce374a2 app/models
| app/models/mailer.rb | ||
|---|---|---|
| 32 | 32 |
{ :host => h, :protocol => Setting.protocol }
|
| 33 | 33 |
end |
| 34 | 34 |
|
| 35 |
|
|
| 36 |
|
|
| 37 |
# Builds a tmail object used to email the specified user that he was added to a project |
|
| 38 |
# |
|
| 39 |
# Example: |
|
| 40 |
# add_to_project(user) => tmail object |
|
| 41 |
# Mailer.deliver_add_to_project(user) => sends an email to the registered user |
|
| 42 |
def added_to_project(member, project) |
|
| 43 |
|
|
| 44 |
user = User.find(member.user_id) |
|
| 45 |
|
|
| 46 |
set_language_if_valid user.language |
|
| 47 |
recipients user.mail |
|
| 48 |
subject l(:mail_subject_added_to_project, Setting.app_title) |
|
| 49 |
body :project_url => url_for(:controller => 'projects', :action => 'show', :id => project.id), |
|
| 50 |
:project_name => project.name |
|
| 51 |
render_multipart('added_to_project', body)
|
|
| 52 |
end |
|
| 53 |
|
|
| 54 |
|
|
| 55 |
|
|
| 35 | 56 |
# Builds a tmail object used to email recipients of the added issue. |
| 36 | 57 |
# |
| 37 | 58 |
# Example: |
| ... | ... | |
| 458 | 479 |
end |
| 459 | 480 |
end |
| 460 | 481 |
end |
| 482 |
|
|
| 483 |
|
|
| 484 |
|
|
| 485 |
|
|
| app/models/news.rb | ||
|---|---|---|
| 51 | 51 |
def add_author_as_watcher |
| 52 | 52 |
Watcher.create(:watchable => self, :user => author) |
| 53 | 53 |
end |
| 54 |
|
|
| 55 |
# returns latest news for a specific project |
|
| 56 |
def self.latest_for(project, count = 5) |
|
| 57 |
find(:all, :limit => count, :conditions => [ "#{News.table_name}.project_id = #{project.id}", Project.allowed_to_condition(User.current, :view_news) ], :include => [ :author, :project ], :order => "#{News.table_name}.created_on DESC")
|
|
| 58 |
end |
|
| 54 | 59 |
end |
| app/models/project.rb | ||
|---|---|---|
| 468 | 468 |
|
| 469 | 469 |
# Returns a short description of the projects (first lines) |
| 470 | 470 |
def short_description(length = 255) |
| 471 |
|
|
| 472 |
## The short description is used in lists, e.g. Latest projects, |
|
| 473 |
## My projects etc. It should be no more than a line or two with |
|
| 474 |
## no text formatting. |
|
| 475 |
|
|
| 471 | 476 |
## Original Redmine code: this truncates to the CR that is more |
| 472 | 477 |
## than "length" characters from the start. |
| 473 | 478 |
# description.gsub(/^(.{#{length}}[^\n\r]*).*$/m, '\1...').strip if description
|
| 474 |
## That's too much for us, and also we want to omit images and the |
|
| 475 |
## like. Truncate instead to the first CR that follows _any_ |
|
| 476 |
## non-blank text, and to the next word break beyond "length" |
|
| 477 |
## characters if the result is still longer than that. |
|
| 479 |
|
|
| 480 |
## That can leave too much text for us, and also we want to omit |
|
| 481 |
## images and the like. Truncate instead to the first CR that |
|
| 482 |
## follows _any_ non-blank text, and to the next word break beyond |
|
| 483 |
## "length" characters if the result is still longer than that. |
|
| 484 |
## |
|
| 478 | 485 |
description.gsub(/![^\s]+!/, '').gsub(/^(\s*[^\n\r]*).*$/m, '\1').gsub(/^(.{#{length}}\b).*$/m, '\1 ...').strip if description
|
| 479 | 486 |
end |
| 480 | 487 |
|
| app/models/repository.rb | ||
|---|---|---|
| 268 | 268 |
nil |
| 269 | 269 |
end |
| 270 | 270 |
|
| 271 |
def clear_cache |
|
| 272 |
clear_changesets |
|
| 273 |
end |
|
| 274 |
|
|
| 271 | 275 |
def self.scm_adapter_class |
| 272 | 276 |
nil |
| 273 | 277 |
end |
| app/models/repository/mercurial.rb | ||
|---|---|---|
| 22 | 22 |
has_many :changesets, :order => "#{Changeset.table_name}.id DESC", :foreign_key => 'repository_id'
|
| 23 | 23 |
|
| 24 | 24 |
attr_protected :root_url |
| 25 |
validates_presence_of :url |
|
| 25 |
# validates_presence_of :url
|
|
| 26 | 26 |
|
| 27 | 27 |
FETCH_AT_ONCE = 100 # number of changesets to fetch at once |
| 28 | 28 |
|
Also available in: Unified diff