diff --git a/ReadMe.txt b/ReadMe.txt index 538457d3d..895e7ffb8 100644 --- a/ReadMe.txt +++ b/ReadMe.txt @@ -88,3 +88,12 @@ bundle exec rake db:migrate:down VERSION=20140811022947 bundle exec rake db:migrate:up VERSION=20140811022947 bundle exec rake db:migrate bundle exec rake project_score:calculate +=================================[2014-10-17]==================================== +kw:数据迁移,web_footer_oranizers表已存在 +bundle exec rake db:migrate:down VERSION=20141013014908 +bundle exec rake db:migrate:up VERSION=20141013014908 +bundle exec rake db:migrate +kw:数据迁移,web_footer_companies表已存在 +bundle exec rake db:migrate:down VERSION=20141013023400 +bundle exec rake db:migrate:up VERSION=20141013023400 +bundle exec rake db:migrate diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb index 7b4e326ad..f3b8b421a 100644 --- a/app/controllers/admin_controller.rb +++ b/app/controllers/admin_controller.rb @@ -159,7 +159,7 @@ class AdminController < ApplicationController respond_to do |format| flash[:notice] = l(:notice_successful_update) format.html { - redirect_to admin_first_page_made_url + redirect_to first_page_made_url } format.api { render_api_ok } #format.json { render json: @first_page, status: :created, location: @first_page } @@ -194,7 +194,7 @@ class AdminController < ApplicationController respond_to do |format| format.html { flash[:notice] = l(:notice_successful_update) - redirect_to admin_course_page_made_url + redirect_to course_page_made_url } format.api { render_api_ok } end @@ -235,7 +235,7 @@ class AdminController < ApplicationController respond_to do |format| format.html { flash[:notice] = l(:notice_successful_update) - redirect_to admin_contest_page_made_url + redirect_to contest_page_made_url } format.api { render_api_ok } end @@ -270,7 +270,7 @@ class AdminController < ApplicationController respond_to do |format| format.html { flash[:notice] = l(:notice_successful_update) - redirect_to admin_web_footer_made_url + redirect_to web_footer_made_url } format.api { render_api_ok } end diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 7f3dc0203..1d94d9a7c 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -766,7 +766,7 @@ class ApplicationController < ActionController::Base end def find_web_footer - @organize = WebFooterOranizer.first + @organizer = WebFooterOranizer.first @companies = WebFooterCompany.all end end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 9d1bb1472..21adfa19e 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -39,9 +39,10 @@ class UsersController < ApplicationController :user_homeworks, :destroy_membership, :user_activities, :user_projects, :user_newfeedback, :user_comments, :watch_bids, :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] + :activity_new_score_index, :influence_new_score_index, :score_new_index,:user_projects_index] before_filter :auth_user_extension, only: :show before_filter :rest_user_score, only: :show + #before_filter :select_entry, only: :user_projects accept_api_auth :index, :show, :create, :update, :destroy,:tag_save , :tag_saveEx #william @@ -80,6 +81,21 @@ class UsersController < ApplicationController end end + def user_projects_index + if User.current.admin? + memberships = @user.memberships.all(conditions: "projects.project_type = #{Project::ProjectType_project}").first + else + cond = Project.visible_condition(User.current) + " AND projects.project_type <> 1" + memberships = @user.memberships.all(:conditions => cond).first + end + watch_projects = Project.joins(:watchers).where("project_type <>? and watchable_type = ? and `watchers`.user_id = ?", '1','Project', @user.id).first + if memberships.nil? && watch_projects + redirect_to(:watch_projects_user) and return + else + redirect_to(:user_projects_user) and return + end + end + #added by young def user_projects @@ -92,8 +108,6 @@ class UsersController < ApplicationController #events = Redmine::Activity::Fetcher.new(User.current, :author => @user).events(nil, nil, :limit => 20) #@events_by_day = events.group_by(&:event_date) @state = 0 - - #add by huang unless User.current.admin? if !@user.active? #|| (@user != User.current && @memberships.empty? && events.empty?) diff --git a/app/models/contesting_project.rb b/app/models/contesting_project.rb index 3db6d6f86..9828bb598 100644 --- a/app/models/contesting_project.rb +++ b/app/models/contesting_project.rb @@ -7,9 +7,10 @@ class ContestingProject < ActiveRecord::Base DESCRIPTION_LENGTH_LIMIT = 500 validates :description, length: {maximum:DESCRIPTION_LENGTH_LIMIT } - validates :user_id, presence: true - validates :contest_id, presence: true, uniqueness: {:scope => :project_id} - validates :project_id, presence: true + validates :user_id, presence: true + validates :contest_id, presence: true, uniqueness: {scope: :project_id} + validates :project_id, presence: true + validate :validate_user validate :validate_contest validate :validate_project diff --git a/app/views/layouts/_base_footer.html.erb b/app/views/layouts/_base_footer.html.erb index 31175ea6d..012729aea 100644 --- a/app/views/layouts/_base_footer.html.erb +++ b/app/views/layouts/_base_footer.html.erb @@ -7,14 +7,12 @@

- <%= @organize.description.html_safe unless @organize.nil?%> + <%= @organizer.description.html_safe unless @organizer.nil?%>

diff --git a/app/views/layouts/base_users.html.erb b/app/views/layouts/base_users.html.erb index 1410e2277..c1c0eaf7b 100644 --- a/app/views/layouts/base_users.html.erb +++ b/app/views/layouts/base_users.html.erb @@ -274,7 +274,7 @@ <% if @user.user_extensions.identity == 2 %> <%= render_menu :user_enterprise_menu %> <% else %> - <%= render_menu :user_menu %> + <%= render_menu :user_menu,@user %> <% end %> diff --git a/config/routes.rb b/config/routes.rb index 3f3ef1b59..91f96bfb2 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -241,6 +241,7 @@ RedmineApp::Application.routes.draw do match "tag_saveEx" , :via => [:get, :post] end member do + match 'user_projects_index', :to => 'users#user_projects_index', :via => :get match 'user_projects', :to => 'users#user_projects', :via => :get match 'user_activities', :to => 'users#user_activities', :via => :get, :as => "user_activities" match 'user_newfeedback', :to => 'users#user_newfeedback', :via => :get, :as => "user_newfeedback" @@ -592,10 +593,10 @@ RedmineApp::Application.routes.draw do match 'admin', :to => 'admin#index', :via => :get match 'admin/projects', :via => :get match 'admin/users', :via => :get - match 'admin/first_page_made', :via => [:get,:post] - match 'admin/course_page_made', :via => [:get,:post] - match 'admin/contest_page_made', :via => [:get,:post] - match 'admin/web_footer_made', :via => [:get,:post] + match 'admin/first_page_made', as: :first_page_made + match 'admin/course_page_made', as: :course_page_made + match 'admin/contest_page_made', as: :contest_page_made + match 'admin/web_footer_made', as: :web_footer_made match 'admin/search', :via => [:get, :post] match 'admin/plugins', :via => :get match 'admin/info', :via => :get diff --git a/lib/redmine.rb b/lib/redmine.rb index db91d7a54..3ec7b114c 100644 --- a/lib/redmine.rb +++ b/lib/redmine.rb @@ -415,9 +415,25 @@ Redmine::MenuManager.map :course_menu do |menu| end Redmine::MenuManager.map :user_menu do |menu| menu.push :activity, {:controller => 'users', :action => 'show', :host => Setting.user_domain } - menu.push :user_course, {:controller => 'users', :action => 'user_courses'},:if => Proc.new {|c| FirstPage.find_by_page_type('project').show_course != 2} + menu.push :user_course, {:controller => 'users', :action => 'user_courses'}, + :if => Proc.new {|u| if User.current == u || User.current.admin? + membership = u.coursememberships.all + else + membership = u.coursememberships.all(:conditions => Course.visible_condition(User.current)) + end + FirstPage.find_by_page_type('project').show_course != 2 && membership && membership.count > 0 + } #menu.push :user_homework, {:controller => 'users', :action => 'user_homeworks'} by huang - menu.push :user_project, {:controller => 'users', :action => 'user_projects', :host => Setting.project_domain} + menu.push :user_project, {:controller => 'users', :action => 'user_projects_index', :host => Setting.project_domain}, + :if => Proc.new {|u| if User.current.admin? + memberships = u.memberships.all(conditions: "projects.project_type = #{Project::ProjectType_project}").first + else + cond = Project.visible_condition(User.current) + " AND projects.project_type <> 1" + memberships = u.memberships.all(:conditions => cond).first + end + watch_projects = Project.joins(:watchers).where("project_type <>? and watchable_type = ? and `watchers`.user_id = ?", '1','Project', u.id).first + memberships || watch_projects + } # menu.push :requirement_focus, {:controller => 'users', :action => 'watch_bids'} by huang menu.push :user_newfeedback, {:controller => 'users', :action => 'user_newfeedback', :host => Setting.user_domain} diff --git a/lib/redmine/menu_manager.rb b/lib/redmine/menu_manager.rb index 75e79d06c..4417c2e0c 100644 --- a/lib/redmine/menu_manager.rb +++ b/lib/redmine/menu_manager.rb @@ -216,7 +216,7 @@ module Redmine # * Checking the url target (project only) # * Checking the conditions of the item def allowed_node?(node, user, project) - if project && user && !user.allowed_to?(node.url, project) + if project && project.is_a?(Project) && user && !user.allowed_to?(node.url, project) return false end if node.condition && !node.condition.call(project)