diff --git a/app/controllers/comments_controller.rb b/app/controllers/comments_controller.rb index 8a64918ae..11a788590 100644 --- a/app/controllers/comments_controller.rb +++ b/app/controllers/comments_controller.rb @@ -27,7 +27,12 @@ class CommentsController < ApplicationController raise Unauthorized unless @news.commentable? @comment = Comment.new - @project ? @comment.comments = params[:comment][:comments] : @comment.comments = params[:comment] + #@project ? @comment.comments = params[:comment][:comments] : @comment.comments = params[:comment] + if params[:user_activity_id] + @comment.comments = params[:comment] + else + @comment.comments = params[:comment][:comments] + end @comment.author = User.current if @news.comments << @comment if params[:asset_id] @@ -48,7 +53,7 @@ class CommentsController < ApplicationController # end # end # # ������ض�̬�ļ�¼add end - flash[:notice] = l(:label_comment_added) + #flash[:notice] = l(:label_comment_added) course_activity = CourseActivity.where("course_act_type='News' and course_act_id =#{@news.id}").first if course_activity course_activity.updated_at = Time.now diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index aa0e1596f..8bd91b089 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -293,10 +293,15 @@ class CoursesController < ApplicationController @all_members = searchTeacherAndAssistant(@course) @members = @all_members when '2' - @subPage_title = l :label_student_list - page = params[:page].nil? ? 0 : (params['page'].to_i - 1) - @all_members = student_homework_score(0,page, 10,"desc") - @members = @all_members + if @course.open_student == 1 || User.current.member_of_course?(@course) + @subPage_title = l :label_student_list + page = params[:page].nil? ? 0 : (params['page'].to_i - 1) + @all_members = student_homework_score(0,page, 10,"desc") + @members = @all_members + else + render_403 + return + end end respond_to do |format| if params[:page] diff --git a/app/controllers/homework_common_controller.rb b/app/controllers/homework_common_controller.rb index 048f62296..46362c2d3 100644 --- a/app/controllers/homework_common_controller.rb +++ b/app/controllers/homework_common_controller.rb @@ -63,6 +63,7 @@ class HomeworkCommonController < ApplicationController end @homework.end_time = params[:homework_common][:end_time] || Time.now @homework.course_id = params[:course_id] + @homework.anonymous_comment = params[:homework_common][:anonymous_comment] ? params[:homework_common][:anonymous_comment] : 1 homework_detail_manual = @homework.homework_detail_manual || HomeworkDetailManual.new if @homework.publish_time <= Date.today && homework_detail_manual.comment_status == 0 diff --git a/app/controllers/news_controller.rb b/app/controllers/news_controller.rb index be2b44c06..d3ac71b99 100644 --- a/app/controllers/news_controller.rb +++ b/app/controllers/news_controller.rb @@ -69,20 +69,25 @@ class NewsController < ApplicationController elsif @course if (User.current.admin? || @course.is_public == 1 || (@course.is_public == 0 && User.current.member_of_course?(@course))) scope = @course ? @course.news.course_visible : News.course_visible + news_arr = scope.map{|news| news.id} + + @page = params[:page] ? params[:page].to_i + 1 : 0 + news_page = @page *10 @news_count = scope.count + @is_new = params[:is_new] @q = params[:subject] if params[:subject].nil? || params[:subject].blank? - scope_order = scope.all(:include => [:author, :course], - :order => "#{News.table_name}.sticky DESC, #{News.table_name}.created_on DESC") + scope_order = scope.reorder("#{News.table_name}.sticky DESC, #{News.table_name}.created_on DESC").limit(10).offset(news_page).includes(:author,:course).all() + #all(:include => [:author, :course], + #:order => "#{News.table_name}.sticky DESC, #{News.table_name}.created_on DESC").limit(10).offset(news_page) else - scope_order = scope.where("#{News.table_name}.title like '#{'%' << params[:subject].to_s << '%'}'").all(:include => [:author, :course], - :order => "#{News.table_name}.sticky DESC, #{News.table_name}.created_on DESC") + scope_order = scope.where("#{News.table_name}.title like '#{'%' << params[:subject].to_s << '%'}'").reorder("#{News.table_name}.sticky DESC, #{News.table_name}.created_on DESC").limit(10).offset(news_page).includes(:author,:course).all() + #.all(:include => [:author, :course],:order => "#{News.table_name}.sticky DESC, #{News.table_name}.created_on DESC") end - # :offset => @offset, - # :limit => @limit) - @newss = paginateHelper scope_order,10 + @newss = scope_order + #@newss = paginateHelper scope_order,10 respond_to do |format| format.html { @news = News.new @@ -130,6 +135,7 @@ class NewsController < ApplicationController result = cs.show_course_news params,User.current @news = result[:news] @comments = result[:comments] + @comment = Comment.new #@comments = @news.comments #@comments.reverse! if User.current.wants_comments_in_reverse_order? #modify by nwb @@ -147,7 +153,22 @@ class NewsController < ApplicationController @news = News.new(:project => @project, :author => User.current) elsif @course @news = News.new(:course => @course, :author => User.current) - render :layout => 'base_courses' + #render :layout => 'base_courses' + @news.safe_attributes = params[:news] + @news.save_attachments(params[:attachments]) + if @news.save + if params[:asset_id] + ids = params[:asset_id].split(',') + update_kindeditor_assets_owner ids,@news.id,OwnerTypeHelper::NEWS + end + render_attachment_warning_if_needed(@news) + #flash[:notice] = l(:notice_successful_create) + redirect_to course_news_index_url(@course) + else + redirect_to course_news_index_url(@course) + #layout_file = 'base_courses' + #render :action => 'new', :layout => layout_file + end end end @@ -210,7 +231,7 @@ class NewsController < ApplicationController @news.save_attachments(params[:attachments]) if @news.save render_attachment_warning_if_needed(@news) - flash[:notice] = l(:notice_successful_update) + #flash[:notice] = l(:notice_successful_update) redirect_to news_url(@news) else #flash[:error] = l(:notice_successful_update) diff --git a/app/controllers/organizations_controller.rb b/app/controllers/organizations_controller.rb index 38402f68e..bba1587b6 100644 --- a/app/controllers/organizations_controller.rb +++ b/app/controllers/organizations_controller.rb @@ -98,7 +98,7 @@ class OrganizationsController < ApplicationController @org_activities = OrgActivity.where("container_type = 'Course' and org_act_type = 'Poll' and container_id in (#{course_ids.join(',')})").order('updated_at desc').page(params[:page] || 1).per(10) end end - @page = params[:page] + @page = params[:page] || 1 respond_to do |format| format.html format.js diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index 8eb6a6860..1674055ac 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -31,8 +31,8 @@ class RepositoriesController < ApplicationController default_search_scope :changesets before_filter :find_project_by_project_id, :only => [:new, :create, :newrepo] - before_filter :find_repository, :only => [:edit, :update, :destroy, :committers, :forked] - before_filter :find_project_repository, :except => [:new, :create, :newcreate, :edit, :update, :destroy, :committers, :newrepo,:to_gitlab] + before_filter :find_repository, :only => [:edit, :update, :destroy, :committers] + before_filter :find_project_repository, :except => [:new, :create, :newcreate, :edit, :update, :destroy, :committers, :newrepo, :to_gitlab, :forked] before_filter :find_changeset, :only => [:revision, :add_related_issue, :remove_related_issue] before_filter :authorize , :except => [:newrepo,:newcreate,:fork, :to_gitlab, :forked] accept_rss_auth :revisions @@ -64,6 +64,8 @@ class RepositoriesController < ApplicationController end def forked + @project = Project.find(params[:id]) + @repository = Repository.where("project_id =? and type =?", @project.id, "Repository::Gitlab") # 如果当前用户已经fork过该项目,不会新fork项目,则跳至已fork的项 unless has_forked?(@project, User.current) project = project_from_current_project(@project.id, User.current.id) @@ -76,7 +78,11 @@ class RepositoriesController < ApplicationController else g = Gitlab.client if User.current.gid.nil? - g.sync_user(User.current) + begin + g.sync_user(User.current) + ensure + logger.error "Synv user failed ==>#{User.current.id}" + end end gproject = g.fork(@project.gpid, User.current.gid) if gproject @@ -351,7 +357,7 @@ update @changesets = g.commits(@project.gpid, :ref_name => @rev) # @changesets = @repository.latest_changesets(@path, @rev) # @changesets_count = @repository.latest_changesets(@path, @rev).count - @changesets_all_count = 0 + @changesets_all_count = @project.gpid.nil? ? 0 : g.commits_total_count(@project.gpid).count @changesets_latest_coimmit = @changesets[0] @properties = @repository.properties(@path, @rev) @repositories = @project.repositories @@ -383,10 +389,10 @@ update @commits = g.commits(@project.gpid, page:(params[:page].to_i - 1).to_s) #add by hx - rep_count = commit_count(@project) + #rep_count = commit_count(@project) #页面传递必须要str类型,但是Paginator的初始化必须要num类型,需要类型转化 - @commits_count = rep_count + @commits_count = params[:commit_count].to_i @commits_pages = Redmine::Pagination::Paginator.new @commits_count,limit,params[:page] @commit = g.commit(@project.gpid,@rev) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 281b8b7e0..f26f6c118 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -522,6 +522,7 @@ class UsersController < ApplicationController else homework.publish_time = params[:homework_common][:publish_time] end + homework.anonymous_comment = params[:homework_common][:anonymous_comment] ? params[:homework_common][:anonymous_comment] : 1 homework.homework_type = params[:homework_type].to_i || 1 homework.late_penalty = 10 homework.teacher_priority = 1 diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index c4bbc4ebb..4bdffb9dc 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -253,8 +253,10 @@ module ApplicationHelper subject = truncate(subject, :length => 60) end end - if issue.status_id == 5 + if issue.status_id == 3 s = link_to text, issue_path(issue), :class => "text_line_s", :title => title + elsif issue.status_id == 5 + s = link_to text, issue_path(issue), :class => "text_line_s del_line", :title => title else s = link_to text, issue_path(issue), :class => "c_blue", :title => title end diff --git a/app/models/mailer.rb b/app/models/mailer.rb index 551ddd616..1cbe7421c 100644 --- a/app/models/mailer.rb +++ b/app/models/mailer.rb @@ -394,7 +394,7 @@ class Mailer < ActionMailer::Base @issue = issue user = User.find_by_mail(recipients) @user = user - @token = Token.get_token_from_user(user, 'autologin') + # @token = Token.get_token_from_user(user, 'autologin') @issue_url = url_for(:controller => 'issues', :action => 'show', :id => issue.id) # edit @@ -436,15 +436,15 @@ class Mailer < ActionMailer::Base user = User.find_by_mail(recipients) @user = user - @token = Token.get_token_from_user(user, 'autologin') + # @token = Token.get_token_from_user(user, 'autologin') # edit - @issue_author_url = url_for(:controller => 'users', :action => 'show', :id => issue.author_id, :token => @token.value) - @project_url = url_for(:controller => 'projects', :action => 'show', :id => issue.project_id, :token => @token.value) - @user_url = url_for(my_account_url(user,:token => @token.value)) + @issue_author_url = url_for(:controller => 'users', :action => 'show', :id => issue.author_id) + @project_url = url_for(:controller => 'projects', :action => 'show', :id => issue.project_id) + @user_url = url_for(my_account_url(user)) - @issue_url = url_for(:controller => 'issues', :action => 'show', :id => issue.id, :anchor => "change-#{journal.id}", :token => @token.value) + @issue_url = url_for(:controller => 'issues', :action => 'show', :id => issue.id, :anchor => "change-#{journal.id}") s = "[#{issue.project.name} - #{issue.tracker.name} ##{issue_id}] " s << "(#{issue.status.name}) " if journal.new_value_for('status_id') s << issue.subject diff --git a/app/views/blog_comments/_blog_attachments.erb b/app/views/blog_comments/_blog_attachments.erb index dd8be659b..86298a330 100644 --- a/app/views/blog_comments/_blog_attachments.erb +++ b/app/views/blog_comments/_blog_attachments.erb @@ -57,7 +57,7 @@ :max_file_size => Setting.attachment_max_size.to_i.kilobytes, :max_file_size_message => l(:error_attachment_too_big, :max_size => number_to_human_size(Setting.attachment_max_size.to_i.kilobytes)), :max_concurrent_uploads => Redmine::Configuration['max_concurrent_ajax_uploads'].to_i, - :upload_path => uploads_path(:format => 'js', :project => container), + :upload_path => uploads_path(:format => 'js'), :description_placeholder => l(:label_optional_description), :field_is_public => l(:field_is_public), :are_you_sure => l(:text_are_you_sure), diff --git a/app/views/boards/_course_show_detail.html.erb b/app/views/boards/_course_show_detail.html.erb index c324f1d69..7b96c4f9a 100644 --- a/app/views/boards/_course_show_detail.html.erb +++ b/app/views/boards/_course_show_detail.html.erb @@ -59,12 +59,14 @@ <% end %> <% if topics.count == 10 %> -