diff --git a/Gemfile b/Gemfile index 2b43cade3..01671daf9 100644 --- a/Gemfile +++ b/Gemfile @@ -6,6 +6,7 @@ unless RUBY_PLATFORM =~ /w32/ gem 'iconv' end +gem 'grack', path:'./lib/grack' gem 'rest-client' gem "mysql2", "= 0.3.18" gem 'redis-rails' diff --git a/app/controllers/boards_controller.rb b/app/controllers/boards_controller.rb index 6ff4d2f97..72301754d 100644 --- a/app/controllers/boards_controller.rb +++ b/app/controllers/boards_controller.rb @@ -67,7 +67,29 @@ class BoardsController < ApplicationController end - def show + def show + #更新对应的forge_messages表的viewed字段 + if @project + query_forge_messages = @board.messages + query_forge_messages.each do |query_forge_message| + query = query_forge_message.forge_messages + query.each do |forge_message| + if User.current.id == forge_message.user_id + forge_message.update_attributes(:viewed => true) + end + end + end + elsif @course + query_course_messages = @board.messages + query_course_messages.each do |query_course_message| + query = query_course_message.course_messages + query.each do |course_message| + if User.current.id == course_message.user_id + course_message.update_attributes(:viewed => true) + end + end + end + end respond_to do |format| format.js format.html { diff --git a/app/controllers/news_controller.rb b/app/controllers/news_controller.rb index 1a8e75b54..d445fc77c 100644 --- a/app/controllers/news_controller.rb +++ b/app/controllers/news_controller.rb @@ -99,6 +99,31 @@ class NewsController < ApplicationController end def show + #鏇存柊news瀵瑰簲鐨刦orge_messages鐨剉iewed瀛楁 + query_forge_news = @news.forge_messages + query_forge_news.each do |query| + if User.current.id == query.user_id + query.update_attributes(:viewed => true) + end + end + #鏇存柊news瀵瑰簲鐨刢ourse_messages鐨剉iewed瀛楁 + query_course_news = @news.course_messages + query_course_news.each do |query| + if User.current.id == query.user_id + query.update_attributes(:viewed => true) + end + end + #鏇存柊椤圭洰鏂伴椈鐨勮瘎闃呯殑viewed瀛楁 + current_forge_comments = @news.comments + current_forge_comments.each do |current_forge_comment| + query_forge_comment = current_forge_comment.forge_messages + query_forge_comment.each do |query| + if User.current.id == query.user_id + query.update_attributes(:viewed => true) + end + end + end + cs = CoursesService.new result = cs.show_course_news params,User.current @news = result[:news] diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index e0aea0c2e..6dec9a82f 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -127,19 +127,18 @@ update end else # 鍘熼昏緫 ##xianbo + params[:repository_scm] = "Git" @root_path=RepositoriesHelper::ROOT_PATH @repository_name=User.current.login.to_s+"/"+params[:repository][:identifier]+".git" @project_path=@root_path+"htdocs/"+@repository_name - @repository_tag=params[:repository][:upassword] || params[:repository][:password] + @repository_tag=params[:repository][:upassword] || params[:repository][:password] || '1234' @repo_name=User.current.login.to_s+"_"+params[:repository][:identifier] logger.info "htpasswd -mb "+@root_path+"htdocs/user.passwd "+@repo_name+": "+@repository_tag logger.info "the value of create repository"+@root_path+": "+@repository_name+": "+@project_path+": "+@repo_name attrs = pickup_extra_info - if((@repository_tag!="")&¶ms[:repository_scm]=="Git") - params[:repository][:url]=@project_path - end + params[:repository][:url]=@project_path ###xianbo - @repository = Repository.factory(params[:repository_scm]) + @repository = Repository.factory(params[:repository_scm]||"Git") @repository.safe_attributes = params[:repository] if attrs[:attrs_extra].keys.any? @repository.merge_extra_info(attrs[:attrs_extra]) @@ -278,7 +277,8 @@ update @course_tag = params[:course] project_path_cut = RepositoriesHelper::PROJECT_PATH_CUT ip = RepositoriesHelper::REPO_IP_ADDRESS - @repos_url = "http://"+@repository.login.to_s+"_"+@repository.identifier.to_s+"@"+ip.to_s+ + # @repos_url = "http://"+@repository.login.to_s+"_"+@repository.identifier.to_s+"@"+ip.to_s+ + @repos_url = "http://#{Setting.host_name}/#{@repository.login.to_s}/#{@repository.identifier.to_s}.git" @repository.url.slice(project_path_cut, @repository.url.length).to_s if @course_tag == 1 render :action => 'show', :layout => 'base_courses' diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 1aa8de526..50496fbf8 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -45,14 +45,14 @@ class UsersController < ApplicationController :activity_new_score_index, :influence_new_score_index, :score_new_index,:update_score,:user_activities,:user_projects_index, :user_courses4show,:user_projects4show,:user_course_activities,:user_project_activities,:user_feedback4show,:user_visitorlist, :user_resource,:user_resource_create,:user_resource_delete,:rename_resource,:search_user_course,:add_exist_file_to_course, - :search_user_project,:resource_preview,:resource_search,:add_exist_file_to_project] + :search_user_project,:resource_preview,:resource_search,:add_exist_file_to_project,:user_messages, :user_messages_new] #edit has been deleted by huang, 2013-9-23 before_filter :find_user, :only => [:user_fanslist, :user_watchlist, :show, :edit, :update, :destroy, :edit_membership, :user_courses, :user_homeworks, :destroy_membership, :user_activities, :user_projects, :user_newfeedback, :user_comments, :watch_contests, :info, :watch_projects, :show_score, :topic_score_index, :project_score_index, :activity_score_index, :influence_score_index, :score_index,:show_new_score, :topic_new_score_index, :project_new_score_index, :activity_new_score_index, :influence_new_score_index, :score_new_index,:user_projects_index,:user_resource, - :user_courses4show,:user_projects4show,:user_course_activities,:user_project_activities,:user_feedback4show,:user_visitorlist,:user_messages] + :user_courses4show,:user_projects4show,:user_course_activities,:user_project_activities,:user_feedback4show,:user_visitorlist,:user_messages,:edit_brief_introduction, :user_messages_new] before_filter :auth_user_extension, only: :show #before_filter :rest_user_score, only: :show #before_filter :select_entry, only: :user_projects @@ -122,62 +122,165 @@ class UsersController < ApplicationController @new_message_count = @user.forge_messages.count + @user.memo_messages.count + @user.course_messages.count + @user.user_feedback_messages.count case params[:type] when nil - @user_course_messages = CourseMessage.where("user_id =?",@user).order("created_at desc") - @user_forge_messages = ForgeMessage.where("user_id =?",@user).order("created_at desc") - @user_memo_messages = MemoMessage.where("user_id =?",@user).order("created_at desc") - @user_feedback_messages = UserFeedbackMessage.where("user_id =?",@user).order("created_at desc") - @user_course_messages_count = @user_course_messages.count - @user_forge_messages_count = @user_forge_messages.count - @user_memo_messages_count = @user_memo_messages.count - @user_feedback_messages_count = @user_feedback_messages.count + @message_alls = [] + messages = MessageAll.where("user_id =?",@user).order("created_at desc") + messages.each do |message_all| + @message_alls << message_all.message + end + + # @user_course_messages = MessageAll.where("user_id =? and message_type=?",@user,"CourseMessage").order("created_at desc") + # @user_forge_messages = MessageAll.where("user_id =? and message_type=?",@user,"ForgeMessage").order("created_at desc") + # @user_memo_messages = MessageAll.where("user_id =? and message_type=?",@user,"MemoMessage").order("created_at desc") + # @user_feedback_messages = MessageAll.where("user_id =? and message_type=?",@user,"UserFeedbackMessage").order("created_at desc") + # @user_course_messages_count = @user_course_messages.count + # @user_forge_messages_count = @user_forge_messages.count + # @user_memo_messages_count = @user_memo_messages.count + # @user_feedback_messages_count = @user_feedback_messages.count when 'homework' - @user_course_messages = CourseMessage.where("course_message_type =? and user_id =?", "HomeworkCommon", @user).order("created_at desc") - @user_course_messages_count = @user_course_messages.count + @message_alls = CourseMessage.where("course_message_type =? and user_id =?", "HomeworkCommon", @user).order("created_at desc") + @message_alls_count = @message_alls.count + #@user_course_messages_count = @user_course_messages.count when 'course_message' - @user_course_messages = CourseMessage.where("course_message_type =? and user_id =?", "Message", @user).order("created_at desc") - @user_course_messages_count = @user_course_messages.count + @message_alls = CourseMessage.where("course_message_type =? and user_id =?", "Message", @user).order("created_at desc") + @message_alls_count = @message_alls.count + #@user_course_messages_count = @user_course_messages.count when 'forge_message' - @user_forge_messages = ForgeMessage.where("forge_message_type =? and user_id =?", "Message", @user).order("created_at desc") - @user_forge_messages_count = @user_forge_messages.count + @message_alls = ForgeMessage.where("forge_message_type =? and user_id =?", "Message", @user).order("created_at desc") + @message_alls_count = @message_alls.count + #@user_forge_messages_count = @user_forge_messages.count when 'course_news' - @user_course_messages = CourseMessage.where("course_message_type =? and user_id =?", "News", @user).order("created_at desc") - @user_course_messages_count = @user_course_messages.count + @message_alls = CourseMessage.where("course_message_type =? and user_id =?", "News", @user).order("created_at desc") + @message_alls_count = @message_alls.count + #@user_course_messages_count = @user_course_messages.count when 'forge_news' - @user_forge_messages = ForgeMessage.where("forge_message_type =? and user_id =?", "News", @user).order("created_at desc") - @user_forge_messages_count = @user_forge_messages.count + @message_alls = ForgeMessage.where("forge_message_type =? and user_id =?", "News", @user).order("created_at desc") + @message_alls_count = @message_alls.count + #@user_forge_messages_count = @user_forge_messages.count when 'course_news_reply' - @user_course_messages = CourseMessage.where("course_message_type =? and user_id =?", "Comment", @user).order("created_at desc") - @user_course_messages_count = @user_course_messages.count + @message_alls = CourseMessage.where("course_message_type =? and user_id =?", "Comment", @user).order("created_at desc") + #@user_course_messages_count = @user_course_messages.count when 'forge_news_reply' - @user_forge_messages = ForgeMessage.where("course_message_type =? and user_id =?", "Comment", @user).order("created_at desc") - @user_forge_messagess_count = @user_forge_messages.count + @message_alls = ForgeMessage.where("forge_message_type =? and user_id =?", "Comment", @user).order("created_at desc") + @message_alls_count = @message_alls.count + #@user_forge_messagess_count = @user_forge_messages.count when 'poll' - @user_course_messages = CourseMessage.where("course_message_type =? and user_id =?", "Poll", @user).order("created_at desc") - @user_course_messages_count = @user_course_messages.count + @message_alls = CourseMessage.where("course_message_type =? and user_id =?", "Poll", @user).order("created_at desc") + @message_alls_count = @message_alls.count + #@user_course_messages_count = @user_course_messages.count when 'works_reviewers' - @user_course_messages = CourseMessage.where("course_message_type =? and user_id =?", "StudentWorksScore", @user).order("created_at desc") - @user_course_messages_count = @user_course_messages.count + @message_alls = CourseMessage.where("course_message_type =? and user_id =?", "StudentWorksScore", @user).order("created_at desc") + @message_alls_count = @message_alls.count + #@user_course_messages_count = @user_course_messages.count when 'works_reply' - @user_course_messages = CourseMessage.where("course_message_type =? and user_id =?", "JournalsForMessage", @user).order("created_at desc") - @user_course_messages_count = @user_course_messages.count + @message_alls = CourseMessage.where("course_message_type =? and user_id =?", "JournalsForMessage", @user).order("created_at desc") + @message_alls_count = @message_alls.count + #@user_course_messages_count = @user_course_messages.count when 'issue' - @user_forge_messages = ForgeMessage.where("forge_message_type =? and user_id =?", "Issue", @user).order("created_at desc") - @user_forge_messages_count = @user_forge_messages.count + @message_alls = ForgeMessage.where("forge_message_type =? and user_id =?", "Issue", @user).order("created_at desc") + @message_alls_count = @message_alls.count + #@user_forge_messages_count = @user_forge_messages.count when 'issue_update' # 缂洪櫡鐘舵佹洿鏂般佺暀瑷 - @user_forge_messages = ForgeMessage.where("forge_message_type =? and user_id =?", "Journal", @user).order("created_at desc") - @user_forge_messages_count = @user_forge_messages.count + @message_alls = ForgeMessage.where("forge_message_type =? and user_id =?", "Journal", @user).order("created_at desc") + @message_alls_count = @message_alls.count + #@user_forge_messages_count = @user_forge_messages.count when 'forum' - @user_memo_messages = MemoMessage.where("memo_type =? and user_id =?", "Memo", @user).order("created_at desc") - @user_memo_messages_count = @user_memo_messages.count + @message_alls = MemoMessage.where("memo_type =? and user_id =?", "Memo", @user).order("created_at desc") + @message_alls_count = @message_alls.count + #@user_memo_messages_count = @user_memo_messages.count when 'user_feedback' - @user_feedback_messages = UserFeedbackMessage.where("journals_for_message_type =? and user_id =?", "Principal", @user).order("created_at desc") - @user_feedback_messages_count = @user_feedback_messages.count + @message_alls = UserFeedbackMessage.where("journals_for_message_type =? and user_id =?", "JournalsForMessage", @user).order("created_at desc") + @message_alls_count = @message_alls.count + #@user_feedback_messages_count = @user_feedback_messages.count else render_404 return end respond_to do |format| - format.html{render :layout=>'base_users_new'} + format.html{render :layout=>'new_base_user'} + end + end + + def user_messages_new + unless User.current.logged? + render_403 + return + end + # 褰撳墠鐢ㄦ埛鏌ョ湅娑堟伅锛屽垯璁剧疆娑堟伅涓哄凡璇 + course_querys = @user.course_messages + forge_querys = @user.forge_messages + user_querys = @user.user_feedback_messages + forum_querys = @user.memo_messages + # if User.current.id == @user.id + # course_querys.update_all(:viewed => true) + # forge_querys.update_all(:viewed => true) + # user_querys.update_all(:viewed => true) + # forum_querys.update_all(:viewed => true) + # end + @new_message_count = @user.forge_messages.count + @user.memo_messages.count + @user.course_messages.count + @user.user_feedback_messages.count + case params[:type] + when nil + @message_alls = [] + messages = MessageAll.where("user_id =?",@user).order("created_at desc") + messages.each do |message_all| + @message_alls << message_all.message + end + + # @user_course_messages = MessageAll.where("user_id =? and message_type=?",@user,"CourseMessage").order("created_at desc") + # @user_forge_messages = MessageAll.where("user_id =? and message_type=?",@user,"ForgeMessage").order("created_at desc") + # @user_memo_messages = MessageAll.where("user_id =? and message_type=?",@user,"MemoMessage").order("created_at desc") + # @user_feedback_messages = MessageAll.where("user_id =? and message_type=?",@user,"UserFeedbackMessage").order("created_at desc") + # @user_course_messages_count = @user_course_messages.count + # @user_forge_messages_count = @user_forge_messages.count + # @user_memo_messages_count = @user_memo_messages.count + # @user_feedback_messages_count = @user_feedback_messages.count + when 'homework' + @message_alls = CourseMessage.where("course_message_type =? and user_id =?", "HomeworkCommon", @user).order("created_at desc") + #@user_course_messages_count = @user_course_messages.count + when 'course_message' + @message_alls = CourseMessage.where("course_message_type =? and user_id =?", "Message", @user).order("created_at desc") + #@user_course_messages_count = @user_course_messages.count + when 'forge_message' + @message_alls = ForgeMessage.where("forge_message_type =? and user_id =?", "Message", @user).order("created_at desc") + #@user_forge_messages_count = @user_forge_messages.count + when 'course_news' + @message_alls = CourseMessage.where("course_message_type =? and user_id =?", "News", @user).order("created_at desc") + #@user_course_messages_count = @user_course_messages.count + when 'forge_news' + @message_alls = ForgeMessage.where("forge_message_type =? and user_id =?", "News", @user).order("created_at desc") + #@user_forge_messages_count = @user_forge_messages.count + when 'course_news_reply' + @message_alls = CourseMessage.where("course_message_type =? and user_id =?", "Comment", @user).order("created_at desc") + #@user_course_messages_count = @user_course_messages.count + when 'forge_news_reply' + @message_alls = ForgeMessage.where("forge_message_type =? and user_id =?", "Comment", @user).order("created_at desc") + #@user_forge_messagess_count = @user_forge_messages.count + when 'poll' + @message_alls = CourseMessage.where("course_message_type =? and user_id =?", "Poll", @user).order("created_at desc") + #@user_course_messages_count = @user_course_messages.count + when 'works_reviewers' + @message_alls = CourseMessage.where("course_message_type =? and user_id =?", "StudentWorksScore", @user).order("created_at desc") + #@user_course_messages_count = @user_course_messages.count + when 'works_reply' + @message_alls = CourseMessage.where("course_message_type =? and user_id =?", "JournalsForMessage", @user).order("created_at desc") + #@user_course_messages_count = @user_course_messages.count + when 'issue' + @message_alls = ForgeMessage.where("forge_message_type =? and user_id =?", "Issue", @user).order("created_at desc") + #@user_forge_messages_count = @user_forge_messages.count + when 'issue_update' # 缂洪櫡鐘舵佹洿鏂般佺暀瑷 + @message_alls = ForgeMessage.where("forge_message_type =? and user_id =?", "Journal", @user).order("created_at desc") + #@user_forge_messages_count = @user_forge_messages.count + when 'forum' + @message_alls = MemoMessage.where("memo_type =? and user_id =?", "Memo", @user).order("created_at desc") + #@user_memo_messages_count = @user_memo_messages.count + when 'user_feedback' + @message_alls = UserFeedbackMessage.where("journals_for_message_type =? and user_id =?", "JournalsForMessage", @user).order("created_at desc") + #@user_feedback_messages_count = @user_feedback_messages.count + else + render_404 + return + end + respond_to do |format| + format.html{render :layout=>'new_base_user'} end end @@ -584,7 +687,7 @@ class UsersController < ApplicationController end def show - render :layout=>'base_users_new' + render :layout=>'new_base_user' end def show_old @@ -1362,6 +1465,16 @@ class UsersController < ApplicationController @user = User.find(params[:id]) end + #淇敼涓汉绠浠 + def edit_brief_introduction + if @user && @user.extensions + @user.extensions.update_column("brief_introduction",params[:brief_introduction]) + end + respond_to do |format| + format.js + end + end + # 璧勬簮搴 鍒嗕负鍏ㄩ儴 璇剧▼璧勬簮 椤圭洰璧勬簮 闄勪欢 def user_resource #纭畾container_type @@ -1414,7 +1527,7 @@ class UsersController < ApplicationController @attachments = paginateHelper @attachments,15 respond_to do |format| format.js - format.html {render :layout => 'base_users_new'} + format.html {render :layout => 'new_base_user'} end end diff --git a/app/helpers/repositories_helper.rb b/app/helpers/repositories_helper.rb index c77eba0c5..710b7488f 100644 --- a/app/helpers/repositories_helper.rb +++ b/app/helpers/repositories_helper.rb @@ -19,7 +19,7 @@ module RepositoriesHelper if Rails.env.development? - ROOT_PATH="/tmp/" if Rails.env.development? + ROOT_PATH="/private/tmp/" else ROOT_PATH="/home/pdl/redmine-2.3.2-0/apache2/" end diff --git a/app/models/course_activity.rb b/app/models/course_activity.rb index 02b6dacf1..cf356dc05 100644 --- a/app/models/course_activity.rb +++ b/app/models/course_activity.rb @@ -4,4 +4,27 @@ class CourseActivity < ActiveRecord::Base belongs_to :course_act ,:polymorphic => true belongs_to :course belongs_to :user + has_many :user_acts, :class_name => 'UserAcivity',:as =>:act + after_save :add_user_activity + before_destroy :destroy_user_activity + + #鍦ㄤ釜浜哄姩鎬侀噷闈㈠鍔犲綋鍓嶅姩鎬 + def add_user_activity + user_activity = UserActivity.where("act_type = '#{self.class.to_s}' and act_id = '#{self.id}'").first + if user_activity + user_activity.save + else + user_activity = UserActivity.new + user_activity.act_id = self.id + user_activity.act_type = self.class.to_s + user_activity.container_type = "Course" + user_activity.container_id = self.course_id + user_activity.save + end + end + + def destroy_user_activity + user_activity = UserActivity.where("act_type = '#{self.class.to_s}' and act_id = '#{self.id}'") + user_activity.destroy_all + end end diff --git a/app/models/course_message.rb b/app/models/course_message.rb index 59089829d..c15c2fc65 100644 --- a/app/models/course_message.rb +++ b/app/models/course_message.rb @@ -5,8 +5,15 @@ class CourseMessage < ActiveRecord::Base belongs_to :course_message ,:polymorphic => true belongs_to :course belongs_to :user + has_many :message_alls, :class_name => 'MessageAll',:as =>:message, :dependent => :destroy + validates :user_id,presence: true validates :course_id,presence: true validates :course_message_id,presence: true validates :course_message_type, presence: true + after_create :add_user_message + + def add_user_message + self.message_alls << MessageAll.new(:user_id => self.user_id) + end end diff --git a/app/models/forge_activity.rb b/app/models/forge_activity.rb index 6b75552c0..5d8de8e3a 100644 --- a/app/models/forge_activity.rb +++ b/app/models/forge_activity.rb @@ -19,5 +19,27 @@ class ForgeActivity < ActiveRecord::Base validates :project_id,presence: true validates :forge_act_id,presence: true validates :forge_act_type, presence: true + has_many :user_acts, :class_name => 'UserAcivity',:as =>:act + after_save :add_user_activity + before_destroy :destroy_user_activity + #鍦ㄤ釜浜哄姩鎬侀噷闈㈠鍔犲綋鍓嶅姩鎬 + def add_user_activity + user_activity = UserActivity.where("act_type = '#{self.class.to_s}' and act_id = '#{self.id}'").first + if user_activity + user_activity.save + else + user_activity = UserActivity.new + user_activity.act_id = self.id + user_activity.act_type = self.class.to_s + user_activity.container_type = "Project" + user_activity.container_id = self.project_id + user_activity.save + end + end + + def destroy_user_activity + user_activity = UserActivity.where("act_type = '#{self.class.to_s}' and act_id = '#{self.id}'") + user_activity.destroy_all + end end diff --git a/app/models/forge_message.rb b/app/models/forge_message.rb index 1543fab58..2d05972ab 100644 --- a/app/models/forge_message.rb +++ b/app/models/forge_message.rb @@ -13,8 +13,15 @@ class ForgeMessage < ActiveRecord::Base belongs_to :forge_message ,:polymorphic => true belongs_to :project belongs_to :user + has_many :message_alls, :class_name => 'MessageAll',:as =>:message, :dependent => :destroy + validates :user_id,presence: true validates :project_id,presence: true validates :forge_message_id,presence: true validates :forge_message_type, presence: true + after_create :add_user_message + + def add_user_message + self.message_alls << MessageAll.new(:user_id => self.user_id) + end end diff --git a/app/models/issue.rb b/app/models/issue.rb index 1724e3484..a63f05e0a 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -145,18 +145,14 @@ class Issue < ActiveRecord::Base def act_as_forge_message # 鎸囨淳缁欒嚜宸辩殑缂洪櫡涓嶆彁绀烘秷鎭 unless self.author_id == self.assigned_to_id - self.forge_messages << ForgeMessage.new(:user_id => self.assigned_to_id, - :project_id => self.project_id, - :viewed => false) + self.forge_messages << ForgeMessage.new(:user_id => self.assigned_to_id, :project_id => self.project_id, :viewed => false) end end # 鏇存柊缂洪櫡 def act_as_forge_message_update unless self.author_id == self.assigned_to_id - self.forge_messages << ForgeMessage.new(:user_id => self.assigned_to_id, - :project_id => self.project_id, - :viewed => false) + self.forge_messages << ForgeMessage.new(:user_id => self.assigned_to_id, :project_id => self.project_id, :viewed => false) end end diff --git a/app/models/memo.rb b/app/models/memo.rb index f1f9029c1..c30616558 100644 --- a/app/models/memo.rb +++ b/app/models/memo.rb @@ -79,7 +79,7 @@ class Memo < ActiveRecord::Base receivers << self.forum.creator end # 娣诲姞鍙戝笘浜 - if self.forum.creator_id != self.parent.author_id + if self.author_id != self.parent.author_id receivers << self.parent.author end end diff --git a/app/models/memo_message.rb b/app/models/memo_message.rb index 051fac317..9be00ce14 100644 --- a/app/models/memo_message.rb +++ b/app/models/memo_message.rb @@ -3,9 +3,15 @@ class MemoMessage < ActiveRecord::Base belongs_to :memo belongs_to :user + has_many :message_alls, :class_name => 'MessageAll',:as =>:message, :dependent => :destroy validates :user_id,presence: true validates :forum_id,presence: true validates :memo_id,presence: true validates :memo_type, presence: true + after_create :add_user_message + + def add_user_message + self.message_alls << MessageAll.new(:user_id => self.user_id) + end end diff --git a/app/models/message_all.rb b/app/models/message_all.rb new file mode 100644 index 000000000..6e0276875 --- /dev/null +++ b/app/models/message_all.rb @@ -0,0 +1,5 @@ +class MessageAll < ActiveRecord::Base + attr_accessible :message_id, :message_type, :user_id + # 铏氭嫙鍏宠仈---椤圭洰娑堟伅琛/璇剧▼娑堟伅琛/鐢ㄦ埛鐣欒█娑堟伅琛/璐村惂娑堟伅琛 + belongs_to :message ,:polymorphic => true +end diff --git a/app/models/user_activity.rb b/app/models/user_activity.rb new file mode 100644 index 000000000..1af1dc017 --- /dev/null +++ b/app/models/user_activity.rb @@ -0,0 +1,7 @@ +class UserActivity < ActiveRecord::Base + attr_accessible :act_type,:act_id,:container_type,:container_id + # 铏氭嫙鍏宠仈---椤圭洰鍔ㄦ佽〃/璇剧▼鍔ㄦ佽〃 + belongs_to :act ,:polymorphic => true + # 铏氭嫙鍏宠仈---椤圭洰/璇剧▼ + belongs_to :container ,:polymorphic => true +end diff --git a/app/models/user_feedback_message.rb b/app/models/user_feedback_message.rb index 98b53e973..1dda157d6 100644 --- a/app/models/user_feedback_message.rb +++ b/app/models/user_feedback_message.rb @@ -3,8 +3,14 @@ class UserFeedbackMessage < ActiveRecord::Base belongs_to :journals_for_message belongs_to :user + has_many :message_alls, :class_name => 'MessageAll',:as =>:message, :dependent => :destroy validates :user_id,presence: true validates :journals_for_message_id,presence: true validates :journals_for_message_type, presence: true + after_create :add_user_message + + def add_user_message + self.message_alls << MessageAll.new(:user_id => self.user_id) + end end diff --git a/app/views/layouts/_base_header_new.html.erb b/app/views/layouts/_base_header_new.html.erb index c224ee0ab..163f3a3ff 100644 --- a/app/views/layouts/_base_header_new.html.erb +++ b/app/views/layouts/_base_header_new.html.erb @@ -56,9 +56,9 @@ diff --git a/app/views/layouts/_logined_header.html.erb b/app/views/layouts/_logined_header.html.erb new file mode 100644 index 000000000..20934fb46 --- /dev/null +++ b/app/views/layouts/_logined_header.html.erb @@ -0,0 +1,46 @@ + \ No newline at end of file diff --git a/app/views/layouts/_new_feedback.html.erb b/app/views/layouts/_new_feedback.html.erb index 3b8098ed5..db0a3c3ee 100644 --- a/app/views/layouts/_new_feedback.html.erb +++ b/app/views/layouts/_new_feedback.html.erb @@ -21,14 +21,15 @@ <% end %> -
+
<%= l(:label_technical_support) %>鐧   缇 -
-
鍦ㄧ嚎瀹㈡湇
+
+ 鍦ㄧ嚎瀹㈡湇 +
diff --git a/app/views/layouts/_unlogin_header.html.erb b/app/views/layouts/_unlogin_header.html.erb new file mode 100644 index 000000000..ac322f07f --- /dev/null +++ b/app/views/layouts/_unlogin_header.html.erb @@ -0,0 +1,40 @@ + \ No newline at end of file diff --git a/app/views/layouts/_user_brief_introduction.html.erb b/app/views/layouts/_user_brief_introduction.html.erb new file mode 100644 index 000000000..58a7bad83 --- /dev/null +++ b/app/views/layouts/_user_brief_introduction.html.erb @@ -0,0 +1,10 @@ +<% if user.user_extensions && user.user_extensions.brief_introduction && !user.user_extensions.brief_introduction.empty? %> + <%= user.user_extensions.brief_introduction %>  +<% else%> + 杩欎綅绔ラ瀷寰堟噿锛屼粈涔堜篃娌℃湁鐣欎笅锝  +<% end %> +<% if User.current == user%> + + + +<% end%> \ No newline at end of file diff --git a/app/views/layouts/_user_watch_btn.html.erb b/app/views/layouts/_user_watch_btn.html.erb index 578319b68..5f9c550b7 100644 --- a/app/views/layouts/_user_watch_btn.html.erb +++ b/app/views/layouts/_user_watch_btn.html.erb @@ -1,11 +1,7 @@ <% if User.current.logged?%> - <% if User.current == target%> - 缂栬緫璧勬枡 - <%else%> - <%if(target.watched_by?(User.current))%> - 鍙栨秷鍏虫敞 - <% else %> - 娣诲姞鍏虫敞 - <% end %> - <% end%> + <%if(target.watched_by?(User.current))%> + <%= link_to "",watch_path(:object_type=> 'user',:object_id=>target.id,:target_id=>target.id),:class => "homepageFollow", :method => "delete",:remote => "true", :title => "鍙栨秷鍏虫敞"%> + <% else %> + <%= link_to "",watch_path(:object_type=> 'user',:object_id=>target.id,:target_id=>target.id),:class => "homepageFollowCancel", :method => "post",:remote => "true", :title => "娣诲姞鍏虫敞"%> + <% end %> <% end %> \ No newline at end of file diff --git a/app/views/layouts/new_base_user.html.erb b/app/views/layouts/new_base_user.html.erb new file mode 100644 index 000000000..419fa70ce --- /dev/null +++ b/app/views/layouts/new_base_user.html.erb @@ -0,0 +1,212 @@ + + + + + <%= h html_title %> + + + <%= csrf_meta_tag %> + <%= favicon %> + <%= stylesheet_link_tag 'jquery/jquery-ui-1.9.2', 'new_public', 'user_leftside', :media => 'all' %> + <%= stylesheet_link_tag 'rtl', :media => 'all' if l(:direction) == 'rtl' %> + <%= javascript_heads %> + <%= javascript_include_tag "bootstrap","avatars","new_user"%> + <%= heads_for_theme %> + <%= call_hook :view_layouts_base_html_head %> + <%= yield :header_tags -%> + + + + + +
+
+
+
+
+ <%= image_tag(url_to_avatar(@user),width:"206", height: "206", :id=>'nh_user_tx') %> + <% if User.current.logged?%> + <% if is_current_user%> +
+
+ +
+
+ <% else %> +
+ <%= render :partial => 'layouts/user_watch_btn', :locals => {:target => @user} %> +
+ <% end %> + <% end%> +
+
+ + <% if (@user.user_extensions && (@user.user_extensions.identity != 2) ) %> +
+ <% end %> + <%= link_to("缂栬緫璧勬枡", my_account_path, :class => "fr gz_btn mr10") if is_current_user%> +
+
+
+
+

+ <%= render :partial => 'layouts/user_brief_introduction', :locals => {:user => @user} %> +

+
+ +
+
+
+
+ <%= link_to User.watched_by(@user.id).count.to_s, {:controller=>"users", :action=>"user_watchlist",:id=>@user.id},:class=>"homepageImageNumber" %> +
+
鍏虫敞
+
+
+
+
+ <%= link_to @user.watcher_users.count.to_s, {:controller=>"users", :action=>"user_fanslist",:id=>@user.id},:class=>"homepageImageNumber", :id => "user_fans_number"%> +
+
绮変笣
+
+
+
+
+ <%= link_to(format("%.2f" ,get_option_number(@user,1).total_score ).to_i, + {:controller => 'users', :action => 'show_new_score', :remote => true, :id => @user.id }, :class => 'homepageImageNumber',:id => 'user_score') %> +
+
绉垎
+
+
+
+
+
+
+ <%= link_to "鍔ㄦ",user_activities_path(@user.id),:class => "homepageMenuText"%> +
+ +
+ +
+ +
+ +
+
+ 鐣欒█ +
+
+
+
+ 鏍囩 +
+ <%= render :partial => 'tags/user_tag', :locals => {:obj => @user,:object_flag => "1"}%> +
+
+
+
+
+
+ <%= yield %> +
+
+ <%= render :partial => 'layouts/new_feedback' %> +
+ + + + + + diff --git a/app/views/my/save_user_avatar.js.erb b/app/views/my/save_user_avatar.js.erb index 54cb3de48..fb3d94231 100644 --- a/app/views/my/save_user_avatar.js.erb +++ b/app/views/my/save_user_avatar.js.erb @@ -1,2 +1,3 @@ $("#nh_user_tx").replaceWith('<%= image_tag(url_to_avatar(@user), :id=>'nh_user_tx',:style=>"width:214px;height:214px;overflow:hidden",:alt=>"澶村儚") %>'); +$("#nh_user_logo").replaceWith('<%= image_tag(url_to_avatar(@user), :id=>'nh_user_logo',:width =>"40",:height => "40",:alt=>"澶村儚") %>'); hideModal(); \ No newline at end of file diff --git a/app/views/projects/settings/_new_repositories.html.erb b/app/views/projects/settings/_new_repositories.html.erb index ca771a487..b626b4089 100644 --- a/app/views/projects/settings/_new_repositories.html.erb +++ b/app/views/projects/settings/_new_repositories.html.erb @@ -62,15 +62,6 @@ <%= labelled_form_for :repository, @repository, :url =>project_repositories_path(@project),:html => {:id => 'repository-form',:method=>"post"} do |f| %>
<%=l(:button_save)%> <%=l(:button_cancel)%>
-<% end %> \ No newline at end of file +<% end %> diff --git a/app/views/repositories/show.html.erb b/app/views/repositories/show.html.erb index 474ac638f..5f279f2c2 100644 --- a/app/views/repositories/show.html.erb +++ b/app/views/repositories/show.html.erb @@ -33,8 +33,9 @@

+

git 鍏嬮殕鍜屾彁浜ょ殑鐢ㄦ埛鍚嶅拰瀵嗙爜涓虹櫥褰曠敤鎴峰悕鍜屽瘑鐮

椤圭洰浠g爜璇疯缃ソ姝g‘鐨勭紪鐮佹柟寮忥紙utf-8锛夛紝鍚﹀垯涓枃浼氬嚭鐜颁贡鐮併

-

閫氳繃cmd鍛戒护鎻愮ず绗﹁繘鍏ヤ唬鐮佸搴旀枃浠跺す鐨勬牴鐩綍锛屽亣璁惧綋鍓嶇敤鎴风殑鐧诲綍鍚嶄负user锛岀増鏈簱鍚嶇О涓篸emo锛岄渶瑕佹搷浣滅殑鐗堟湰搴撳垎鏀负branch銆 +

閫氳繃cmd鍛戒护鎻愮ず绗﹁繘鍏ヤ唬鐮佸搴旀枃浠跺す鐨勬牴鐩綍锛 濡傛灉鏄娆℃彁浜や唬鐮侊紝鎵ц濡備笅鍛戒护锛

@@ -45,19 +46,19 @@

git commit -m "first commit"

git remote add origin - http://user_demo@repository.trustie.net/user/demo.git + <%= @repos_url %>

git config http.postBuffer 524288000 #璁剧疆鏈湴post缂撳瓨涓500MB

-

git push -u origin branch:branch

+

git push -u origin master

宸茬粡鏈夋湰鍦板簱锛岃繕娌℃湁閰嶇疆杩滅▼鍦板潃锛屾墦寮鍛戒护琛屾墽琛屽涓嬶細

-

git remote add origin http://user_demo@repository.trustie.net/user/demo.git

+

git remote add origin <%= @repos_url %>

git add .

@@ -65,14 +66,14 @@

git config http.postBuffer 524288000 #璁剧疆鏈湴post缂撳瓨涓500MB

-

git push -u origin branch:branch

+

git push -u origin master

宸叉湁杩滅▼鍦板潃锛屽垱寤轰竴涓繙绋嬪垎鏀紝骞跺垏鎹㈠埌璇ュ垎鏀紝鎵撳紑鍛戒护琛屾墽琛屽涓嬶細

-

git clone http://user_demo@repository.trustie.net/user/demo.git

+

git clone <%= @repos_url %>

git push

@@ -86,7 +87,7 @@

git remote add trustie - http://user_demo@repository.trustie.net/user/demo.git + <%= @repos_url %>

git add .

diff --git a/app/views/users/_resource_share_for_project_popup.html.erb b/app/views/users/_resource_share_for_project_popup.html.erb index 9cd744c9a..01a2375c1 100644 --- a/app/views/users/_resource_share_for_project_popup.html.erb +++ b/app/views/users/_resource_share_for_project_popup.html.erb @@ -26,6 +26,7 @@ <%= hidden_field_tag(:send_id, send_id) %> <%= hidden_field_tag(:send_ids, send_ids) %> +
<% if !projects.empty? %> <% projects.each do |project| %>
    @@ -35,7 +36,7 @@
  • <%= truncate( project.name,:length=>18)%>
<% end %> - +
diff --git a/app/views/users/_resource_share_popup.html.erb b/app/views/users/_resource_share_popup.html.erb index ea1ada447..7f1c5a005 100644 --- a/app/views/users/_resource_share_popup.html.erb +++ b/app/views/users/_resource_share_popup.html.erb @@ -26,6 +26,7 @@ <%= hidden_field_tag(:send_id, send_id) %> <%= hidden_field_tag(:send_ids, send_ids) %> +
<% if !courses.empty? %> <% courses.each do |course| %>
    @@ -35,14 +36,14 @@
  • <%= truncate(course.name,:length=>18)%>
<% end %> - +
<%= submit_tag '纭畾',:class=>'sendSourceText',:onfocus=>'this.blur();' %>
- +
<% end %> diff --git a/app/views/users/edit_brief_introduction.js.erb b/app/views/users/edit_brief_introduction.js.erb new file mode 100644 index 000000000..c64482715 --- /dev/null +++ b/app/views/users/edit_brief_introduction.js.erb @@ -0,0 +1,3 @@ +$("#user_brief_introduction_show").html("<%= escape_javascript render(:partial => "layouts/user_brief_introduction", :locals => {:user => @user}) %>"); +$("#user_brief_introduction_show").show(); +$("#user_brief_introduction_edit").hide(); \ No newline at end of file diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb index b2e6258ee..02791d02d 100644 --- a/app/views/users/show.html.erb +++ b/app/views/users/show.html.erb @@ -1,40 +1,221 @@ -<%= javascript_include_tag "/assets/kindeditor/kindeditor",'/assets/kindeditor/pasteimg',"user" %> -<% @center_flag = (User.current == @user) %> -
- - <% if @user.allowed_to?(:add_project, nil, :global => true) %> - 鏂板缓椤圭洰 - <% else %> - 鍔犲叆椤圭洰 - <% end %> - - <% if @user.user_extensions.identity == 0 && @user.allowed_to?(:add_course, nil, :global => true) %> - 鏂板缓璇剧▼ - <% else %> - - 鍔犲叆璇剧▼ - <% end %> -
-
- -
- -