diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index 6dec9a82f..126b269bb 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -127,18 +127,19 @@ update end else # 原逻辑 ##xianbo - params[:repository_scm] = "Git" @root_path=RepositoriesHelper::ROOT_PATH @repository_name=User.current.login.to_s+"/"+params[:repository][:identifier]+".git" @project_path=@root_path+"htdocs/"+@repository_name - @repository_tag=params[:repository][:upassword] || params[:repository][:password] || '1234' + @repository_tag=params[:repository][:upassword] || params[:repository][:password] @repo_name=User.current.login.to_s+"_"+params[:repository][:identifier] logger.info "htpasswd -mb "+@root_path+"htdocs/user.passwd "+@repo_name+": "+@repository_tag logger.info "the value of create repository"+@root_path+": "+@repository_name+": "+@project_path+": "+@repo_name attrs = pickup_extra_info - params[:repository][:url]=@project_path + if((@repository_tag!="")&¶ms[:repository_scm]=="Git") + params[:repository][:url]=@project_path + end ###xianbo - @repository = Repository.factory(params[:repository_scm]||"Git") + @repository = Repository.factory(params[:repository_scm]) @repository.safe_attributes = params[:repository] if attrs[:attrs_extra].keys.any? @repository.merge_extra_info(attrs[:attrs_extra]) @@ -277,8 +278,7 @@ update @course_tag = params[:course] project_path_cut = RepositoriesHelper::PROJECT_PATH_CUT ip = RepositoriesHelper::REPO_IP_ADDRESS - # @repos_url = "http://"+@repository.login.to_s+"_"+@repository.identifier.to_s+"@"+ip.to_s+ - @repos_url = "http://#{Setting.host_name}/#{@repository.login.to_s}/#{@repository.identifier.to_s}.git" + @repos_url = "http://"+@repository.login.to_s+"_"+@repository.identifier.to_s+"@"+ip.to_s+ @repository.url.slice(project_path_cut, @repository.url.length).to_s if @course_tag == 1 render :action => 'show', :layout => 'base_courses' diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 2b6f2d28f..544ed7bf5 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -39,20 +39,14 @@ class UsersController < ApplicationController # before_filter :can_show_course, :only => [:user_courses,:user_homeworks] - before_filter :require_admin, :except => [:show, :index, :search, :tag_save, :tag_saveEx,:user_projects, :user_newfeedback, :user_comments, :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,:user_activities,:user_projects_index, - :user_courses4show,:user_projects4show,:user_course_activities,:user_project_activities,:user_feedback4show,:user_visitorlist, - :user_resource,:user_resource_create,:user_resource_delete,:rename_resource,:search_user_course,:add_exist_file_to_course, - :search_user_project,:resource_preview,:resource_search,:add_exist_file_to_project,:user_messages,:edit_brief_introduction,:user_new_homework] #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, :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,:user_projects_index,:user_resource, - :user_courses4show,:user_projects4show,:user_course_activities,:user_project_activities,:user_feedback4show,:user_visitorlist,:user_messages,:edit_brief_introduction] + :user_courses4show,:user_projects4show,:user_course_activities,:user_project_activities,:user_feedback4show,:user_visitorlist,:user_messages,:edit_brief_introduction, + :user_import_homeworks,:user_search_homeworks] before_filter :auth_user_extension, only: :show #before_filter :rest_user_score, only: :show #before_filter :select_entry, only: :user_projects @@ -310,7 +304,46 @@ class UsersController < ApplicationController respond_to do |format| format.js format.html {render :layout => 'new_base_user'} + end end + + #导入作业 + def user_import_homeworks + @user_homeworks = HomeworkCommon.where(:user_id => @user.id).order("created_at desc") + respond_to do |format| + format.js + end + end + + #用户主页过滤作业 + def user_search_homeworks + @user_homeworks = HomeworkCommon.where("user_id = '#{@user.id}' and lower(name) like '%#{params[:name].to_s.downcase}%'").order("created_at desc") + respond_to do |format| + format.js + end + end + + #导入作业,确定按钮 + def user_select_homework + homework = HomeworkCommon.find_by_id params[:checkMenu] + @homework = HomeworkCommon.new + if homework + @homework.name = homework.name + @homework.description = homework.description + @homework.end_time = homework.end_time + @homework.course_id = homework.course_id + homework.attachments.each do |attachment| + att = attachment.copy + att.container_id = nil + att.container_type = nil + att.copy_from = attachment.id + att.save + @homework.attachments << att + end + end + respond_to do |format| + format.js + end end def user_new_homework @@ -962,13 +995,13 @@ class UsersController < ApplicationController end end @type = params[:type] || 1 - @limit = 15 + @limit = 25 @is_remote = true @atta_count = @attachments.count @atta_pages = Paginator.new @atta_count, @limit, params['page'] || 1 @offset ||= @atta_pages.offset #@curse_attachments_all = @all_attachments[@offset, @limit] - @attachments = paginateHelper @attachments,15 + @attachments = paginateHelper @attachments,25 respond_to do |format| format.js end @@ -1018,13 +1051,13 @@ class UsersController < ApplicationController end end @type = params[:type] - @limit = 15 + @limit = 25 @is_remote = true @atta_count = @attachments.count @atta_pages = Paginator.new @atta_count, @limit, params['page'] || 1 @offset ||= @atta_pages.offset #@curse_attachments_all = @all_attachments[@offset, @limit] - @attachments = paginateHelper @attachments,15 + @attachments = paginateHelper @attachments,25 respond_to do |format| format.js end @@ -1422,13 +1455,13 @@ class UsersController < ApplicationController end end @type = params[:type] - @limit = 15 + @limit = 25 @is_remote = true @atta_count = @attachments.count @atta_pages = Paginator.new @atta_count, @limit, params['page'] || 1 @offset ||= @atta_pages.offset #@curse_attachments_all = @all_attachments[@offset, @limit] - @attachments = paginateHelper @attachments,15 + @attachments = paginateHelper @attachments,25 respond_to do |format| format.js format.html {render :layout => 'new_base_user'} @@ -1474,13 +1507,13 @@ class UsersController < ApplicationController end end @type = params[:type] - @limit = 15 + @limit = 25 @is_remote = true @atta_count = @attachments.count @atta_pages = Paginator.new @atta_count, @limit, params['page'] || 1 @offset ||= @atta_pages.offset #@curse_attachments_all = @all_attachments[@offset, @limit] - @attachments = paginateHelper @attachments,15 + @attachments = paginateHelper @attachments,25 respond_to do |format| format.js end diff --git a/app/views/projects/settings/_new_repositories.html.erb b/app/views/projects/settings/_new_repositories.html.erb index b626b4089..be793a409 100644 --- a/app/views/projects/settings/_new_repositories.html.erb +++ b/app/views/projects/settings/_new_repositories.html.erb @@ -62,6 +62,16 @@ <%= labelled_form_for :repository, @repository, :url =>project_repositories_path(@project),:html => {:id => 'repository-form',:method=>"post"} do |f| %>