From 0541294c33ba8b5926cd5a0f2f3806c0543c2782 Mon Sep 17 00:00:00 2001 From: huang Date: Thu, 31 Dec 2015 17:08:27 +0800 Subject: [PATCH 01/47] =?UTF-8?q?=E4=B8=BA=E8=A7=A3=E5=86=B3=E5=AE=8C?= =?UTF-8?q?=EF=BC=9A=201=E3=80=81user=5Fmessage=5Fsystem=E9=99=84=E4=BB=B6?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E9=97=AE=E9=A2=98=202=E3=80=81issue=E5=9B=9E?= =?UTF-8?q?=E5=A4=8D=E6=B7=BB=E5=8A=A0=E9=99=84=E4=BB=B6=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/issues_controller.rb | 3 ++ app/controllers/system_messages_controller.rb | 2 ++ app/controllers/users_controller.rb | 2 ++ app/models/journal.rb | 7 ++--- app/models/system_message.rb | 1 + app/views/admin/messages.html.erb | 9 ++++++ app/views/attachments/_issue_reply.html.erb | 31 +++++++++++++++++++ app/views/boards/show.html.erb | 1 + app/views/issues/_issue_replies.html.erb | 20 ++++++++---- app/views/issues/add_journal.js.erb | 8 ++--- app/views/users/user_system_messages.html.erb | 13 +++++++- 11 files changed, 82 insertions(+), 15 deletions(-) create mode 100644 app/views/attachments/_issue_reply.html.erb diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb index 77dc1a9aa..5e21251b8 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.rb @@ -137,6 +137,7 @@ class IssuesController < ApplicationController end end # end + @jour_reply = Journal.new @journals = @issue.journals.includes(:user, :details).reorder("#{Journal.table_name}.id ASC").all @journals.each_with_index {|j,i| j.indice = i+1} @journals.reject!(&:private_notes?) unless User.current.allowed_to?(:view_private_notes, @issue.project) @@ -153,6 +154,7 @@ class IssuesController < ApplicationController @project_base_tag = (params[:project_id] || @issue.project) ? 'base_projects':'base'#by young @available_watchers = (@issue.project.users.sort + @issue.watcher_users).uniq + @journal = Journal.new(:journalized => @issue) respond_to do |format| format.html { @@ -401,6 +403,7 @@ class IssuesController < ApplicationController jour.user_id = User.current.id jour.notes = params[:notes] jour.journalized = @issue + jour.save_attachments(params[:attachments]) jour.save user_activity = UserActivity.where("act_type='Issue' and act_id =#{@issue.id}").first user_activity.updated_at = jour.created_on diff --git a/app/controllers/system_messages_controller.rb b/app/controllers/system_messages_controller.rb index 684378e8a..6e9c8ad13 100644 --- a/app/controllers/system_messages_controller.rb +++ b/app/controllers/system_messages_controller.rb @@ -1,4 +1,5 @@ class SystemMessagesController < ApplicationController + # before_filter :message_author, :only => [:show] # # def message_author @@ -41,6 +42,7 @@ class SystemMessagesController < ApplicationController @system_messages.description = params[:system_message][:description] @system_messages.subject = params[:system_message][:subject] @system_messages.user_id = User.current.id + @system_messages.save_attachments(params[:attachments]) respond_to do |format| if @system_messages.save format.html {redirect_to user_system_messages_path(User.current)} diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index f26f6c118..c57478c4a 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -55,6 +55,7 @@ class UsersController < ApplicationController before_filter :recorded_visitor, :only => [:show,:user_fanslist,:user_watchlist,:user_visitorlist] helper :sort + helper :attachments include SortHelper helper :custom_fields include CustomFieldsHelper @@ -63,6 +64,7 @@ class UsersController < ApplicationController include GitlabHelper include UserScoreHelper + include PollHelper helper :user_score helper :journals diff --git a/app/models/journal.rb b/app/models/journal.rb index 638a98006..4ab55c158 100644 --- a/app/models/journal.rb +++ b/app/models/journal.rb @@ -31,9 +31,8 @@ class Journal < ActiveRecord::Base #has_many :forge_acts, :class_name => 'ForgeActivity',:as =>:forge_act ,:dependent => :destroy 评论不应该算入 # 被ForgeMessage虚拟关联 has_many :forge_messages, :class_name => 'ForgeMessage',:as =>:forge_message ,:dependent => :destroy - has_many :at_messages, as: :at_message, dependent: :destroy - + acts_as_attachable attr_accessor :indice acts_as_event :title =>Proc.new {|o| status = ((s = o.new_status) ? " (#{s})" : nil); "#{o.issue.tracker} ##{o.issue.project_index}#{status}: #{o.issue.subject}" }, @@ -46,8 +45,8 @@ class Journal < ActiveRecord::Base acts_as_activity_provider :type => 'issues', :author_key => :user_id, :find_options => {:include => [{:issue => :project}, :details, :user], - :conditions => "#{Journal.table_name}.journalized_type = 'Issue' AND" + - " (#{JournalDetail.table_name}.prop_key = 'status_id' OR #{Journal.table_name}.notes <> '')"} + :conditions => "#{Journal.table_name}.journalized_type = 'Issue' AND" + + "(#{JournalDetail.table_name}.prop_key = 'status_id' OR #{Journal.table_name}.notes <> '')"} before_create :split_private_notes diff --git a/app/models/system_message.rb b/app/models/system_message.rb index a05610da7..65623c104 100644 --- a/app/models/system_message.rb +++ b/app/models/system_message.rb @@ -7,6 +7,7 @@ class SystemMessage < ActiveRecord::Base validates_length_of :description, maximum: 10000 has_many :message_alls, :class_name => 'MessageAll',:as =>:message, :dependent => :destroy + acts_as_attachable # 系统消息放置总消息列表 after_create :add_system_message diff --git a/app/views/admin/messages.html.erb b/app/views/admin/messages.html.erb index e4d053d49..5a8d9e0d2 100644 --- a/app/views/admin/messages.html.erb +++ b/app/views/admin/messages.html.erb @@ -19,6 +19,15 @@

+ +
+
+ <%= render :partial => 'attachments/form', :locals => {:container => @admin_messages} %> +
+
+ +
+
<%= link_to l(:label_submit), "javascript:void(0)", :class => "btn_message_free", :onclick => "system_message_editor.sync();submit_message();" %>
diff --git a/app/views/attachments/_issue_reply.html.erb b/app/views/attachments/_issue_reply.html.erb new file mode 100644 index 000000000..d3232ecf2 --- /dev/null +++ b/app/views/attachments/_issue_reply.html.erb @@ -0,0 +1,31 @@ + + + + "$('#_file').click();">上传附件 + <%= file_field_tag 'attachments[dummy][file]', + :id => "_file", + :class => 'file_selector', + :multiple => true, + :onchange => "addInputFiles_board(this, '#{container.id}');", + :style => 'display:none', + :data => { + :max_file_size => Setting.attachment_max_size.to_i.kilobytes, + :max_file_size_message => l(:error_attachment_too_big, :max_size => number_to_human_size(Setting.attachment_max_size.to_i.kilobytes)), + :max_concurrent_uploads => Redmine::Configuration['max_concurrent_ajax_uploads'].to_i, + :upload_path => uploads_path(:format => 'js'), + :description_placeholder => l(:label_optional_description), + :field_is_public => l(:field_is_public), + :are_you_sure => l(:text_are_you_sure), + :file_count => l(:label_file_count), + :delete_all_files => l(:text_are_you_sure_all), + :lebel_file_uploding => l(:lebel_file_uploding)} %> + <% if container.nil? %> + <%= l(:label_no_file_uploaded) %> + <% end %> + + +<% content_for :header_tags do %> + <%= javascript_include_tag 'attachments' %> +<% end %> + + diff --git a/app/views/boards/show.html.erb b/app/views/boards/show.html.erb index 89f43e0d6..9dd5c78ca 100644 --- a/app/views/boards/show.html.erb +++ b/app/views/boards/show.html.erb @@ -1,3 +1,4 @@ +