diff --git a/app/models/comment_observer.rb b/app/models/comment_observer.rb index e7c12c4b..a46e53ab 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 4a61f118..447952c7 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 a7519428..3369387e 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 fe937de0..cdd23bc7 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 7166025c..1db19f14 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 9ef52b6b..38330166 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 8ba3894f..8b9bc7b4 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 00000000..cdfad28c --- /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 00000000..4a767aae --- /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 00000000..527b092c --- /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 6219f407..187c0228 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 00000000..e0e2b49f --- /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 00000000..6a54878e --- /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 00000000..e69de29b diff --git a/public/images/issues-closed.png b/public/images/issues-closed.png new file mode 100644 index 00000000..167048fe Binary files /dev/null and b/public/images/issues-closed.png differ