diff --git a/app/controllers/boards_controller.rb b/app/controllers/boards_controller.rb index 434ea4470..22881b8f2 100644 --- a/app/controllers/boards_controller.rb +++ b/app/controllers/boards_controller.rb @@ -103,7 +103,7 @@ class BoardsController < ApplicationController @topic_pages = Paginator.new @topic_count, per_page_option, params['page'] #现在发布帖子的时候置顶功能已经没有了。所以取消这个置顶排序 #{Message.table_name}.sticky DESC, @topics = @board.topics. - reorder("#{Message.table_name}.created_on desc"). + reorder("#{Message.table_name}.sticky DESC, #{Message.table_name}.created_on desc"). includes(:last_reply). limit(@topic_pages.per_page). offset(@topic_pages.offset). diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index 126b269bb..f2f10d5b6 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -46,16 +46,21 @@ class RepositoriesController < ApplicationController rescue_from Redmine::Scm::Adapters::CommandFailed, :with => :show_error_command_failed def new - scm = params[:repository_scm] || (Redmine::Scm::Base.all & Setting.enabled_scm).first - @repository = Repository.factory(scm) - @repository.is_default = @project.repository.nil? - @repository.project = @project - @course_tag = params[:course] - if @course_tag == 1 - render :layout => 'base_courses' + if @project.repositories.count == 0 + scm = params[:repository_scm] || (Redmine::Scm::Base.all & Setting.enabled_scm).first + @repository = Repository.factory(scm) + @repository.is_default = @project.repository.nil? + @repository.project = @project + @course_tag = params[:course] + if @course_tag == 1 + render :layout => 'base_courses' + else + render :layout => 'base_projects' + end else - render :layout => 'base_projects' + render_403 end + end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 41e016562..b18d0c706 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -2349,22 +2349,25 @@ module ApplicationHelper #根据传入作业确定显示为编辑作品还是新建作品,或者显示作品数量 def user_for_homework_common homework,is_teacher - if is_teacher #老师显示作品数量 - link_to "提交(#{homework.student_works.count})",student_work_index_path(:homework => homework.id),:class => "c_blue" - else #学生显示提交作品、修改作品等按钮 - work = cur_user_works_for_homework homework - if work.nil? - link_to "提交作品", new_student_work_path(:homework => homework.id),:class => 'c_blue' - else - if homework.homework_detail_manual && homework.homework_detail_manual.comment_status != 1 #匿评作业,且作业状态不是在开启匿评之前 - link_to "作品已交", "javascript:void(0)", :class => 'c_blue', :title => "开启匿评后不可修改作品" - elsif homework.homework_type == 2 #编程作业不能修改作品 - link_to "修改作品", new_student_work_path(:homework => homework.id),:class => 'c_blue' + if User.current.member_of_course?(homework.course) + if is_teacher #老师显示作品数量 + link_to "提交(#{homework.student_works.count})",student_work_index_path(:homework => homework.id),:class => "c_blue" + else #学生显示提交作品、修改作品等按钮 + work = cur_user_works_for_homework homework + if work.nil? + link_to "提交作品", new_student_work_path(:homework => homework.id),:class => 'c_blue' else - link_to "修改作品", edit_student_work_path(work.id),:class => 'c_blue' + if homework.homework_detail_manual && homework.homework_detail_manual.comment_status != 1 #匿评作业,且作业状态不是在开启匿评之前 + link_to "作品匿评", student_work_index_path(:homework => homework.id), :class => 'c_blue', :title => "开启匿评后不可修改作品" + elsif homework.homework_type == 2 #编程作业不能修改作品 + link_to "修改作品", new_student_work_path(:homework => homework.id),:class => 'c_blue' + else + link_to "修改作品", edit_student_work_path(work.id),:class => 'c_blue' + end end end end + end def student_anonymous_comment homework diff --git a/app/models/project.rb b/app/models/project.rb index 0cd6af35b..fcc96c404 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -91,8 +91,10 @@ class Project < ActiveRecord::Base has_many :tags, :through => :project_tags, :class_name => 'Tag' has_many :project_tags, :class_name => 'ProjectTags' + # 动态级联删除 + has_many :forge_activities, :class_name => 'ForgeActivity', :dependent => :destroy # 关联虚拟表 - has_many :forge_messages, :class_name =>'ForgeMessage', :as => :forge_message, :dependent => :destroy + has_many :forge_messages, :class_name =>'ForgeMessage', :as => :forge_message, :dependent => :destroy belongs_to :organization diff --git a/app/views/boards/_project_show.html.erb b/app/views/boards/_project_show.html.erb index 4f022261f..3cfd4ae72 100644 --- a/app/views/boards/_project_show.html.erb +++ b/app/views/boards/_project_show.html.erb @@ -51,9 +51,9 @@ :data => {:confirm => l(:text_are_you_sure)}, :class => 'talk_edit fr', :style => ' margin-right: 10px;') if topic.destroyable_by?(User.current) %> - <%# if topic.sticky? %> - - <%# end %> + <% if topic.sticky? %> + <%= l(:label_board_sticky)%> + <% end %>