Changesets can be listed by changeset number.
The Git repository is here.
- Revision:
- 24
- Log:
Initial import of Collaboa 0.5.6 from downloaded Tarball. Collaboa is
a Ruby On Rails based bug tracker and SVN repository browsing tool.
- Author:
- adh
- Date:
- Mon Jul 24 21:54:39 +0100 2006
- Size:
- 2198 Bytes
1 | class TicketChange < ActiveRecord::Base |
2 | belongs_to :ticket |
3 | serialize :log |
4 | |
5 | def each_log |
6 | return unless self.log |
7 | self.log.each do |name, (old_value, new_value)| |
8 | yield [name, old_value, new_value] |
9 | end |
10 | end |
11 | |
12 | def empty? |
13 | return false if self.comment && !self.comment.empty? |
14 | return false if self.log && !self.log.empty? |
15 | return false if self.attachment && !self.attachment.empty? |
16 | true |
17 | end |
18 | |
19 | # TODO: flesh out |
20 | def attach(attachment) |
21 | unless attachment.blank? |
22 | self.attachment = base_part_of(attachment.original_filename) |
23 | self.content_type = attachment.content_type.strip |
24 | self.attachment_fsname = dump_filename |
25 | filename = dump_filename |
26 | attachment.rewind |
27 | File.open(filename, "wb") do |f| |
28 | f.write(attachment.read) |
29 | end |
30 | end |
31 | end |
32 | |
33 | def dump_filename |
34 | File.expand_path(File.join(ATTACHMENTS_PATH, "#{self.id}-#{self.attachment}")) |
35 | end |
36 | |
37 | def has_attachment? |
38 | self.attachment && !self.attachment.empty? |
39 | end |
40 | |
41 | class << self |
42 | # Returns am array of "normalized" hashes, useful for mixing display of search result from |
43 | # other resources (token finder code based on things found in Typo) |
44 | def search(query) |
45 | if !query.to_s.strip.empty? |
46 | tokens = query.split.collect {|c| "%#{c.downcase}%"} |
47 | findings = find( :all, |
48 | :conditions => [(["(LOWER(comment) LIKE ?)"] * tokens.size).join(" AND "), |
49 | *tokens.collect { |token| [token] }.flatten], |
50 | :order => 'created_at DESC') |
51 | findings.collect do |f| |
52 | { |
53 | :title => "Ticket ##{f.ticket_id} comment by #{f.author}", |
54 | :content => f.comment, |
55 | :link => { :controller => '/tickets', :action => 'show', :id => f.ticket_id } |
56 | } |
57 | end |
58 | else |
59 | [] |
60 | end |
61 | end |
62 | end |
63 | |
64 | protected |
65 | validates_presence_of :author |
66 | |
67 | private |
68 | def base_part_of(filename) |
69 | filename = File.basename(filename.strip) |
70 | # remove leading period, whitespace and \ / : * ? " ' < > | |
71 | filename = filename.gsub(%r{^\.|[\s/\\\*\:\?'"<>\|]}, '_') |
72 | end |
73 | |
74 | end |