diff --git a/Gemfile b/Gemfile index 1d827679..3784e60d 100644 --- a/Gemfile +++ b/Gemfile @@ -19,6 +19,10 @@ gem 'acts-as-taggable-on' group :development do gem 'better_errors', path: 'lib/better_errors' gem 'rack-mini-profiler', path: 'lib/rack-mini-profiler' + if ENV['PRY'] + gem 'pry' + gem 'pry-nav' + end end # Gems used only for assets and not required diff --git a/ReadMe.txt b/ReadMe.txt index e7444a6c..9d223259 100644 --- a/ReadMe.txt +++ b/ReadMe.txt @@ -1,11 +1,18 @@ patch: -用户姓名的部分,根据issues#655。 -为了修改方便 -alias: -方法 之前显示 调整之后 +鐢ㄦ埛濮撳悕鐨勯儴鍒嗭紝鏍规嵁issues#655銆 +涓轰簡淇敼鏂逛究 +alias锛 +鏂规硶 涔嬪墠鏄剧ず 璋冩暣涔嬪悗 name firstname+lastname login nickname xxx login realname xxx firstname+lastname + +User model缁忚繃淇敼锛屽凡缁忓畬鍏ㄩ泦鎴愪簡user_extensions鐨勫姛鑳 +渚嬪 +user.gender=1 +user.save +user_extensions瀛楁浼氳嚜鍔ㄤ繚瀛 +涓嶅繀瑕佹瘡娆ser.user_extensions.xxx浠ュ強鍒ゆ柇鏄惁涓虹┖ ================================================================================ app/models/setting.rb :165 # fixed domain url in development. tantantan's bug @@ -14,22 +21,22 @@ app/models/setting.rb :165 define_singleton_method m do; nil; end if m.to_s =~ /([a-zA-Z]+_domain)$/ end end - 程序部分链接中制定了subdomain参数,使链接在二级域名中来回跳转。 - 为了开发方便,使之功能在development模式下失效。 + 绋嬪簭閮ㄥ垎閾炬帴涓埗瀹氫簡subdomain鍙傛暟锛屼娇閾炬帴鍦ㄤ簩绾у煙鍚嶄腑鏉ュ洖璺宠浆銆 + 涓轰簡寮鍙戞柟渚匡紝浣夸箣鍔熻兘鍦╠evelopment妯″紡涓嬪け鏁堛 # => nyan ================================================================================ app/controller/projects_controller.rb ===> projects#fake - fake filter: 修改了传到页面中的Count后缀的数量 - 改为正确的数量,删掉fake过滤器即可 + fake filter: 淇敼浜嗕紶鍒伴〉闈腑鐨凜ount鍚庣紑鐨勬暟閲 + 鏀逛负姝g‘鐨勬暟閲忥紝鍒犳帀fake杩囨护鍣ㄥ嵆鍙 ================================================================================ -#导航栏匹配域名显示和改变 +#瀵艰埅鏍忓尮閰嶅煙鍚嶆樉绀哄拰鏀瑰彉 app\helper\application_helper.rb # rewrite navigation app\views\layouts\_base_header.html.erb # reset navigation by domain name and url through regular match ================================================================================ -#首页根据域名匹配进入不同的页面 +#棣栭〉鏍规嵁鍩熷悕鍖归厤杩涘叆涓嶅悓鐨勯〉闈 app\controller\welcome_controller.rb def entry_select_user if request.original_url.match(/user\.trustie\.net/) diff --git a/app/controllers/bids_controller.rb b/app/controllers/bids_controller.rb index d63f0cfb..87b0d8dc 100644 --- a/app/controllers/bids_controller.rb +++ b/app/controllers/bids_controller.rb @@ -881,6 +881,7 @@ class BidsController < ApplicationController def memberAccess # 鏄绋嬶紝鍒欏垽鏂綋鍓嶇敤鎴锋槸鍚﹀弬鍔犱簡璇剧▼ + return true if current_user.admin? return 0 if @bid.courses.first.project_type == Project::ProjectType_project currentUser = User.current render_403 unless currentUser.member_of?(@bid.courses.first) diff --git a/app/controllers/welcome_controller.rb b/app/controllers/welcome_controller.rb index c662c44f..c92f39d3 100644 --- a/app/controllers/welcome_controller.rb +++ b/app/controllers/welcome_controller.rb @@ -21,13 +21,7 @@ class WelcomeController < ApplicationController before_filter :entry_select_course, :entry_select_contest, :entry_select_user, :only => [:index] def index - projectActive = Project.project_entities.active - @projectCount = projectActive.count - @projectPublicCount = projectActive.all_public.count - @projectHidenCount = @projectCount - @projectPublicCount - @developerCount = User.developer.count - @allUsercount = User.count end def robots @@ -36,10 +30,7 @@ class WelcomeController < ApplicationController end def course - @courseCount = Project.course_entities.count - @teacherCount = User.teacher.count - @studentCount = User.student.count - @logoLink = logolink() + @logoLink ||= logolink() end @@ -121,25 +112,25 @@ class WelcomeController < ApplicationController end end - def render(*args) - _fake if @fake_filter - super - end + # def render(*args) + # _fake if @fake_filter + # super + # end - private + # private - def fake - @fake_filter = true - end + # def fake + # @fake_filter = true + # end - # 楠楀瓙鏂规硶 - def _fake - instance_variables.map { |variable| - if variable.to_s =~ /Count$/ - self.instance_variable_set(variable.to_sym, - ("1" + (self.instance_variable_get(variable.to_sym).to_s)).to_i) - end - } - end + # # 楠楀瓙鏂规硶 + # def _fake + # instance_variables.map { |variable| + # if variable.to_s =~ /Count$/ + # self.instance_variable_set(variable.to_sym, + # ("1" + (self.instance_variable_get(variable.to_sym).to_s)).to_i) + # end + # } + # end end diff --git a/app/models/user.rb b/app/models/user.rb index 6fb97537..ddf40a82 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -199,6 +199,53 @@ class User < Principal end } + + # ====================================================================== + # 闆嗕腑澶勭悊 User 鎵╁睍琛ㄤ负绌虹殑闂 + validate :valid_user_extensions + before_save :save_user_extensions + + def extensions + self.user_extensions ||= self.create_user_extensions + end + + def respond_to?(m, include_private = false) + flag = extensions.respond_to? m.to_sym + if flag + flag + else + super + end + end + + def method_missing m, *args, &block + if extensions.respond_to? m.to_sym + self.class.send :define_method, m.to_sym, *args do + self.extensions.__send__ m.to_sym, *args + end + __send__ m.to_sym, *args, &block + + else + super + end + end + + def valid_user_extensions + if !self.extensions.valid? + self.extensions.errors.messages.each do |key, values| + values.each do |value| + self.errors.add key, value + end + end + end + end + + def save_user_extensions + self.extensions.save + end + # 闆嗕腑澶勭悊 User 鎵╁睍琛ㄤ负绌虹殑闂 < end + # ====================================================================== + #閫夋嫨椤圭洰鎴愬憳鏃舵樉绀虹殑鐢ㄦ埛淇℃伅鏂囧瓧 def userInfo info=self.nickname + ' (' + self.realname + ')'; diff --git a/app/views/my/account.html.erb b/app/views/my/account.html.erb index 80554565..3853af34 100644 --- a/app/views/my/account.html.erb +++ b/app/views/my/account.html.erb @@ -34,7 +34,6 @@