From db1874fa0752034bcbd39d01c2454d29cb6a5367 Mon Sep 17 00:00:00 2001 From: baiyu Date: Thu, 9 Jan 2014 10:58:05 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AF=84=E5=88=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/users_controller.rb | 8 ++++++-- app/models/user_extensions.rb | 20 ++++++++++++++++++++ app/views/layouts/base_users.html.erb | 13 +++++++++++-- config/routes.rb | 1 + 4 files changed, 38 insertions(+), 4 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 4b7f04547..60a0b6e4d 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -30,11 +30,11 @@ class UsersController < ApplicationController before_filter :require_admin, :except => [:show, :index, :search, :tag_save, :user_projects, :user_newfeedback, :user_comments, :watch_bids, :info, - :user_watchlist, :user_fanslist,:update, :user_courses, :user_homeworks, :watch_projects] + :user_watchlist, :user_fanslist,:update, :user_courses, :user_homeworks, :watch_projects, :show_score] #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_bids, :info, - :watch_projects] + :watch_projects, :show_score] accept_api_auth :index, :show, :create, :update, :destroy,:tag_save #william @@ -86,6 +86,10 @@ class UsersController < ApplicationController end end + def show_score + + end + ##added by fq def watch_bids cond = 'bids.reward_type <> 1' diff --git a/app/models/user_extensions.rb b/app/models/user_extensions.rb index 64229f517..e2c42a745 100644 --- a/app/models/user_extensions.rb +++ b/app/models/user_extensions.rb @@ -25,6 +25,23 @@ class UserExtensions < ActiveRecord::Base return self.brief_introduction end + # added by bai + def show_identity + if self.identity == 0 + user_identity = '教师' + elsif self.identity == 1 + user_identity = '学生' + elsif self.identity == 2 + user_identity = '企业' + elsif self.identity == 3 + user_identity = '开发者' + else + user_identity = '' + end + return user_identity + end +# end + def self.introduction(user, message) unless user.user_extensions.nil? info = user.user_extensions @@ -37,4 +54,7 @@ class UserExtensions < ActiveRecord::Base info.save end end + + + end diff --git a/app/views/layouts/base_users.html.erb b/app/views/layouts/base_users.html.erb index ad4876de5..ae29544cc 100644 --- a/app/views/layouts/base_users.html.erb +++ b/app/views/layouts/base_users.html.erb @@ -62,14 +62,23 @@ <% unless User.current == @user %> <%= watcher_link(@user, User.current) %> <% else %> - <%= link_to(l(:label_user_edit), my_account_path(@user)) if User.current %><% end %> + <%= link_to(l(:label_user_edit), my_account_path(@user)) if User.current %> + <% end %> + + + <%= link_to(l(:label_user_grade), {:controller => 'users', :action => 'show_score', :remote => true, :id => @user.id})%>: <%= @user.user_status.grade %> + + +
<%= link_to l(:label_user_watcher)+"("+User.watched_by(@user.id).count.to_s+")" ,:controller=>"users", :action=>"user_watchlist"%>   - <%= link_to l(:label_x_user_fans, :count => User.current.watcher_users(User.current.id).count)+"("+@user.watcher_users(@user.id).count.to_s+")", :controller=>"users", :action=>"user_fanslist" %>  + + <%= link_to l(:label_x_user_fans, :count => User.current.watcher_users(User.current.id).count)+"("+@user.watcher_users.count.to_s+")", :controller=>"users", :action=>"user_fanslist" %>  + <%= link_to l(:label_requirement_focus)+"("+Bid.watched_by(@user).where('reward_type = ?', 1).count.to_s+")" ,:controller=>"users", :action=>"watch_bids"%>   <% if @user.id == User.current.id %> diff --git a/config/routes.rb b/config/routes.rb index 6b5edb16d..91a3eeb9d 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -113,6 +113,7 @@ RedmineApp::Application.routes.draw do match 'user_courses', :to => 'users#user_courses', :via => :get match 'user_homeworks', :to => 'users#user_homeworks', :via => :get match 'watch_projects', :to => 'users#watch_projects', :via => :get + match 'show_score', :to => 'users#show_score', :via => :get end end match 'users/:id/user_newfeedback', :to => 'users#user_newfeedback', :via => :get, :as => "feedback"