From 83ff8a31c144e31f3eb2dad3e3b5177e30a2a3fd Mon Sep 17 00:00:00 2001 From: Administrator Date: Thu, 22 Aug 2013 16:42:13 +0800 Subject: [PATCH] test --- app/models/comment_observer.rb | 5 +- app/models/document_observer.rb | 5 +- app/models/issue_observer.rb | 5 +- app/models/journal_observer.rb | 5 +- app/models/mailer.rb | 2 +- app/models/message_observer.rb | 5 +- app/models/news_observer.rb | 5 +- app/models/user_extension.rb | 11 +++++ app/models/watchers_of_projects.rb | 47 ++++++++++++++++++ app/models/watchers_of_user.rb | 66 ++++++++++++++++++++++++++ app/models/wiki_content_observer.rb | 10 +++- app/views/layouts/_tag.html.erb | 41 ++++++++++++++++ app/views/layouts/_tag_name.html.erb | 55 +++++++++++++++++++++ app/views/tags/_show_results.html.erb | 0 public/images/issues-closed.png | Bin 0 -> 3099 bytes 15 files changed, 253 insertions(+), 9 deletions(-) create mode 100644 app/models/user_extension.rb create mode 100644 app/models/watchers_of_projects.rb create mode 100644 app/models/watchers_of_user.rb create mode 100644 app/views/layouts/_tag.html.erb create mode 100644 app/views/layouts/_tag_name.html.erb create mode 100644 app/views/tags/_show_results.html.erb create mode 100644 public/images/issues-closed.png diff --git a/app/models/comment_observer.rb b/app/models/comment_observer.rb index e7c12c4b6..a46e53ab9 100644 --- a/app/models/comment_observer.rb +++ b/app/models/comment_observer.rb @@ -18,7 +18,10 @@ class CommentObserver < ActiveRecord::Observer def after_create(comment) if comment.commented.is_a?(News) && Setting.notified_events.include?('news_comment_added') - Mailer.news_comment_added(comment).deliver + ##by senluo + thread3=Thread.new do + Mailer.news_comment_added(comment).deliver + end end end end diff --git a/app/models/document_observer.rb b/app/models/document_observer.rb index 4a61f1184..447952c70 100644 --- a/app/models/document_observer.rb +++ b/app/models/document_observer.rb @@ -17,6 +17,9 @@ class DocumentObserver < ActiveRecord::Observer def after_create(document) - Mailer.document_added(document).deliver if Setting.notified_events.include?('document_added') + ##by senluo + thread2=Thread.new do + Mailer.document_added(document).deliver if Setting.notified_events.include?('document_added') + end end end diff --git a/app/models/issue_observer.rb b/app/models/issue_observer.rb index a75194286..3369387ee 100644 --- a/app/models/issue_observer.rb +++ b/app/models/issue_observer.rb @@ -16,7 +16,10 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. class IssueObserver < ActiveRecord::Observer + def after_create(issue) - Mailer.issue_add(issue).deliver if Setting.notified_events.include?('issue_added') + thread1=Thread.new do + Mailer.issue_add(issue).deliver if Setting.notified_events.include?('issue_added') + end end end diff --git a/app/models/journal_observer.rb b/app/models/journal_observer.rb index fe937de07..cdd23bc7c 100644 --- a/app/models/journal_observer.rb +++ b/app/models/journal_observer.rb @@ -23,7 +23,10 @@ class JournalObserver < ActiveRecord::Observer (Setting.notified_events.include?('issue_status_updated') && journal.new_status.present?) || (Setting.notified_events.include?('issue_priority_updated') && journal.new_value_for('priority_id').present?) ) - Mailer.issue_edit(journal).deliver + ##by senluo + thread4=Thread.new do + Mailer.issue_edit(journal).deliver + end end end end diff --git a/app/models/mailer.rb b/app/models/mailer.rb index 7166025c2..1db19f14e 100644 --- a/app/models/mailer.rb +++ b/app/models/mailer.rb @@ -294,7 +294,7 @@ class Mailer < ActionMailer::Base set_language_if_valid(user.language) @url = url_for(:controller => 'welcome') mail :to => user.mail, - :subject => 'Redmine test' + :subject => 'forge test' end # Overrides default deliver! method to prevent from sending an email diff --git a/app/models/message_observer.rb b/app/models/message_observer.rb index 9ef52b6b4..383301664 100644 --- a/app/models/message_observer.rb +++ b/app/models/message_observer.rb @@ -17,6 +17,9 @@ class MessageObserver < ActiveRecord::Observer def after_create(message) - Mailer.message_posted(message).deliver if Setting.notified_events.include?('message_posted') + ##by senluo + thread5=Thread.new do + Mailer.message_posted(message).deliver if Setting.notified_events.include?('message_posted') + end end end diff --git a/app/models/news_observer.rb b/app/models/news_observer.rb index 8ba3894f4..8b9bc7b4b 100644 --- a/app/models/news_observer.rb +++ b/app/models/news_observer.rb @@ -17,6 +17,9 @@ class NewsObserver < ActiveRecord::Observer def after_create(news) - Mailer.news_added(news).deliver if Setting.notified_events.include?('news_added') + ##by senluo + thread6=Thread.new do + Mailer.news_added(news).deliver if Setting.notified_events.include?('news_added') + end end end diff --git a/app/models/user_extension.rb b/app/models/user_extension.rb new file mode 100644 index 000000000..cdfad28c6 --- /dev/null +++ b/app/models/user_extension.rb @@ -0,0 +1,11 @@ +class UserExtension < ActiveRecord::Base + attr_accessible :birthday, :brief_introduction, :fans_num, :finish_project_num, :follow_num, :gender, :good_num, :location, :occupation, :publish_requirement_num, :user_id, :work_experience, :zip_code + + belongs_to :user + validate :validate_user + + def validate_user + errors.add :user_id, :invalid if user.nil? || !user.active? || User.current != user_id + end + +end diff --git a/app/models/watchers_of_projects.rb b/app/models/watchers_of_projects.rb new file mode 100644 index 000000000..4a767aaee --- /dev/null +++ b/app/models/watchers_of_projects.rb @@ -0,0 +1,47 @@ +# fq +class WatchersOfProjects < ActiveRecord::Base + attr_accessible :project_id, :user_id + belongs_to :project + belongs_to :user + + validate :validate_user + validate :validate_project + validates_uniqueness_of :user_id, :scope => :project_id + validates_presence_of :user_id, :project_id + + def self.watch(user_id, project_id) + @new_watch = WatchersOfProjects.new + @new_watch.user_id = user_id + @new_watch.project_id = project_id + @new_watch.save + true + end + + def self.watcher_count(project) + @project = project + @count = @project.watchers_of_projects.count + @count + end + + def self.is_watched(user_id, project_id) + @is_watched = self.where("user_id = ? and project_id = ?", user_id, project_id).to_a.first + if @is_watched.nil? + false + else + true + end + end + + def self.watch_cancle(user_id, project_id) + self.delete_all(["user_id = ? and project_id = ?", user_id, project_id]) + true + end + + def validate_user + errors.add :user_id, :invalid if user.nil? || !user.active? + end + + def validate_project + errors.add :project_id, :invalid if project.nil? + end +end diff --git a/app/models/watchers_of_user.rb b/app/models/watchers_of_user.rb new file mode 100644 index 000000000..527b092c8 --- /dev/null +++ b/app/models/watchers_of_user.rb @@ -0,0 +1,66 @@ +# fq +class WatchersOfUser < ActiveRecord::Base + attr_accessible :user_id, :watcher_id + belongs_to :user + + validates_uniqueness_of :watcher_id, :scope => :user_id + validate :validate_user + validate :validate_watcher + validates_presence_of :watcher_id, :user_id + + def self.watch_user(watcher_id, user_id) + unless user_id == watcher_id + @watchers_of_user = WatchersOfUser.new + @watchers_of_user.watcher_id = watcher_id + @watchers_of_user.user_id = user_id + @watchers_of_user.save + true + else + false + end + end + + def cancel_watching_user + self.class.cancel_watching_user(self.watcher_id, self.user_id) + end + + def self.cancel_watching_user(watcher_id, user_id) + self.delete_all(["user_id = ? and watcher_id = ?", user_id, watcher_id]) + true + end + + def self.find_users(watcher_id) + @user = WatchersOfUser.find_by_sql("select * from users where id in (select user_id from #{WatchersOfUser.table_name} where watcher_id = #{watcher_id})") + @user + # @watch_table_for_user=WatchersOfUser.where(:watcher_id => watcher_id) + # @user = [] + # @watch_table_for_user.each do |watch| + # @user.push(watch.user) + # end + # @user + end + + def self.find_watchers(user_id) + @watcher = WatchersOfUser.find_by_sql("select * from users where id in (select watcher_id from #{WatchersOfUser.table_name} where user_id = #{user_id})") + @watcher + # user = User.find(user_id) + # @watch_table_for_watcher = user.watchers_of_users + # @watcher = [] + # @watch_table_for_watcher.each do |watch| + # user_temp = User.find(watch.watcher_id) + # @watcher.push(user_temp) + # end + # @watcher + end + + #验证user是否存在 + def validate_user + errors.add :user_id, :invalid if user.nil? || !user.active? + end + + #验证watcher是否存在 + def validate_watcher + user = User.where("id = ?", watcher_id).to_a.first + errors.add :watcher_id, :invalid if user.nil? || !user.active? + end +end diff --git a/app/models/wiki_content_observer.rb b/app/models/wiki_content_observer.rb index 6219f407b..187c02288 100644 --- a/app/models/wiki_content_observer.rb +++ b/app/models/wiki_content_observer.rb @@ -17,12 +17,18 @@ class WikiContentObserver < ActiveRecord::Observer def after_create(wiki_content) - Mailer.wiki_content_added(wiki_content).deliver if Setting.notified_events.include?('wiki_content_added') + ##by senluo + thread7=Thread.new do + Mailer.wiki_content_added(wiki_content).deliver if Setting.notified_events.include?('wiki_content_added') + end end def after_update(wiki_content) if wiki_content.text_changed? - Mailer.wiki_content_updated(wiki_content).deliver if Setting.notified_events.include?('wiki_content_updated') + ##by senluo + thread8=Thread.new do + Mailer.wiki_content_updated(wiki_content).deliver if Setting.notified_events.include?('wiki_content_updated') + end end end end diff --git a/app/views/layouts/_tag.html.erb b/app/views/layouts/_tag.html.erb new file mode 100644 index 000000000..e0e2b49fd --- /dev/null +++ b/app/views/layouts/_tag.html.erb @@ -0,0 +1,41 @@ +
+ <%= tag('img', {:src => "/images/sidebar/tags.png"}, false, false) %> + + + + <% if object_flag == '3' %> + <%= toggle_link (image_tag "/images/sidebar/add.png"), 'put-tag-form-issue', {:focus => 'name-issue'} %> +
+ <%= render :partial => "layouts/tag_name",:locals => {:obj => obj,:non_list_all => false ,:object_flag => object_flag} %> +
+ +
+ +<% else %> +<%= toggle_link (image_tag "/images/sidebar/add.png"), 'put-tag-form', {:focus => 'name'} %> +
+ <%= render :partial => "layouts/tag_name",:locals => {:obj => obj,:non_list_all => false ,:object_flag => object_flag} %> +
+ + +<% end %> diff --git a/app/views/layouts/_tag_name.html.erb b/app/views/layouts/_tag_name.html.erb new file mode 100644 index 000000000..6a54878ed --- /dev/null +++ b/app/views/layouts/_tag_name.html.erb @@ -0,0 +1,55 @@ + + +<% @tags = obj.reload.tag_list %> + +<% if non_list_all and (@tags.size > 0) %> + + <% if @tags.size > Setting.show_tags_length.to_i then %> + <% i = 0 %> + <% until i>Setting.show_tags_length.to_i do %> +
+ <%= link_to @tags[i], :controller => "tags",:action => "index",:q => @tags[i],:object_flag => object_flag,:obj_id => obj.id %> +
+ <% i += 1%> + <% end %> + <%= link_to l(:label_more_tags),:action => "show",:id => obj.id %> + + <% else %> + + <% @tags.each do |tag| %> +
+ <%= link_to tag,:controller => "tags",:action => "index",:q=>tag,:object_flag => object_flag,:obj_id => obj.id + %> +
+ <% end %> + <% end %> + +<% else %> + + <% if @tags.size > 0 %> + <% @tags.each do |tag| %> +
+ <%= link_to tag,:controller => "tags",:action => "index",:q=>tag ,:object_flag => object_flag,:obj_id => obj.id %> +
+ <% end %> + <% end %> + +<% end %> \ No newline at end of file diff --git a/app/views/tags/_show_results.html.erb b/app/views/tags/_show_results.html.erb new file mode 100644 index 000000000..e69de29bb diff --git a/public/images/issues-closed.png b/public/images/issues-closed.png new file mode 100644 index 0000000000000000000000000000000000000000..167048fefc950b5b76a20d4635dd797aa70ce171 GIT binary patch literal 3099 zcmV+$4CM2PP)KLZ*U+5Lu!Sk^o_Z5E4Meg@_7P6crJiNL9pw)e1;Xm069{HJUZAPk55R%$-RIA z6-eL&AQ0xu!e<4=008gy@A0LT~suv4>S3ILP<0Bm`DLLvaF4FK%)Nj?Pt*r}7;7Xa9z9H|HZjR63e zC`Tj$K)V27Re@400>HumpsYY5E(E}?0f1SyGDiY{y#)Yvj#!WnKwtoXnL;eg03bL5 z07D)V%>y7z1E4U{zu>7~aD})?0RX_umCct+(lZpemCzb@^6=o|A>zVpu|i=NDG+7} zl4`aK{0#b-!z=TL9Wt0BGO&T{GJWpjryhdijfaIQ&2!o}p04JRKYg3k&Tf zVxhe-O!X z{f;To;xw^bEES6JSc$k$B2CA6xl)ltA<32E66t?3@gJ7`36pmX0IY^jz)rRYwaaY4 ze(nJRiw;=Qb^t(r^DT@T3y}a2XEZW-_W%Hszxj_qD**t_m!#tW0KDiJT&R>6OvVTR z07RgHDzHHZ48atvzz&?j9lXF70$~P3Knx_nJP<+#`N z#-MZ2bTkiLfR>_b(HgWKJ%F~Nr_oF3b#wrIijHG|(J>BYjM-sajE6;FiC7vY#};Gd zST$CUHDeuEH+B^pz@B062qXfFfD`NpUW5?BY=V%GM_5c)L#QR}BeW8_2v-S%gfYS= zB9o|3v?Y2H`NVi)In3rTB8+ej^> zQ=~r95NVuDChL%G$=>7$vVg20myx%S50Foi`^m%Pw-h?Xh~i8Mq9jtJloCocWk2Nv zrJpiFnV_ms&8eQ$2&#xWpIS+6pmtC%Q-`S&GF4Q#^mhymh7E(qNMa}%Y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