From 1b8bf05be50da21799ae861386cfb6122f06a282 Mon Sep 17 00:00:00 2001 From: huang Date: Thu, 20 Oct 2016 13:26:11 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=A8=E6=88=B7ID=E8=A3=85=E6=8D=A2=E6=88=90?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/application_helper.rb | 8 +++++ app/models/user.rb | 6 ++++ app/views/users/show.html.erb | 51 ------------------------------- db/schema.rb | 37 +++++++++++++++++++--- 4 files changed, 47 insertions(+), 55 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 0782b55b0..4dbac0730 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -56,6 +56,14 @@ module ApplicationHelper user.nil? ? User.find(2) : user end + # 重置user_path,目的是将id转换成用户名 + def user_path(resource, parameters = {}) + if Fixnum === resource + resource = User.find(resource) + end + super + end + # 历史数据(老版本库数据)处理完则可以修改该放放 def get_rep_identifier_by_project project identifier = Repository.where(:project_id => project.id, :type => "Repository::Gitlab").first.try(:identifier) diff --git a/app/models/user.rb b/app/models/user.rb index 6a285efd1..730a7fe0e 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -320,6 +320,12 @@ class User < Principal self.user_extensions.try(:occupation).to_s end + # id 转换成 登录名 + def to_param + self.login.to_i > 0 ? id : login + end + + def my_blogs_count self.blog.blog_comments.where("#{BlogComment.table_name}.parent_id is null").count end diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb index 4247e2c87..e69de29bb 100644 --- a/app/views/users/show.html.erb +++ b/app/views/users/show.html.erb @@ -1,51 +0,0 @@ - - -
-
最新动态
- -
- - -<%# if @user.blog.homepage_id and BlogComment.where("id=?", @user.blog.homepage_id).count > 0 %> - <%# homepage = BlogComment.find(@user.blog.homepage_id) %> - <%#= render :partial => 'blogs/homepage', :locals => {:activity => homepage, :user_activity_id => homepage.id} %> -<%# end %> -<%= render :partial => 'users/user_activities', :locals => {:user_activities => @user_activities,:page => 0,:type => @type, :user_id => (@user.type == "AnonymousUser" ? User.current.id : @user.id)} %> diff --git a/db/schema.rb b/db/schema.rb index af81cc795..65ec42b02 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20161015102324) do +ActiveRecord::Schema.define(:version => 20161019020422) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -117,6 +117,18 @@ ActiveRecord::Schema.define(:version => 20161015102324) do t.integer "apply_user_id" end + create_table "article_homepages", :force => true do |t| + t.string "title" + t.text "content" + t.integer "user_id" + t.integer "homepage_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + add_index "article_homepages", ["homepage_id"], :name => "index_article_homepages_on_homepage_id" + add_index "article_homepages", ["user_id"], :name => "index_article_homepages_on_user_id" + create_table "at_messages", :force => true do |t| t.integer "user_id" t.integer "at_message_id" @@ -313,14 +325,16 @@ ActiveRecord::Schema.define(:version => 20161015102324) do add_index "changeset_parents", ["parent_id"], :name => "changeset_parents_parent_ids" create_table "changesets", :force => true do |t| - t.integer "repository_id", :null => false - t.string "revision", :null => false + t.integer "repository_id", :null => false + t.string "revision", :null => false t.string "committer" - t.datetime "committed_on", :null => false + t.datetime "committed_on", :null => false t.text "comments" t.date "commit_date" t.string "scmid" t.integer "user_id" + t.integer "project_id" + t.integer "type", :default => 0 end add_index "changesets", ["committed_on"], :name => "index_changesets_on_committed_on" @@ -870,6 +884,16 @@ ActiveRecord::Schema.define(:version => 20161015102324) do add_index "groups_users", ["group_id", "user_id"], :name => "groups_users_ids", :unique => true + create_table "homepages", :force => true do |t| + t.string "name" + t.integer "article_id" + t.integer "user_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + add_index "homepages", ["user_id"], :name => "index_homepages_on_user_id" + create_table "homework_attaches", :force => true do |t| t.integer "bid_id" t.integer "user_id" @@ -971,6 +995,10 @@ ActiveRecord::Schema.define(:version => 20161015102324) do t.datetime "updated_at", :null => false end + create_table "innodb_monitor", :id => false, :force => true do |t| + t.integer "a" + end + create_table "invite_lists", :force => true do |t| t.integer "project_id" t.integer "user_id" @@ -1517,6 +1545,7 @@ ActiveRecord::Schema.define(:version => 20161015102324) do t.integer "board_num", :default => 0 t.integer "attach_num", :default => 0 t.datetime "commit_time" + t.integer "pull_request_num", :default => 0 end create_table "project_statuses", :force => true do |t|