将issue加入活动中,添加读取活动数据的方法
This commit is contained in:
parent
1dd86b9116
commit
7287e151d0
|
@ -9,6 +9,27 @@ def index
|
|||
# @message.each do |m|
|
||||
# Activity.create(:act_id => m.id, :act_type => 'Message', :user_id => m.author_id)
|
||||
# end
|
||||
activity = Message.all
|
||||
activity += News.all
|
||||
activity += Journal.all
|
||||
activity += Issue.all
|
||||
activity += Bid.all
|
||||
@activity = activity.sort {|x,y| x.created_on <=> y.created_on}
|
||||
@activity.each do |act|
|
||||
if act.instance_of?(Bid)
|
||||
act.acts << Activity.new(:user_id => act.author_id)
|
||||
elsif act.instance_of?(News)
|
||||
act.acts << Activity.new(:user_id => act.author_id)
|
||||
elsif act.instance_of?(Message)
|
||||
act.acts << Activity.new(:user_id => act.author_id)
|
||||
elsif act.instance_of?(Journal)
|
||||
act.acts << Activity.new(:user_id => act.user_id)
|
||||
elsif act.instance_of?(Issue)
|
||||
act.acts << Activity.new(:user_id => act.author_id)
|
||||
elsif act.instance_of?(Changeset)
|
||||
act.acts << Activity.new(:user_id => act.user_id)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
#@watchers_of_projects = WatchersOfProjects.new
|
||||
|
|
|
@ -42,6 +42,11 @@ class Issue < ActiveRecord::Base
|
|||
|
||||
has_many :relations_from, :class_name => 'IssueRelation', :foreign_key => 'issue_from_id', :dependent => :delete_all
|
||||
has_many :relations_to, :class_name => 'IssueRelation', :foreign_key => 'issue_to_id', :dependent => :delete_all
|
||||
|
||||
# added by fq
|
||||
has_many :acts, :class_name => 'Activity', :as => :act, :dependent => :destroy
|
||||
# end
|
||||
|
||||
|
||||
acts_as_nested_set :scope => 'root_id', :dependent => :destroy
|
||||
acts_as_attachable :after_add => :attachment_added, :after_remove => :attachment_removed
|
||||
|
@ -65,6 +70,11 @@ class Issue < ActiveRecord::Base
|
|||
DONE_RATIO_OPTIONS = %w(issue_field issue_status)
|
||||
|
||||
attr_reader :current_journal
|
||||
|
||||
# fq
|
||||
after_create :act_as_activity
|
||||
# end
|
||||
|
||||
delegate :notes, :notes=, :private_notes, :private_notes=, :to => :current_journal, :allow_nil => true
|
||||
|
||||
validates_presence_of :subject, :priority, :project, :tracker, :author, :status
|
||||
|
@ -102,6 +112,15 @@ class Issue < ActiveRecord::Base
|
|||
after_save :after_create_from_copy
|
||||
after_destroy :update_parent_attributes
|
||||
|
||||
|
||||
# fq
|
||||
def act_as_activity
|
||||
self.acts << Activity.new(:user_id => self.author_id)
|
||||
end
|
||||
# end
|
||||
|
||||
|
||||
|
||||
# Returns a SQL conditions string used to find all issues visible by the specified user
|
||||
def self.visible_condition(user, options={})
|
||||
Project.allowed_to_condition(user, :view_issues, options) do |role, user|
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
|
||||
<div class="box tabular">
|
||||
<% if @user.auth_source_id.nil? %>
|
||||
<p><%= f.text_field :login, :size => 25, :required => true %></p>
|
||||
|
||||
<p><%= f.text_field :login, :size => 25, :required => true %>
|
||||
<em class="info">至多25个字符。</em></p>
|
||||
<p><%= f.password_field :password, :size => 25, :required => true %>
|
||||
<em class="info"><%= l(:text_caracters_minimum, :count => Setting.password_min_length) %></em></p>
|
||||
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
height: 30px;
|
||||
line-height: 18px;
|
||||
font-size: 14px;
|
||||
color: rgb(255, 255, 255);
|
||||
background: url("/images/button/bg104.jpg") no-repeat scroll left top transparent;
|
||||
color: rgb(0, 0, 0);
|
||||
background: url("/images/button/bg103.jpg") no-repeat scroll left top transparent;
|
||||
padding: 0px 0px 4px 0px;
|
||||
border-radius: 2px;
|
||||
border: 1px solid rgb(148, 148, 148);
|
||||
|
@ -21,8 +21,8 @@
|
|||
height: 30px;
|
||||
line-height: 18px;
|
||||
font-size: 14px;
|
||||
color: rgb(255, 255, 255);
|
||||
background: url("/images/button/bg104.jpg") no-repeat scroll left top transparent;
|
||||
color: rgb(0, 0, 0);
|
||||
background: url("/images/button/bg103.jpg") no-repeat scroll left top transparent;
|
||||
padding: 0px 0px 4px 0px;
|
||||
border-radius: 2px;
|
||||
border: 1px solid rgb(148, 148, 148);
|
||||
|
|
|
@ -79,10 +79,29 @@
|
|||
<%= textilizable act.description %>
|
||||
</p></td>
|
||||
</tr>
|
||||
<% when 'Issue' %>
|
||||
<tr>
|
||||
<% if e.user == User.current%>
|
||||
<td colspan="2" valign="top"><strong> <%= link_to("#{l(:label_i)}", user_path(e.user_id)) %></strong><span class="font_lighter"><%= l(:label_new_activity) %></span> <%= link_to format_activity_title("#{act.tracker.name} ##{act.id} (#{act.status}): #{act.subject}"), {:controller => 'issues', :action => 'show', :id => act.id} %></td>
|
||||
<% else %>
|
||||
<td colspan="2" valign="top"><strong> <%= link_to(h(e.user), user_path(e.user_id)) %></strong><span class="font_lighter"><%= l(:label_new_activity) %></span> <%= link_to format_activity_title("#{act.tracker.name} ##{act.id} (#{act.status}): #{act.subject}"), {:controller => 'issues', :action => 'show', :id => act.id} %></td>
|
||||
<% end %>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2" width="580" >
|
||||
<p class="font_description">
|
||||
<%= textilizable act.description %>
|
||||
</p></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
<tr>
|
||||
<td align="left"><a class="font_lighter"></a></td>
|
||||
<td width="200" align="right" class="a"><span class="font_lighter"><%= format_time(e.act.created_on) %></span></td>
|
||||
<td width="200" align="right" class="a"><span class="font_lighter">
|
||||
<% if e.act_type == 'Changeset' %>
|
||||
<%= format_time(e.act.committed_on) %>
|
||||
<% else %>
|
||||
<%= format_time(e.act.created_on) %>
|
||||
<% end %></span></td>
|
||||
</tr>
|
||||
<!-- <tr><div class="line_under"></div></tr> -->
|
||||
</table></td>
|
||||
|
|
|
@ -430,6 +430,8 @@ RedmineApp::Application.routes.draw do
|
|||
match 'bids/new_bid', :controller => 'bids', :action => 'new_bid'
|
||||
match 'bids/:id/show_project', :controller => 'bids', :action => 'show_project', :as => 'project_for_bid'
|
||||
match 'bids/:id/add', :controller => 'bids', :action => 'add'
|
||||
## 测试用
|
||||
match 'test/index', :controller => 'test', :action => 'index'
|
||||
# added by young
|
||||
match 'bids', :controller => 'bids', :action => 'index'
|
||||
|
||||
|
|
16
db/schema.rb
16
db/schema.rb
|
@ -625,22 +625,6 @@ ActiveRecord::Schema.define(:version => 20130811122119) do
|
|||
t.integer "fields_bits", :default => 0
|
||||
end
|
||||
|
||||
create_table "user_extensions", :force => true do |t|
|
||||
t.integer "user_id"
|
||||
t.text "brief_introduction"
|
||||
t.text "gender"
|
||||
t.date "birthdate"
|
||||
t.text "occupation"
|
||||
t.text "location"
|
||||
t.integer "zip_code"
|
||||
t.float "work_experitions"
|
||||
t.integer "qq"
|
||||
t.integer "praise_num"
|
||||
t.integer "tread_num"
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
end
|
||||
|
||||
create_table "user_preferences", :force => true do |t|
|
||||
t.integer "user_id", :default => 0, :null => false
|
||||
t.text "others"
|
||||
|
|
Loading…
Reference in New Issue