diff --git a/ReadMe.txt b/ReadMe.txt index 32ac107e3..8c57f348c 100644 --- a/ReadMe.txt +++ b/ReadMe.txt @@ -68,5 +68,7 @@ bundle exec rake db:migrate:up VERSION=20140410021724 4 点击“查询”(就是确定的功能) =============================================================================== 0719:若遇到首页定制报错问题请尝试如下操作 +如果运行迁移文件有报错与‘sort_type’相关 先运行 bundle exec rake db:migrate:down version=20140716021202 bundle exec rake db:migrate:up version=20140716021202 +在按如下步骤执行,未报与之相关的则直接按如下步骤执行 1.运行 bundle exec rake db:migrate:down version=20140719080032 2.运行 bundle exec rake db:migrate:up version=20140719080032 \ No newline at end of file diff --git a/app/controllers/boards_controller.rb b/app/controllers/boards_controller.rb index a692acc12..40674b53f 100644 --- a/app/controllers/boards_controller.rb +++ b/app/controllers/boards_controller.rb @@ -70,7 +70,7 @@ class BoardsController < ApplicationController @message = Message.new(:board => @board) #modify by nwb if @project - render :action => 'show', :layout => !request.xhr? + render :action => 'show', :layout => 'base_projects' elsif @course render :action => 'show', :layout => 'base_courses' end diff --git a/app/controllers/contests_controller.rb b/app/controllers/contests_controller.rb index 350204fbe..cf8750b5d 100644 --- a/app/controllers/contests_controller.rb +++ b/app/controllers/contests_controller.rb @@ -1,6 +1,7 @@ # fq # class BidsController < ApplicationController class ContestsController < ApplicationController + layout "contest_base" menu_item :respond menu_item :project, :only => :show_project menu_item :application, :only => :show_softapplication diff --git a/app/controllers/documents_controller.rb b/app/controllers/documents_controller.rb index 89bd9dc92..b0ad6b109 100644 --- a/app/controllers/documents_controller.rb +++ b/app/controllers/documents_controller.rb @@ -29,7 +29,13 @@ class DocumentsController < ApplicationController def index @sort_by = %w(category date title author).include?(params[:sort_by]) ? params[:sort_by] : 'category' - documents = @project.documents.includes(:attachments, :category).all + temp = @project.documents.includes(:attachments, :category).all + documents = [] + temp.each do |doc| + if doc.has_right?(@project) + documents << doc + end + end case @sort_by when 'date' @grouped = documents.group_by {|d| d.updated_on.to_date } @@ -105,7 +111,7 @@ class DocumentsController < ApplicationController # 权限判断 # add by nwb def authorize_document - if !(User.current.admin? || User.current.member_of?(@project) || @document.is_public==1) + if !(User.current.admin? || User.current.member_of?(@project) || @document == nil || (@document != nil && @document.is_public==1)) render_403 :message => :notice_not_authorized end end diff --git a/app/controllers/softapplications_controller.rb b/app/controllers/softapplications_controller.rb index f42865ead..d7b2477a8 100644 --- a/app/controllers/softapplications_controller.rb +++ b/app/controllers/softapplications_controller.rb @@ -1,4 +1,5 @@ class SoftapplicationsController < ApplicationController + layout "contest_base" before_filter :find_softapplication, only: [:edit, :update, :destroy] before_filter :editable, only: [:edit, :update] before_filter :destroyable, only: :destroy diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 34745709b..9e7ee0229 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -33,7 +33,7 @@ class UsersController < ApplicationController before_filter :require_admin, :except => [:show, :index, :search, :tag_save, :tag_saveEx,:user_projects, :user_newfeedback, :user_comments, :watch_bids, :watch_contests, :info, :user_watchlist, :user_fanslist,:update, :user_courses, :user_homeworks, :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,:update_score] + :activity_new_score_index, :influence_new_score_index, :score_new_index,:update_score,:user_activities] #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, diff --git a/app/controllers/welcome_controller.rb b/app/controllers/welcome_controller.rb index 9330d1d44..516b88310 100644 --- a/app/controllers/welcome_controller.rb +++ b/app/controllers/welcome_controller.rb @@ -148,7 +148,7 @@ class WelcomeController < ApplicationController end private - + # 判断网站的入口,是课程 course 则跳过index去渲染 course 方法 def entry_select url = request.original_url if url.include?("course.trustie.net") @@ -166,28 +166,6 @@ class WelcomeController < ApplicationController end - # 判断网站的入口,是课程 course 则跳过index去渲染 course 方法 - def entry_select_course - if request.original_url.match(/.*course\.trustie\.net/) - (course() and render :course and return 0) - end - end - - def entry_select_contest - if request.original_url.match(/.*contest\.trustie\.net/) - contest - render :contest - return 0 - end - end - - def entry_select_user - if request.original_url.match(/.*user\.trustie\.net$/) - redirect_to(:controller => "users", :action => "index") - return 0 - end - end - # def render(*args) # _fake if @fake_filter # super diff --git a/app/models/document.rb b/app/models/document.rb index 5cfce896b..1467903b0 100644 --- a/app/models/document.rb +++ b/app/models/document.rb @@ -46,6 +46,10 @@ class Document < ActiveRecord::Base !user.nil? && user.allowed_to?(:view_documents, project) end + def has_right?(project,user=User.current) + user.admin? || user.member_of?(project) || self.is_public==1 + end + def initialize(attributes=nil, *args) super if new_record? diff --git a/app/models/project.rb b/app/models/project.rb index 5bcd2e8c5..d6283e44f 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -56,13 +56,12 @@ class Project < ActiveRecord::Base #added by xianbo for delete biding_project has_many :biding_projects, :dependent => :destroy has_many :contesting_projects, :dependent => :destroy - has_many :projecting_softapplications, :dependent => :destroy has_many :softapplications, :through => :projecting_softapplications #ended by xianbo # added by fq has_many :journals_for_messages, :as => :jour, :dependent => :destroy - has_many :homework_for_courses, :dependent => :destroy - has_many :homeworks, :through => :homework_for_courses, :source => :bid, :dependent => :destroy + #has_many :homework_for_courses, :dependent => :destroy + #has_many :homeworks, :through => :homework_for_courses, :source => :bid, :dependent => :destroy has_many :shares, :dependent => :destroy # has_many :students_for_courses, :dependent => :destroy has_many :student, :through => :students_for_courses, :source => :user @@ -1138,13 +1137,13 @@ class Project < ActiveRecord::Base # 创建项目后在项目下同步创建一个讨论区 def create_board_sync @board = self.boards.build - self.name=" #{l(:label_borad_course) }" + self.name=" #{l(:label_borad_project) }" @board.name = self.name @board.description = self.name.to_s if @board.save - logger.debug "[Course Model] ===> #{@board.to_json}" + logger.debug "[Project Model] ===> #{@board.to_json}" else - logger.error "[Course Model] ===> Auto create board when Course saved, because #{@board.full_messages}" + logger.error "[Project Model] ===> Auto create board when Project saved, because #{@board.full_messages}" end end diff --git a/app/views/documents/index.html.erb b/app/views/documents/index.html.erb index 41b2d13fd..43b0cff49 100644 --- a/app/views/documents/index.html.erb +++ b/app/views/documents/index.html.erb @@ -27,8 +27,8 @@ <% if @grouped.empty? %>
<%= l(:label_no_data) %>
<% end %> <% @grouped.keys.sort.each do |group| %> - - <%= render :partial => 'documents/document', :collection => @grouped[group] %> -<% end %> + + <%= render :partial => 'documents/document', :collection => @grouped[group] %> +<% end %> <% html_title(l(:label_document_plural)) -%> diff --git a/app/views/issues/_list.html.erb b/app/views/issues/_list.html.erb index c9fecc6a9..4c2a63844 100644 --- a/app/views/issues/_list.html.erb +++ b/app/views/issues/_list.html.erb @@ -39,7 +39,7 @@