diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index 0a3c61c90..1a561006a 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -107,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] diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb index 057d962c8..1cd5b0f15 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 # @@ -378,6 +379,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/repositories_controller.rb b/app/controllers/repositories_controller.rb index 8a1b3bbe0..1f252cc24 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -215,19 +215,15 @@ update end end - unless @repository.gitlab? - # redirect_to to_gitlab_project_repository_path(@project, @repository) - render :to_gitlab - return - end + # unless @repository.gitlab? + # # redirect_to to_gitlab_project_repository_path(@project, @repository) + # render :to_gitlab + # return + # end #if( !User.current.member_of?(@project) || @project.hidden_repo) @repository.fetch_changesets if Setting.autofetch_changesets? && @path.empty? - # g = Gitlab.client - # project = g.project(20) - # rr = g.trees(project.id, @path) - # r = g.get ("/projects/#{@project}/repository/tree") # :name, :path, :kind, :size, :lastrev, :changeset @entries = @repository.entries(@path, @rev) # @trees = g.trees(project, @path) @@ -241,10 +237,18 @@ update #Modified by young # (show_error_not_found; return) unless @entries g = Gitlab.client - @changesets = g.get ("/projects/#{@project.gpid}/repository/commits") + count = 0 + (0..100).each do |page| + if g.commits(@project.gpid,:page => page).count == 0 + break + else + count = count + g.commits(@project.gpid,:page => page).count + end + end + @changesets = g.commits(@project.gpid) # @changesets = @repository.latest_changesets(@path, @rev) # @changesets_count = @repository.latest_changesets(@path, @rev).count - @changesets_count = @changesets.count + @changesets_all_count = count @changesets_latest_coimmit = @changesets[0] @properties = @repository.properties(@path, @rev) @repositories = @project.repositories @@ -252,11 +256,10 @@ update project_path_cut = RepositoriesHelper::PROJECT_PATH_CUT ip = RepositoriesHelper::REPO_IP_ADDRESS gitlab_address = Redmine::Configuration['gitlab_address'] - if @repository.type.to_s=="Repository::Gitlab" + if @repository.type.to_s == "Repository::Gitlab" @repos_url = gitlab_address.to_s+"/"+@project.owner.to_s+"/"+@repository.identifier+"."+"git" else - @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 + @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 end if @course_tag == 1 render :action => 'show', :layout => 'base_courses' @@ -272,7 +275,9 @@ update @entry = @repository.entry(@path, @rev) (show_error_not_found; return) unless @entry g = Gitlab.client - @changesets = g.get ("/projects/#{@project.gpid}/repository/commits?#{@rev}") + @commits = g.commits(@project.gpid, page:params[:pamge]) + @commit = g.commit(@project.gpid,@rev) + # @changesets = g.get ("/projects/#{@project.gpid}/repository/commits?#{@rev}") #@changesets = @repository.latest_changesets(@path, @rev, Setting.repository_log_display_limit.to_i) @properties = @repository.properties(@path, @rev) @changeset = @repository.find_changeset_by_name(@rev) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 84364b4f6..b6c4ec91b 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -609,6 +609,17 @@ module ApplicationHelper return @result end + # 判断版本库是否初始为gitlab + def rep_is_gitlab?(project) + rep = Repository.where("project_id =? and type =?", project, "Repository::Gitlab") + return rep.blank? ? true :false + end + + # 获取单一gitlab项目 + def gitlab_repository(project) + rep = Repository.where("project_id =? and type =?", project.id,"Repository::Gitlab" ).first + end + # 判断当前用户是否为项目管理员 def is_project_manager?(user_id, project_id) @result = false diff --git a/app/helpers/projects_helper.rb b/app/helpers/projects_helper.rb index 41f25d1a3..51d1846d8 100644 --- a/app/helpers/projects_helper.rb +++ b/app/helpers/projects_helper.rb @@ -117,6 +117,22 @@ module ProjectsHelper end end + # 获取新增gitlab版本库 + def rep_gitlab(project) + rep = Repository.where("project_id =? and type =?", project, "Repository::Gitlab") + end + + # 获取新项目的版本库地址 + def rep_gitlab_url(project) + gitlab_address = Redmine::Configuration['gitlab_address'] + url = gitlab_address.to_s+"/"+project.owner.to_s+"/"+ rep_gitlab(project).first.identifier+"."+"git" + end + + # # 获取Forge历史版本库 + def rep_forge(project) + rep = Repository.where("project_id =? and type =?", project, "Repository::Git") + end + # Added by young def course_settings_tabs tabs = [{:name => 'info', :action => :edit_project, :partial => 'projects/edit', :label => :label_information_plural, :course=>'1'}, diff --git a/app/services/courses_service.rb b/app/services/courses_service.rb index 74580632f..c8af509f8 100644 --- a/app/services/courses_service.rb +++ b/app/services/courses_service.rb @@ -303,6 +303,7 @@ class CoursesService #@state == 7 您已经发送过申请了,请耐心等待 #@state == 8 您已经是该课程的教师了 #@state == 9 您已经是该课程的教辅了 + #@state == 10 您已经是该课程的管理员了 #@state 其他 未知错误,请稍后再试 def join_course params,current_user course = Course.find_by_id params[:object_id] @@ -325,6 +326,8 @@ class CoursesService #如果加入的角色教辅并且当前为教辅 elsif params[:role] == "7" && roleName == "TeachingAsistant" @state = 9 + elsif roleName == "Manager" + @state = 10 #如果加入角色为教师或者教辅,并且当前是学生,或者是要成为教辅,当前不是教辅,或者要成为教师,当前不是教师。那么要发送请求 elsif (params[:role] != "10" && roleName == "Student") || (params[:role] == "7" && roleName != "TeachingAsistant" ) || (params[:role] == "9" && roleName != "Teacher" ) #如果已经发送过消息了,那么就要给个提示 diff --git a/app/views/account/login.html.erb b/app/views/account/login.html.erb index ed43f455a..fadf5e465 100644 --- a/app/views/account/login.html.erb +++ b/app/views/account/login.html.erb @@ -86,6 +86,9 @@ } function register(){ + if($("#loginUpButton").hasClass('loginUpDisableButton')){ + return; + } if($login_correct && $mail_correct && $passwd_correct && $passwd_comfirm_correct && $("#read_and_confirm").attr("checked") == 'checked'){ $("#main_reg_form").submit(); }else{ @@ -182,6 +185,16 @@ $('#main_login_form').submit(); } } + + function changeRegisterBtn(checkbox){ + if(checkbox.checked == true){ + $("#loginUpButton").removeClass('loginUpDisableButton'); + $("#loginUpButton").addClass('loginUpButton'); + }else{ + $("#loginUpButton").removeClass('loginUpButton') + $("#loginUpButton").addClass('loginUpDisableButton'); + } + }