diff --git a/.gitignore b/.gitignore index fdb7a3c6b..22d9e17e6 100644 --- a/.gitignore +++ b/.gitignore @@ -29,3 +29,4 @@ vendor/cache /public/images/avatars /public/files /tags +/config/initializers/gitlab_config.rb diff --git a/Gemfile b/Gemfile index cf6e9f773..3027c16cd 100644 --- a/Gemfile +++ b/Gemfile @@ -6,7 +6,8 @@ unless RUBY_PLATFORM =~ /w32/ gem 'iconv' end -gem 'grack', path:'./lib/grack' +gem 'grack', path:'lib/grack' +gem 'gitlab', path: 'lib/gitlab-cli' gem 'rest-client' gem "mysql2", "= 0.3.18" gem 'redis-rails' @@ -45,7 +46,7 @@ group :development, :test do gem 'pry-stack_explorer' if RUBY_PLATFORM =~ /darwin/ gem 'puma' - end + end end gem 'rspec-rails', '~> 3.0' diff --git a/app/controllers/account_controller.rb b/app/controllers/account_controller.rb index af501fdf9..33d988e35 100644 --- a/app/controllers/account_controller.rb +++ b/app/controllers/account_controller.rb @@ -21,7 +21,6 @@ class AccountController < ApplicationController # prevents login action to be filtered by check_if_login_required application scope filter skip_before_filter :check_if_login_required - # Login request and validation def login if request.get? diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb index 477a8e2b9..9e935ae40 100644 --- a/app/controllers/admin_controller.rb +++ b/app/controllers/admin_controller.rb @@ -354,7 +354,7 @@ class AdminController < ApplicationController @schools = School.where('1=1') end @school_count = @schools.count - @school_pages = Paginator.new @school_count, per_page_option, params['page'] || 1 + @school_pages = Paginator.new @school_count, 100, params['page'] || 1 @schools = paginateHelper @schools,100 respond_to do |format| format.html diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 86c220bd2..6387a97a4 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -38,7 +38,8 @@ class ApplicationController < ActionController::Base protect_from_forgery def handle_unverified_request super - cookies.delete(autologin_cookie_name) + raise(ActionController::InvalidAuthenticityToken) + # cookies.delete(autologin_cookie_name) end before_filter :find_first_page @@ -381,6 +382,11 @@ class ApplicationController < ActionController::Base if allowed true else + if params[:action] == 'show' + #更新申请结果反馈消息的状态 + messages = CourseMessage.where("course_message_type =? and course_id =? and user_id =? and viewed =?", 'CourseRequestDealResult', @course.id, User.current.id, false) + messages.update_all(:viewed => true) + end if @course && @course.archived? render_403 :message => :notice_not_authorized_archived_project else @@ -657,7 +663,8 @@ class ApplicationController < ActionController::Base if api_request? logger.error "Form authenticity token is missing or is invalid. API calls must include a proper Content-type header (text/xml or text/json)." end - render_error "Invalid form authenticity token." + #render_error "Invalid form authenticity token." + redirect_to signin_path(:login=>true) end def render_feed(items, options={}) diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb index ee953e913..37182dbcf 100644 --- a/app/controllers/attachments_controller.rb +++ b/app/controllers/attachments_controller.rb @@ -227,6 +227,8 @@ class AttachmentsController < ApplicationController format.js elsif @attachment.container.is_a?(Message) format.html { redirect_to_referer_or new_board_message_path(@attachment.container) } + elsif @attachment.container.is_a?(BlogComment) + format.html { redirect_to_referer_or user_blog_blog_comment_path(:user_id=>@attachment.container.author.id,:blog_id=>@attachment.container.blog_id,:id=>@attachment.container.id)} elsif @course.nil? format.html { redirect_to_referer_or forum_memo_path(@attachment.container.forum, @attachment.container) } else diff --git a/app/controllers/blog_comments_controller.rb b/app/controllers/blog_comments_controller.rb new file mode 100644 index 000000000..b92223edc --- /dev/null +++ b/app/controllers/blog_comments_controller.rb @@ -0,0 +1,150 @@ +class BlogCommentsController < ApplicationController + include ApplicationHelper + before_filter :find_user + def index + + end + def create + if User.current.logged? + @article = BlogComment.new + @article.author = User.current + @article.blog_id = params[:blog_id] + @article.safe_attributes = params[:blog_comment] + if request.post? + @article.save_attachments(params[:attachments]) + if @article.save + # 更新kindeditor上传的图片资源所有者 + # if params[:asset_id] + # ids = params[:asset_id].split(',') + # update_kindeditor_assets_owner ids,@article.id,OwnerTypeHelper::BLOGCOMMENT + # end + render_attachment_warning_if_needed(@article) + else + end + redirect_to user_blogs_path(:user_id=>params[:user_id]) + else + respond_to do |format| + format.html { + render :layout => 'new_base_user' + } + end + end + else + redirect_to signin_path + end + end + def new + respond_to do |format| + format.html {render :layout=>'new_base_user'} + end + end + def show + @article = BlogComment.find(params[:id]) + respond_to do |format| + format.html {render :layout=>'new_base_user'} + end + end + def update + @article = BlogComment.find(params[:id]) + @article.safe_attributes = params[:blog_comment] + @article.save_attachments(params[:attachments]) + if @article.save + render_attachment_warning_if_needed(@article) + else + end + redirect_to user_blog_blog_comment_path(:user_id=>params[:user_id],:blog_id=>params[:blog_id],:id=>params[:id]) + end + def destroy + @article = BlogComment.find(params[:id]) + if @article.parent_id.nil? #如果是文章被删,那么跳转到用户博客界面,如果带了course_id过来,那么就要跳转到课程首页 + if params[:course_id] #如果带了课程id过来,说明这是课程大纲,不要删除,只需取消课程大纲就ok了 + @course = Course.find(params[:course_id]) + @course.outline = 0 + @course.save + redirect_to course_path(:id=>params[:course_id]) + else + @article.children.delete + @article.delete + redirect_to user_blogs_path(:user_id=>User.current) + end + + else#如果是回复被删, + if params[:course_id] #如果带了course_id过来了,那么这是要跳到课程大纲去的 + @article.delete + redirect_to syllabus_course_path(:id=>params[:course_id]) + else + root = @article.root + @article.delete + redirect_to user_blog_blog_comment_path(:user_id=>root.author_id,:blog_id=>root.blog_id,:id=>root.id) + end + + end + end + + def edit + @article = BlogComment.find(params[:id]) + respond_to do |format| + format.html {render :layout=>'new_base_user'} + end + end + + def quote + @blogComment = BlogComment.find(params[:id]) + @subject = @blogComment.title + @subject = "RE: #{@subject}" unless @subject.starts_with?('RE:') + + @content = "> #{ll(Setting.default_language, :text_user_wrote, @blogComment.author.realname)}\n> " + @temp = BlogComment.new + @course_id = params[:course_id] + @temp.content = "
#{ll(Setting.default_language, :text_user_wrote, @blogComment.author.realname)}".html_safe + respond_to do | format| + format.js + end + end + + #回复 + def reply + if params[:in_user_center] + @in_user_center = true + end + @article = BlogComment.find(params[:id]).root + @quote = params[:quote][:quote] + @blogComment = BlogComment.new + @blogComment.author = User.current + @blogComment.blog = Blog.find(params[:blog_id]) + params[:blog_comment][:sticky] = params[:blog_comment][:sticky] || 0 + params[:blog_comment][:locked] = params[:blog_comment][:locked] || 0 + @blogComment.safe_attributes = params[:blog_comment] + @blogComment.content = @quote + @blogComment.content + @blogComment.title = "RE: #{@article.title}" unless params[:blog_comment][:title] + @article.children << @blogComment + @user_activity_id = params[:user_activity_id] + user_activity = UserActivity.where("act_type='BlogComment' and act_id =#{@article.id}").first + if user_activity + user_activity.updated_at = Time.now + user_activity.save + end + attachments = Attachment.attach_files(@blogComment, params[:attachments]) + render_attachment_warning_if_needed(@blogComment) + #@article.save + # redirect_to user_blogs_path(:user_id=>params[:user_id]) + respond_to do |format| + format.html { + if params[:course_id] #如果呆了course_id过来了,那么这是要跳到课程大纲去的 + redirect_to syllabus_course_path(:id=>params[:course_id]) + else + redirect_to user_blog_blog_comment_path(:user_id=>@article.author_id,:blog_id=>@article.blog_id,:id=>@article) + end + + } + format.js + end + rescue Exception => e #如果上面的代码执行发生异常就捕获 + flash[:notice] = e.message + end + + private + def find_user + @user = User.find(params[:user_id]) + end +end diff --git a/app/controllers/blogs_controller.rb b/app/controllers/blogs_controller.rb new file mode 100644 index 000000000..07bf60464 --- /dev/null +++ b/app/controllers/blogs_controller.rb @@ -0,0 +1,47 @@ +class BlogsController < ApplicationController + before_filter :find_blog,:except => [:index,:create,:new] + before_filter :find_user + def index + @articls = @user.blog.articles + @article = BlogComment.new + respond_to do |format| + format.html {render :layout=>'new_base_user'} + end + end + def create + + end + def new + + end + def show + + end + def update + + end + def destory + + end + def edit + + end + private + def find_blog + if params[:blog_id] + @blog = Blog.find(params[:blog_id]) + else + render_404 + end + if @blog.nil? + #如果某个user的blog不存在,那么就创建一条 + @blog = Blog.create(:name=>User.find(params[:id]).realname , + :description=>'', + :author_id=>params[:id]) + end + end + + def find_user + @user = User.find(params[:user_id]) + end +end diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index 7d26b2eca..1a561006a 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -31,27 +31,24 @@ class CoursesController < ApplicationController def join if User.current.logged? - cs = CoursesService.new - user = User.current - join = cs.join_course params,user - @state = join[:state] - course = join[:course] + cs = CoursesService.new + @user = User.current + join = cs.join_course params,@user + @state = join[:state] + @course = join[:course] + # else + # @course = Course.find_by_id params[:object_id] + # CourseMessage.create(:user_id => @course.tea_id, :course_id => @course.id, :viewed => false,:content=> params[:role],:course_message_id=>User.current.id,:course_message_type=>'JoinCourseRequest') + # @state = 6 + # end else @state = 5 #未登录 end - # if @state == 1 || @state == 3 - # respond_to course_path(course.id) - # else - respond_to do |format| - format.js { render :partial => 'set_join', :locals => {:user => user, :course => course, :object_id => params[:object_id]} } - end - #end - - rescue Exception => e - @state = 4 #已经加入了课程 + @object_id = params[:object_id] respond_to do |format| - format.js { render :partial => 'set_join', :locals => {:user => User.current, :course => nil, :object_id => nil} } + format.js #{ render :partial => 'set_join', :locals => {:user => @user, :course => @course, :object_id => params[:object_id]} } end + end def unjoin @@ -110,7 +107,7 @@ class CoursesController < ApplicationController courses = Course.visible @courses = paginateHelper courses,10 else - courses = Course.visible.where("LOWER(name) like '%#{params[:name].to_s.downcase}%'") + courses = Course.visible.where("LOWER(name) like '%#{params[:name].to_s.downcase}%'").order("time desc, created_at desc") @courses = paginateHelper courses,10 end @name = params[:name] @@ -291,14 +288,11 @@ class CoursesController < ApplicationController def export_course_member_excel @all_members = student_homework_score(0,0,0,"desc") filename="#{@course.teacher.lastname.to_s + @course.teacher.firstname.to_s }_#{@course.name}_#{@course.time.to_s + @course.term}#{l(:excel_member_list)}"; - # 如果是ie 需要转码 - if(/trident/.match(request.env["HTTP_USER_AGENT"]) != nil) - filename= URI::encode(filename) - end + respond_to do |format| format.xls { send_data(member_to_xls(@all_members,@course.course_groups), :type => "text/excel;charset=utf-8; header=present", - :filename => "#{filename}.xls") + :filename => filename_for_content_disposition("#{filename}.xls")) } end end @@ -619,6 +613,10 @@ class CoursesController < ApplicationController create_course_messages = @course.course_messages.where("user_id =? and course_message_type =? and course_id =? and viewed =?", User.current.id, 'Course', @course.id, 0) create_course_messages.update_all(:viewed => true) + #更新申请结果反馈消息的状态 + course_request_messages = CourseMessage.where("user_id =? and course_id =? and course_message_type =? and viewed =?", User.current.id, @course.id, 'CourseRequestDealResult', false) + course_request_messages.update_all(:viewed => true) + course_activities = @course.course_activities @canShowRealName = User.current.member_of_course? @course @page = params[:page] ? params[:page].to_i + 1 : 0 @@ -713,6 +711,41 @@ class CoursesController < ApplicationController end end + #从课程创建的老师那里选择课程大纲 + def course_outline + @teacher = User.find(@course.tea_id) + @blog_articles = @teacher.blog.articles + @is_in_show_outline_page = params[:is_in_show_outline_page] + respond_to do |format| + format.js + end + end + + #根据关键字搜索,查找方法一样的,但返回内容不一样 + def search_course_outline + @article_title = params[:title] + @teacher = User.find(@course.tea_id) + @blog_articles = @teacher.blog.articles.like(@article_title) + render :json=>@blog_articles.to_json + end + + #设置或者更改课程的大纲 + def set_course_outline + @course.outline = params[:outline_id] + @course.save + @is_in_show_outline_page = params[:is_in_show_outline_page] + respond_to do |format| + format.js + end + end + + #显示课程大纲 + def syllabus + @article = BlogComment.find(@course.outline) + respond_to do |format| + format.html {render :layout => 'base_courses'} + end + end #删除课程 #删除课程只是将课程的is_delete状态改为false,is_delete为false状态的课程只有管理员可以看到 def destroy diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb index 057d962c8..dd8dc84c4 100644 --- a/app/controllers/files_controller.rb +++ b/app/controllers/files_controller.rb @@ -1,3 +1,4 @@ +#encoding: utf-8 # Redmine - project management software # Copyright (C) 2006-2013 Jean-Philippe Lang # @@ -331,6 +332,9 @@ class FilesController < ApplicationController #modify by nwb if @project @addTag=false + if params[:in_project_toolbar] + @in_project_toolbar = params[:in_project_toolbar] + end container = (params[:version_id].blank? ? @project : @project.versions.find_by_id(params[:version_id])) attachments = Attachment.attach_filesex(container, params[:attachments], params[:attachment_type]) render_attachment_warning_if_needed(container) @@ -362,6 +366,9 @@ class FilesController < ApplicationController end elsif @course @addTag=false + if params[:in_course_toolbar] + @in_course_toolbar = params[:in_course_toolbar] + end attachments = Attachment.attach_filesex(@course, params[:attachments], params[:attachment_type]) if !attachments.empty? && !attachments[:files].blank? && Setting.notified_events.include?('file_added') @@ -378,6 +385,8 @@ class FilesController < ApplicationController tag_name = l(:label_media) when "4" tag_name = l(:label_code) + when "6" + tag_name = "论文" else tag_name = "" end diff --git a/app/controllers/gantts_controller.rb b/app/controllers/gantts_controller.rb index ee132ac29..710bb2f47 100644 --- a/app/controllers/gantts_controller.rb +++ b/app/controllers/gantts_controller.rb @@ -42,8 +42,8 @@ class GanttsController < ApplicationController respond_to do |format| format.html { render :action => "show", :layout => 'base_projects' }#by young - format.png { send_data(@gantt.to_image, :disposition => 'inline', :type => 'image/png', :filename => "#{basename}.png") } if @gantt.respond_to?('to_image') - format.pdf { send_data(@gantt.to_pdf, :type => 'application/pdf', :filename => "#{basename}.pdf") } + format.png { send_data(@gantt.to_image, :disposition => 'inline', :type => 'image/png', :filename => filename_for_content_disposition("#{basename}.png")) } if @gantt.respond_to?('to_image') + format.pdf { send_data(@gantt.to_pdf, :type => 'application/pdf', :filename => filename_for_content_disposition("#{basename}.pdf") ) } end end end diff --git a/app/controllers/homework_attach_controller.rb b/app/controllers/homework_attach_controller.rb index 5dd5363b9..93459578c 100644 --- a/app/controllers/homework_attach_controller.rb +++ b/app/controllers/homework_attach_controller.rb @@ -33,7 +33,7 @@ class HomeworkAttachController < ApplicationController format.js format.xls { send_data(homework_to_xls(@all_homework_list), :type => "text/excel;charset=utf-8; header=present", - :filename => "#{@course.teacher.lastname.to_s + @course.teacher.firstname}_#{@course.name}_#{@course.time.to_s + @course.term}_#{@bid.name}#{l(:excel_homework_list)}(#{l(:excel_not_rated)}).xls") + :filename => filename_for_content_disposition("#{@course.teacher.lastname.to_s + @course.teacher.firstname}_#{@course.name}_#{@course.time.to_s + @course.term}_#{@bid.name}#{l(:excel_homework_list)}(#{l(:excel_not_rated)}).xls") ) } end end @@ -66,7 +66,7 @@ class HomeworkAttachController < ApplicationController format.js format.xls { send_data(homework_to_xls(all_homework_list), :type => "text/excel;charset=utf-8; header=present", - :filename => "#{@course.teacher.lastname.to_s + @course.teacher.firstname}_#{@course.name}_#{@course.time.to_s + @course.term}_#{@bid.name}#{l(:excel_homework_list)}(#{l(:excel_been_rated)}).xls") + :filename => filename_for_content_disposition("#{@course.teacher.lastname.to_s + @course.teacher.firstname}_#{@course.name}_#{@course.time.to_s + @course.term}_#{@bid.name}#{l(:excel_homework_list)}(#{l(:excel_been_rated)}).xls") ) } end end @@ -101,7 +101,7 @@ class HomeworkAttachController < ApplicationController format.js format.xls { send_data(homework_to_xls(all_homework_list), :type => "text/excel;charset=utf-8; header=present", - :filename => "#{@course.teacher.lastname.to_s + @course.teacher.firstname}_#{@course.name}_#{@course.time.to_s + @course.term}_#{@bid.name}#{l(:excel_homework_list)}.xls") + :filename => filename_for_content_disposition("#{@course.teacher.lastname.to_s + @course.teacher.firstname}_#{@course.name}_#{@course.time.to_s + @course.term}_#{@bid.name}#{l(:excel_homework_list)}.xls") ) } end end diff --git a/app/controllers/homework_common_controller.rb b/app/controllers/homework_common_controller.rb index 9e3a4b836..687ef9503 100644 --- a/app/controllers/homework_common_controller.rb +++ b/app/controllers/homework_common_controller.rb @@ -6,8 +6,8 @@ class HomeworkCommonController < ApplicationController include StudentWorkHelper before_filter :find_course, :only => [:index,:new,:create] - before_filter :find_homework, :only => [:edit,:update,:alert_anonymous_comment,:start_anonymous_comment,:stop_anonymous_comment,:destroy,:start_evaluation_set,:set_evaluation_attr] - before_filter :teacher_of_course, :only => [:new, :create, :edit, :update, :destroy, :start_anonymous_comment, :stop_anonymous_comment, :alert_anonymous_comment,:start_evaluation_set,:set_evaluation_attr] + before_filter :find_homework, :only => [:edit,:update,:alert_anonymous_comment,:start_anonymous_comment,:stop_anonymous_comment,:destroy,:start_evaluation_set,:set_evaluation_attr,:score_rule_set,:alert_forbidden_anonymous_comment] + before_filter :teacher_of_course, :only => [:new, :create, :edit, :update, :destroy, :start_anonymous_comment, :stop_anonymous_comment, :alert_anonymous_comment,:start_evaluation_set,:set_evaluation_attr,:score_rule_set,:alert_forbidden_anonymous_comment] before_filter :member_of_course, :only => [:index] def index @@ -38,6 +38,7 @@ class HomeworkCommonController < ApplicationController def edit @user = User.current @is_in_course = params[:is_in_course].to_i + @course_activity = params[:course_activity].to_i respond_to do |format| format.html{render :layout => 'new_base_user'} end @@ -47,10 +48,18 @@ class HomeworkCommonController < ApplicationController if params[:homework_common] @homework.name = params[:homework_common][:name] @homework.description = params[:homework_common][:description] + if params[:homework_common][:publish_time] == "" + @homework.publish_time = Date.today + else + @homework.publish_time = params[:homework_common][:publish_time] + end @homework.end_time = params[:homework_common][:end_time] || Time.now @homework.course_id = params[:course_id] homework_detail_manual = @homework.homework_detail_manual || HomeworkDetailManual.new + if @homework.publish_time <= Date.today && homework_detail_manual.comment_status == 0 + homework_detail_manual.comment_status = 1 + end homework_detail_manual.evaluation_start = params[:evaluation_start].blank? ? @homework.end_time + 7 : params[:evaluation_start] homework_detail_manual.evaluation_end = params[:evaluation_end].blank? ? homework_detail_manual.evaluation_start + 7 : params[:evaluation_end] @@ -80,8 +89,12 @@ class HomeworkCommonController < ApplicationController @homework_detail_programing.save if @homework_detail_programing if params[:is_in_course] == "1" redirect_to homework_common_index_path(:course => @course.id) - else + elsif params[:is_in_course] == "0" redirect_to user_homeworks_user_path(User.current.id) + elsif params[:is_in_course] == "-1" && params[:course_activity] == "0" + redirect_to user_path(User.current.id) + elsif params[:is_in_course] == "-1" && params[:course_activity] == "1" + redirect_to course_path(@course.id) end end end @@ -93,8 +106,12 @@ class HomeworkCommonController < ApplicationController format.html { if params[:is_in_course] == "1" redirect_to homework_common_index_path(:course => @course.id) - else + elsif params[:is_in_course] == "0" redirect_to user_homeworks_user_path(User.current.id) + elsif params[:is_in_course] == "-1" && params[:course_activity] == "0" + redirect_to user_path(User.current.id) + elsif params[:is_in_course] == "-1" && params[:course_activity] == "1" + redirect_to course_path(@course.id) end } end @@ -130,6 +147,9 @@ class HomeworkCommonController < ApplicationController else @statue = 3 end + @user_activity_id = params[:user_activity_id].to_i + @is_in_course = params[:is_in_course].to_i + @course_activity = params[:course_activity].to_i end #关闭匿评 @@ -145,6 +165,9 @@ class HomeworkCommonController < ApplicationController # 匿评关闭消息邮件通知 send_message_anonymous_comment(@homework, m_status = 3) Mailer.send_mail_anonymous_comment_close(@homework).deliver + @user_activity_id = params[:user_activity_id].to_i + @is_in_course = params[:is_in_course].to_i + @course_activity = params[:course_activity].to_i respond_to do |format| format.js end @@ -171,6 +194,22 @@ class HomeworkCommonController < ApplicationController @homework.student_works.map { |work| @cur_size += work.student_works_scores.where(:reviewer_role => 3).count} end @percent = format("%.2f",(@cur_size.to_f / ( @totle_size == 0 ? 1 : @totle_size)) * 100) + @user_activity_id = params[:user_activity_id].to_i + @is_in_course = params[:is_in_course].to_i + @course_activity = params[:course_activity].to_i + respond_to do |format| + format.js + end + end + + def alert_forbidden_anonymous_comment + if params[:user_activity_id] + @user_activity_id = params[:user_activity_id] + else + @user_activity_id = -1 + end + @is_in_course = params[:is_in_course] if params[:is_in_course] + @course_activity = params[:course_activity] if params[:course_Activity] respond_to do |format| format.js end @@ -215,6 +254,16 @@ class HomeworkCommonController < ApplicationController end end + #评分设置 + def score_rule_set + if params[:user_activity_id] + @user_activity_id = params[:user_activity_id] + else + @user_activity_id = -1 + end + @is_in_course = params[:is_in_course] + end + private #获取课程 def find_course diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb index 923414583..e529dd3b9 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.rb @@ -151,7 +151,7 @@ class IssuesController < ApplicationController format.atom { render :template => 'journals/index', :layout => false, :content_type => 'application/atom+xml' } format.pdf { pdf = issue_to_pdf(@issue, :journals => @journals) - send_data(pdf, :type => 'application/pdf', :filename => "#{@project.identifier}-#{@issue.id}.pdf") + send_data(pdf, :type => 'application/pdf', :filename => filename_for_content_disposition("#{@project.identifier}-#{@issue.id}.pdf") ) } end end diff --git a/app/controllers/members_controller.rb b/app/controllers/members_controller.rb index 6bb61e6a1..4dc2c52f5 100644 --- a/app/controllers/members_controller.rb +++ b/app/controllers/members_controller.rb @@ -159,6 +159,14 @@ class MembersController < ApplicationController if role && (role.name == "学生" || role.name == "Student") StudentsForCourse.create(:student_id => user_id, :course_id =>@course.id) end + + #给新成员和老师发送加入课程的消息,发送者id放在CourseMessage的course_message_id字段中 + #course_message_type设置为JoinCourse + #status = 0 表示给学生发,status = 1表示给老师发 + course_join = CourseMessage.new(:user_id =>user_id, :course_message_id=>User.current.id,:course_id => @course.id,:course_message_type=>"JoinCourse", :content => role, :viewed => false, :status => 0) + course_join.save + CourseMessage.create(:user_id => User.current.id, :course_message_id => user_id, :course_id => @course.id, :course_message_type => "JoinCourse",:content => role, :viewed => false, :status => 1) + members << member #user_grades << UserGrade.new(:user_id => user_id, :course_id => @course.id) if (params[:membership][:role_ids]) @@ -305,7 +313,8 @@ class MembersController < ApplicationController grade.destroy end end - ForgeMessage.create(:user_id => @member.user_id, :project_id => @project.id, :forge_message_type => "RemoveFromProject", :viewed => false, :forge_message_id => User.current.id) + #移出项目发送消息 + ForgeMessage.create(:user_id => @member.user_id, :project_id => @project.id, :forge_message_type => "RemoveFromProject", :viewed => false, :forge_message_id => User.current.id) end respond_to do |format| format.html { redirect_to_settings_in_projects } @@ -333,6 +342,8 @@ class MembersController < ApplicationController end @roles = Role.givable.all[3..5] @members = @course.member_principals.includes(:roles, :principal).all.sort + #移出课程发送消息 + CourseMessage.create(:user_id => @member.user_id, :course_id => @course.id, :course_message_type => "RemoveFromCourse", :viewed => false, :course_message_id => User.current.id) end respond_to do |format| format.html { redirect_to_settings_in_courses } diff --git a/app/controllers/poll_controller.rb b/app/controllers/poll_controller.rb index a8f2a11f1..ec54ae8a4 100644 --- a/app/controllers/poll_controller.rb +++ b/app/controllers/poll_controller.rb @@ -413,7 +413,7 @@ class PollController < ApplicationController respond_to do |format| format.xls { send_data(poll_to_xls(poll_questions), :type => "text/excel;charset=utf-8; header=present", - :filename => "#{@poll.polls_name}.xls") + :filename => filename_for_content_disposition("#{@poll.polls_name}.xls") ) } end end diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index f2f10d5b6..1f252cc24 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -29,12 +29,12 @@ class RepositoriesController < ApplicationController menu_item :repository menu_item :settings, :only => [:new, :create, :edit, :update, :destroy, :committers] default_search_scope :changesets - + before_filter :find_project_by_project_id, :only => [:new, :create, :newrepo] before_filter :find_repository, :only => [:edit, :update, :destroy, :committers] - before_filter :find_project_repository, :except => [:new, :create, :newcreate, :edit, :update, :destroy, :committers, :newrepo] + before_filter :find_project_repository, :except => [:new, :create, :newcreate, :edit, :update, :destroy, :committers, :newrepo,:to_gitlab] before_filter :find_changeset, :only => [:revision, :add_related_issue, :remove_related_issue] - before_filter :authorize , :except => [:newrepo,:newcreate,:fork] + before_filter :authorize , :except => [:newrepo,:newcreate,:fork, :to_gitlab] accept_rss_auth :revisions # hidden repositories filter // 隐藏代码过滤器 before_filter :check_hidden_repo, :only => [:show, :stats, :revisions, :revision, :diff ] @@ -42,7 +42,7 @@ class RepositoriesController < ApplicationController include RepositoriesHelper helper :project_score #@root_path = RepositoriesHelper::ROOT_PATH - + rescue_from Redmine::Scm::Adapters::CommandFailed, :with => :show_error_command_failed def new @@ -62,8 +62,8 @@ class RepositoriesController < ApplicationController end end - - + + def newrepo scm = params[:repository_scm] || (Redmine::Scm::Base.all & Setting.enabled_scm).first @repository = Repository.factory(scm) @@ -76,23 +76,23 @@ class RepositoriesController < ApplicationController render :layout => 'base_projects' end end - + def fork @repository_url = params[:repository_url] - + # @repository.url # system "htpasswd -mb "+@root_path+"user.passwd "+params[:repository][:identifier]+" "+@upasswd # system "echo -e '"+params[:project_id]+"-"+params[:repository][:identifier]+"-write:"+ - # " "+params[:repository][:identifier]+"' >> "+@root_path+"group.passwd" - system "git clone --bare "+@repository_url + # " "+params[:repository][:identifier]+"' >> "+@root_path+"group.passwd" + system "git clone --bare "+@repository_url # system "mv "+@project_path+"/hooks/post-update{.sample,}" # system "chmod a+x "+@project_path+"/hooks/post-update" # system "."+@project_path+"/hooks/post-update" # system "echo -e 'Allow from all \n Order Deny,Allow \n "+ - # "
#{@blogComment.content.html_safe}
<%= line.html_safe %>+
<%= line.html_safe %>