修改用户主页中与我相关部分的功能,现在可以查找在问题中的引用以及对指派给我的问题中的所有反馈
This commit is contained in:
parent
d3ddb833b5
commit
238b9a416f
|
@ -192,6 +192,10 @@ class IssuesController < ApplicationController
|
|||
|
||||
if saved
|
||||
render_attachment_warning_if_needed(@issue)
|
||||
reply_id = params[:reference_user_id].to_i
|
||||
if reply_id > 0
|
||||
JournalReply.add_reply(@issue.current_journal.id, reply_id, User.current.id)
|
||||
end
|
||||
flash[:notice] = l(:notice_successful_update) unless @issue.current_journal.new_record?
|
||||
|
||||
respond_to do |format|
|
||||
|
|
|
@ -69,6 +69,7 @@ class JournalsController < ApplicationController
|
|||
text = text.to_s.strip.gsub(%r{<pre>((.|\s)*?)</pre>}m, '[...]')
|
||||
@content = "#{ll(Setting.default_language, :text_user_wrote, user)}\n> "
|
||||
@content << text.gsub(/(\r?\n|\r\n?)/, "\n> ") + "\n\n"
|
||||
@id = user.id
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
render_404
|
||||
end
|
||||
|
|
|
@ -24,6 +24,7 @@ class UsersController < ApplicationController
|
|||
menu_item :user_newfeedback, :only => :user_newfeedback
|
||||
#Ended by young
|
||||
|
||||
|
||||
before_filter :require_admin, :except => [:show, :index,:tag_save, :user_projects, :user_newfeedback, :user_comments, :watch_bids, :info, :user_watchlist, :user_fanslist,:edit]
|
||||
before_filter :find_user, :only => [:user_fanslist, :user_watchlist, :show, :edit, :update, :destroy, :edit_membership,
|
||||
:destroy_membership, :user_activities, :user_projects, :user_newfeedback, :user_comments, :watch_bids, :info]
|
||||
|
@ -216,10 +217,20 @@ class UsersController < ApplicationController
|
|||
|
||||
#### added by fq
|
||||
def info
|
||||
@message = []
|
||||
|
||||
message = []
|
||||
if @user == User.current
|
||||
@message = JournalsForMessage.reference_message(@user.id)
|
||||
end
|
||||
|
||||
message = JournalsForMessage.reference_message(@user.id)
|
||||
message += Journal.reference_message(@user.id) end
|
||||
@offset, @limit = api_offset_and_limit({:limit => 10})
|
||||
@info_count = message.size
|
||||
@info_pages = Paginator.new @info_count, @limit, params['page']
|
||||
@offset ||= @info_pages.offset
|
||||
|
||||
messages = message.sort {|x,y| y.created_on <=> x.created_on }
|
||||
|
||||
@message = messages[@offset, @limit]
|
||||
|
||||
unless User.current.admin?
|
||||
if !@user.active?
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
class Activity < ActiveRecord::Base
|
||||
attr_accessible :act_id, :act_type, :user_id
|
||||
belongs_to :act, :polymorphic => true
|
||||
end
|
|
@ -6,6 +6,7 @@ class Bid < ActiveRecord::Base
|
|||
has_many :biding_projects, :dependent => :destroy
|
||||
has_many :projects, :through => :biding_projects
|
||||
has_many :journals_for_messages, :as => :jour, :dependent => :destroy
|
||||
has_many :acts, :as => :act, :dependent => :destroy
|
||||
|
||||
NAME_LENGTH_LIMIT = 60
|
||||
DESCRIPTION_LENGTH_LIMIT = 250
|
||||
|
@ -17,6 +18,8 @@ class Bid < ActiveRecord::Base
|
|||
# validates_format_of :deadline, :with =>
|
||||
validate :validate_user
|
||||
|
||||
# after_save :act_as_activity
|
||||
|
||||
scope :visible, lambda {|*args|
|
||||
nil
|
||||
}
|
||||
|
@ -77,4 +80,8 @@ class Bid < ActiveRecord::Base
|
|||
def validate_user
|
||||
errors.add :author_id, :invalid if author.nil? || !author.active?
|
||||
end
|
||||
|
||||
# def act_as_activity
|
||||
# self.acts << Activity.new(:user_id => self.author_id)
|
||||
# end
|
||||
end
|
||||
|
|
|
@ -23,6 +23,9 @@ class Journal < ActiveRecord::Base
|
|||
|
||||
belongs_to :user
|
||||
has_many :details, :class_name => "JournalDetail", :dependent => :delete_all
|
||||
# added by fq
|
||||
has_one :journal_reply
|
||||
#end
|
||||
attr_accessor :indice
|
||||
|
||||
acts_as_event :title => Proc.new {|o| status = ((s = o.new_status) ? " (#{s})" : nil); "#{o.issue.tracker} ##{o.issue.id}#{status}: #{o.issue.subject}" },
|
||||
|
@ -108,6 +111,14 @@ class Journal < ActiveRecord::Base
|
|||
end
|
||||
notified.map(&:mail)
|
||||
end
|
||||
|
||||
## added_by_fq
|
||||
def self.reference_message(user_id)
|
||||
message = Journal.find_by_sql("select id, journalized_id, user_id, notes, created_on from journals where id in (select journal_id from journal_replies where reply_id = #{user_id})")
|
||||
message += Journal.find_by_sql("select id, journalized_id, user_id, notes, created_on from journals where journalized_id in (select id from issues where assigned_to_id = #{user_id})")
|
||||
message
|
||||
end
|
||||
##
|
||||
|
||||
private
|
||||
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
# added by fq
|
||||
|
||||
class JournalReply < ActiveRecord::Base
|
||||
attr_accessible :journal_id, :reply_id, :user_id
|
||||
|
||||
belongs_to :user
|
||||
belongs_to :journal
|
||||
|
||||
def self.add_reply(journal_id, reply_id, user_id)
|
||||
self.create(:journal_id => journal_id, :reply_id => reply_id, :user_id => user_id)
|
||||
end
|
||||
end
|
|
@ -16,7 +16,7 @@ class JournalsForMessage < ActiveRecord::Base
|
|||
|
||||
def self.reference_message(user_id)
|
||||
@user = User.find(user_id)
|
||||
message = JournalsForMessage.find_by_sql("select * from journals_for_messages where reply_id = #{@user.id} or (jour_type = 'Bid' and jour_id in (select id from bids where author_id = #{@user.id}))", )
|
||||
message = JournalsForMessage.find_by_sql("select * from journals_for_messages where reply_id = #{@user.id} or (jour_type = 'Bid' and jour_id in (select id from bids where author_id = #{@user.id}))")
|
||||
message
|
||||
end
|
||||
|
||||
|
|
|
@ -81,6 +81,7 @@ class User < Principal
|
|||
has_many :jours, :class_name => 'JournalsForMessage', :dependent => :destroy
|
||||
has_many :bids, :foreign_key => 'author_id', :dependent => :destroy
|
||||
has_many :journals_for_messages, :as => :jour, :dependent => :destroy
|
||||
has_many :journal_replies
|
||||
#####
|
||||
|
||||
|
||||
|
|
|
@ -44,6 +44,7 @@
|
|||
|
||||
<%= f.hidden_field :lock_version %>
|
||||
<%= hidden_field_tag 'last_journal_id', params[:last_journal_id] || @issue.last_journal_id %>
|
||||
<%= hidden_field_tag 'reference_user_id', params[:reference_user_id]%>
|
||||
<%= submit_tag l(:button_submit) %>
|
||||
<%= preview_link preview_edit_issue_path(:project_id => @project, :id => @issue), 'issue-form' %>
|
||||
<% end %>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
$("#journal-<%= @journal.id %>-notes").hide();
|
||||
|
||||
$('#new_form_reference_user_id').val('');
|
||||
if ($("form#journal-<%= @journal.id %>-form").length > 0) {
|
||||
// journal edit form already loaded
|
||||
$("#journal-<%= @journal.id %>-form").show();
|
||||
|
|
|
@ -8,3 +8,5 @@ $('#issue_private_notes').attr('checked', true);
|
|||
|
||||
showAndScrollTo("update", "notes");
|
||||
$('#notes').scrollTop = $('#notes').scrollHeight - $('#notes').clientHeight;
|
||||
|
||||
$('#reference_user_id').val("<%= @id %>");
|
|
@ -5,5 +5,5 @@
|
|||
$("#journal-<%= @journal.id %>-notes").show();
|
||||
$("#journal-<%= @journal.id %>-form").remove();
|
||||
<% end %>
|
||||
|
||||
$('#new_form_reference_user_id').val('');
|
||||
<%= call_hook(:view_journals_update_js_bottom, { :journal => @journal }) %>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<!-- fq -->
|
||||
<% unless @message.empty? %>
|
||||
<div id="activity">
|
||||
<% @message.sort {|x,y| y.created_at <=> x.created_at }.each do |e| -%>
|
||||
<% @message.each do |e| -%>
|
||||
<table width="660" border="0" align="left" style="border-bottom: 1px solid rgb(225, 225, 225); margin-bottom: 10px;">
|
||||
<tr>
|
||||
<!-- fq -->
|
||||
|
@ -10,10 +10,19 @@
|
|||
<table width="580" border="0">
|
||||
<tr>
|
||||
<td colspan="2" valign="top"><strong> <%= link_to(h(e.user), user_path(e.user)) %></strong><span class="font_lighter">
|
||||
<% if e.jour_type == "Bid"%>
|
||||
对需求:<%= link_to(e.jour.name, respond_path(e.jour))%>进行了反馈
|
||||
<% elsif e.jour_type == 'Principal' %>
|
||||
对<%= link_to("我", user_path(e.jour))%>的话进行了引用
|
||||
<% if e.instance_of?(JournalsForMessage)%>
|
||||
<% if e.reply_id == User.current.id%>
|
||||
对我的话进行了引用<%if e.jour_type == 'Bid'%><%= link_to('link', respond_path(e.jour))%><% else %><%= link_to('link', feedback_path(e.jour))%><% end %>
|
||||
<% else %>
|
||||
对需求:<%= link_to(e.jour.name, respond_path(e.jour_id))%>进行了反馈
|
||||
<% end %>
|
||||
<% else %>
|
||||
<% if e.journal_reply.nil? || e.journal_reply.reply_id != User.current.id %>
|
||||
对问题:<%= link_to(e.issue.subject, issue_path(e.journalized_id))%>进行了反馈
|
||||
|
||||
<% else %>
|
||||
对我的话进行了引用<%= link_to('link', issue_path(e.issue))%>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</span></td>
|
||||
</tr>
|
||||
|
@ -25,7 +34,7 @@
|
|||
</tr>
|
||||
<tr>
|
||||
<td align="left"><a class="font_lighter"></a></td>
|
||||
<td width="200" align="right" class="a"><span class="font_lighter"><%= format_time e.created_at %></span></td>
|
||||
<td width="200" align="right" class="a"><span class="font_lighter"><%= format_time e.created_on %></span></td>
|
||||
</tr>
|
||||
<!-- <tr><div class="line_under"></div></tr> -->
|
||||
</table></td>
|
||||
|
@ -34,3 +43,8 @@
|
|||
<% end %>
|
||||
</div>
|
||||
<% end %>
|
||||
<div class="pagination">
|
||||
<ul>
|
||||
<%= pagination_links_full @info_pages %>
|
||||
<ul>
|
||||
</div>
|
||||
|
|
|
@ -83,6 +83,7 @@ RedmineApp::Application.routes.draw do
|
|||
match 'user_fanslist', :to => 'users#user_fanslist', :via => :get, :as => "user_fanslist" #add by huang
|
||||
end
|
||||
end
|
||||
match 'users/:id/user_newfeedback', :to => 'users#user_newfeedback', :via => :get, :as => "feedback"
|
||||
#end
|
||||
match 'my/account', :controller => 'my', :action => 'account', :via => [:get, :post]
|
||||
match 'my/account/destroy', :controller => 'my', :action => 'destroy', :via => [:get, :post]
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
class CreateActivities < ActiveRecord::Migration
|
||||
def change
|
||||
create_table :activities, :id => false do |t|
|
||||
t.integer :act_id, :null => false
|
||||
t.string :act_type, :null => false
|
||||
t.integer :user_id, :null => false
|
||||
end
|
||||
add_index :activities, :user_id
|
||||
add_index :activities, [:act_id, :act_type]
|
||||
add_index :activities, [:user_id, :act_type]
|
||||
end
|
||||
end
|
|
@ -0,0 +1,13 @@
|
|||
class CreateJournalReplies < ActiveRecord::Migration
|
||||
def change
|
||||
create_table :journal_replies, :id => false do |t|
|
||||
t.integer :journal_id
|
||||
t.integer :user_id
|
||||
t.integer :reply_id
|
||||
|
||||
end
|
||||
add_index :journal_replies, :user_id
|
||||
add_index :journal_replies, :journal_id
|
||||
add_index :journal_replies, :reply_id
|
||||
end
|
||||
end
|
|
@ -0,0 +1,4 @@
|
|||
class ChangeTimetempInJournalForMessageTable < ActiveRecord::Migration
|
||||
rename_column :journals_for_messages, :created_at, :created_on
|
||||
rename_column :journals_for_messages, :updated_at, :updated_on
|
||||
end
|
58
db/schema.rb
58
db/schema.rb
|
@ -11,7 +11,7 @@
|
|||
#
|
||||
# It's strongly recommended to check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(:version => 20130807021309) do
|
||||
ActiveRecord::Schema.define(:version => 20130811001727) do
|
||||
|
||||
create_table "a_user_watchers", :force => true do |t|
|
||||
t.string "name"
|
||||
|
@ -21,6 +21,16 @@ ActiveRecord::Schema.define(:version => 20130807021309) do
|
|||
t.integer "member_id"
|
||||
end
|
||||
|
||||
create_table "activities", :id => false, :force => true do |t|
|
||||
t.integer "act_id", :null => false
|
||||
t.string "act_type", :null => false
|
||||
t.integer "user_id", :null => false
|
||||
end
|
||||
|
||||
add_index "activities", ["act_id", "act_type"], :name => "index_activities_on_act_id_and_act_type"
|
||||
add_index "activities", ["user_id", "act_type"], :name => "index_activities_on_user_id_and_act_type"
|
||||
add_index "activities", ["user_id"], :name => "index_activities_on_user_id"
|
||||
|
||||
create_table "attachments", :force => true do |t|
|
||||
t.integer "container_id"
|
||||
t.string "container_type", :limit => 30
|
||||
|
@ -60,14 +70,6 @@ ActiveRecord::Schema.define(:version => 20130807021309) do
|
|||
|
||||
add_index "auth_sources", ["id", "type"], :name => "index_auth_sources_on_id_and_type"
|
||||
|
||||
create_table "b_watcher_lists", :force => true do |t|
|
||||
t.string "name"
|
||||
t.integer "user_id"
|
||||
t.string "sexual"
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
end
|
||||
|
||||
create_table "biding_projects", :force => true do |t|
|
||||
t.integer "project_id"
|
||||
t.integer "bid_id"
|
||||
|
@ -322,6 +324,16 @@ ActiveRecord::Schema.define(:version => 20130807021309) do
|
|||
|
||||
add_index "journal_details", ["journal_id"], :name => "journal_details_journal_id"
|
||||
|
||||
create_table "journal_replies", :id => false, :force => true do |t|
|
||||
t.integer "journal_id"
|
||||
t.integer "user_id"
|
||||
t.integer "reply_id"
|
||||
end
|
||||
|
||||
add_index "journal_replies", ["journal_id"], :name => "index_journal_replies_on_journal_id"
|
||||
add_index "journal_replies", ["reply_id"], :name => "index_journal_replies_on_reply_id"
|
||||
add_index "journal_replies", ["user_id"], :name => "index_journal_replies_on_user_id"
|
||||
|
||||
create_table "journals", :force => true do |t|
|
||||
t.integer "journalized_id", :default => 0, :null => false
|
||||
t.string "journalized_type", :limit => 30, :default => "", :null => false
|
||||
|
@ -343,8 +355,8 @@ ActiveRecord::Schema.define(:version => 20130807021309) do
|
|||
t.text "notes"
|
||||
t.integer "status"
|
||||
t.integer "reply_id"
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
t.datetime "created_on", :null => false
|
||||
t.datetime "updated_on", :null => false
|
||||
end
|
||||
|
||||
create_table "member_roles", :force => true do |t|
|
||||
|
@ -450,6 +462,14 @@ ActiveRecord::Schema.define(:version => 20130807021309) do
|
|||
t.datetime "updated_at", :null => false
|
||||
end
|
||||
|
||||
create_table "project_infos", :force => true do |t|
|
||||
t.string "name"
|
||||
t.integer "project_id"
|
||||
t.integer "user_id"
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
end
|
||||
|
||||
create_table "project_tags", :force => true do |t|
|
||||
t.integer "project_id"
|
||||
t.integer "tag_id"
|
||||
|
@ -524,6 +544,7 @@ ActiveRecord::Schema.define(:version => 20130807021309) do
|
|||
t.text "permissions"
|
||||
t.string "issues_visibility", :limit => 30, :default => "default", :null => false
|
||||
end
|
||||
|
||||
create_table "settings", :force => true do |t|
|
||||
t.string "name", :default => "", :null => false
|
||||
t.text "value"
|
||||
|
@ -540,6 +561,7 @@ ActiveRecord::Schema.define(:version => 20130807021309) do
|
|||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
t.integer "project_id"
|
||||
t.integer "user_id"
|
||||
end
|
||||
|
||||
create_table "students", :force => true do |t|
|
||||
|
@ -685,20 +707,6 @@ ActiveRecord::Schema.define(:version => 20130807021309) do
|
|||
add_index "watchers", ["user_id"], :name => "index_watchers_on_user_id"
|
||||
add_index "watchers", ["watchable_id", "watchable_type"], :name => "index_watchers_on_watchable_id_and_watchable_type"
|
||||
|
||||
create_table "watchers_of_projects", :force => true do |t|
|
||||
t.integer "user_id"
|
||||
t.integer "project_id"
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
end
|
||||
|
||||
create_table "watchers_of_users", :force => true do |t|
|
||||
t.integer "watcher_id"
|
||||
t.integer "user_id"
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
end
|
||||
|
||||
create_table "wiki_content_versions", :force => true do |t|
|
||||
t.integer "wiki_content_id", :null => false
|
||||
t.integer "page_id", :null => false
|
||||
|
|
Binary file not shown.
Loading…
Reference in New Issue