From d4823e7c8b606fac2cf8d81c1d8501670c20dd06 Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Tue, 1 Dec 2015 15:48:25 +0800 Subject: [PATCH 01/21] =?UTF-8?q?=E8=B4=B4=E5=90=A7=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E6=97=B6=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/forums/_show_topics.html.erb | 2 +- app/views/memos/show.html.erb | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/app/views/forums/_show_topics.html.erb b/app/views/forums/_show_topics.html.erb index bb8a91b69..dc3a20482 100644 --- a/app/views/forums/_show_topics.html.erb +++ b/app/views/forums/_show_topics.html.erb @@ -16,7 +16,7 @@
最后回复:<%= author.name%>
<%= format_date(topic.last_reply.created_at)%>
<% end%> - + 更新时间:<%= format_date(topic.updated_at)%>
diff --git a/app/views/memos/show.html.erb b/app/views/memos/show.html.erb index efcd15a66..c05b63427 100644 --- a/app/views/memos/show.html.erb +++ b/app/views/memos/show.html.erb @@ -79,6 +79,8 @@ <%= render :partial => 'attachments_links', :locals => {:attachments => @memo.attachments, :options => options, :is_float => true} %> <% end %>
+
+ 更新时间:<%= format_date(@memo.updated_at)%>
From 35b543cd22ad41fb7cd8e2c562f2901bf1d757f0 Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Tue, 1 Dec 2015 17:23:14 +0800 Subject: [PATCH 02/21] =?UTF-8?q?=E8=AE=BA=E5=9D=9B=E5=8F=91=E5=B8=96=20?= =?UTF-8?q?=E9=87=87=E7=94=A8ajax=E6=8F=90=E4=BA=A4=E3=80=82=E8=BF=99?= =?UTF-8?q?=E6=A0=B7=E5=AD=90=E7=BD=91=E7=BB=9C=E4=B8=8D=E5=A5=BD=E7=9A=84?= =?UTF-8?q?=E6=83=85=E5=86=B5=E5=B0=B1=E4=B8=8D=E4=BC=9A=E4=B8=A2=E5=A4=B1?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E4=BA=86=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/memos_controller.rb | 6 +++++- app/views/forums/show.html.erb | 18 ++++++++++++++++-- app/views/layouts/base_forums.html.erb | 2 +- app/views/memos/create.js.erb | 1 + app/views/memos/edit.html.erb | 16 +++++++++++++++- app/views/memos/update.js.erb | 5 +++++ 6 files changed, 43 insertions(+), 5 deletions(-) create mode 100644 app/views/memos/create.js.erb create mode 100644 app/views/memos/update.js.erb diff --git a/app/controllers/memos_controller.rb b/app/controllers/memos_controller.rb index 4181090a5..2d2c058d4 100644 --- a/app/controllers/memos_controller.rb +++ b/app/controllers/memos_controller.rb @@ -73,6 +73,7 @@ class MemosController < ApplicationController end end #end + format.js format.html { redirect_to back_memo_url, notice: "#{l :label_memo_create_succ}" } format.json { render json: @memo, status: :created, location: @memo } else @@ -152,6 +153,7 @@ class MemosController < ApplicationController end def update + @flag = false respond_to do |format| if( #@memo.update_column(:subject, params[:memo][:subject]) && @memo.update_column(:content, params[:memo][:content]) && @@ -159,10 +161,12 @@ class MemosController < ApplicationController @memo.update_column(:lock, params[:memo][:lock]) && @memo.update_column(:subject,params[:memo][:subject])) @memo.save_attachments(params[:attachments] || (params[:memo] && params[:memo][:uploads])) - @memo.save + @flag = @memo.save # @memo.root.update_attribute(:updated_at, @memo.updated_at) + format.js format.html {redirect_to back_memo_url, notice: "#{l :label_memo_create_succ}"} else + format.js format.html { render action: "edit" } format.json { render json: @person.errors, status: :unprocessable_entity } end diff --git a/app/views/forums/show.html.erb b/app/views/forums/show.html.erb index 05c086ed4..ad9195804 100644 --- a/app/views/forums/show.html.erb +++ b/app/views/forums/show.html.erb @@ -3,7 +3,7 @@
@@ -674,7 +674,7 @@
  • 课程名称:<%= ma.course_message.course.name %>(<%= ma.course_message.course.time.to_s + '年'+ ma.course_message.course.term %>)
  • 测验标题:<%= ma.course_message.exercise_name %>
  • 截止时间:<%= ma.course_message.end_time.to_s.gsub("+0800","").to_datetime.strftime("%Y-%m-%d %H:%M:%S") %>
  • -
  • 答题时间:<%= ma.course_message.time == 0 ? '无限制' : ma.course_message.time.to_s + '分钟' %>
  • +
  • 答题时长:<%= ma.course_message.time == -1 ? '无限制' : ma.course_message.time.to_s + '分钟' %>
  • 请及时完成课程测验,辛苦啦!

    diff --git a/lib/tasks/exercise_close_to_deadline_warn.rake b/lib/tasks/exercise_close_to_deadline_warn.rake index 2deb7204e..e2808818f 100644 --- a/lib/tasks/exercise_close_to_deadline_warn.rake +++ b/lib/tasks/exercise_close_to_deadline_warn.rake @@ -1,5 +1,5 @@ #coding=utf-8 - +#需要在0点以后执行 namespace :exercise_deadline_warn do desc "exercise deadline warn" task :deadline_warn => :environment do From c1747ab2172f695174736d68546129ccbb33e3c3 Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 4 Dec 2015 15:49:05 +0800 Subject: [PATCH 15/21] =?UTF-8?q?fork=E9=87=8D=E5=90=8D=EF=BC=8C=E6=8F=90?= =?UTF-8?q?=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/repositories_controller.rb | 63 ++++++++++++------- app/views/repositories/show.html.erb | 6 +- ...1204062220_add_forked_count_to_projects.rb | 5 ++ db/schema.rb | 14 +---- lib/gitlab-cli/lib/gitlab/client/projects.rb | 5 +- 5 files changed, 56 insertions(+), 37 deletions(-) create mode 100644 db/migrate/20151204062220_add_forked_count_to_projects.rb diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index 2bd54954a..c1e124063 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -64,32 +64,53 @@ class RepositoriesController < ApplicationController end def forked - # 被forked的标识如果不满足单个用户唯一性,则不执行fork - if is_sigle_identifier?(User.current, @repository.identifier) - # REDO: 那些人有权限forked项目 - g = Gitlab.client - gproject = g.post ("/projects/fork/#{@project.gpid}?user_id=#{User.current.gid}") - if gproject - copy_project(@project, gproject) - end + # 如果当前用户已经fork过该项目,不会新fork项目,则跳至已fork的项 + unless has_forked?(@project, User.current) + project = project_from_current_project(@project.id, User.current.id) + redirect_to project_path(project) else - flash[:notice] = l(:project_gitlab_fork_double_message) - redirect_to settings_project_url(@project, :tab => 'repositories') + # 单个用户只能拥有一个名字一样的版本库,否则不能fork + # if is_sigle_identifier?(User.current, @repository.identifier) + # REDO: 那些人有权限forked项目 + g = Gitlab.client + gproject = g.fork(@project.gpid, User.current.gid) + if gproject + copy_project(@project, gproject) + forked_count = @project.forked_count.to_i + 1 + @project.update_attributes(:forked_count => forked_count) + end + # else + # flash[:notice] = l(:project_gitlab_fork_double_message) + # redirect_to settings_project_url(@project, :tab => 'repositories') + # end end + + end + + # 判断用户是否已经fork过该项目 + def has_forked?(project, user) + projects = Project.where("user_id =?", user) + projects.map(&:forked_from_project_id).detect{|s| s == @project.id}.nil? ? true : false + end + + # 获取当前用户fork过的项目 + def project_from_current_project(project, user) + project = Project.where("user_id =? and forked_from_project_id =?",user, project).first end # copy a project for fork - def copy_project(project, gproject) + def copy_project(tproject, gproject) project = Project.new - project.name = @project.name - project.is_public = @project.is_public - project.status = @project.status - project.description = @project.description - project.hidden_repo = @project.hidden_repo + project.name = tproject.name + project.is_public = tproject.is_public + project.status = tproject.status + project.description = tproject.description + project.hidden_repo = tproject.hidden_repo project.user_id = User.current.id project.project_type = 0 - project.project_new_type = @project.project_new_type + project.project_new_type = tproject.project_new_type project.gpid = gproject.id + project.forked_from_project_id = tproject.id if project.save r = Role.givable.find_by_id(Setting.new_project_user_role_id.to_i) || Role.givable.first m = Member.new(:user => User.current, :roles => [r]) @@ -124,16 +145,16 @@ class RepositoriesController < ApplicationController def copy_repository(project, gproject) # 避免 - if is_sigle_identifier?(project.user_id, gproject.name) + # if is_sigle_identifier?(project.user_id, gproject.name) repository = Repository.factory('Git') repository.project_id = project.id repository.type = 'Repository::Gitlab' repository.url = gproject.name repository.identifier = gproject.name repository = repository.save - else - flash[:notice] = l(:project_gitlab_create_double_message) - end + # else + # flash[:notice] = l(:project_gitlab_create_double_message) + # end end def newrepo diff --git a/app/views/repositories/show.html.erb b/app/views/repositories/show.html.erb index 324dc6202..d8b7c4625 100644 --- a/app/views/repositories/show.html.erb +++ b/app/views/repositories/show.html.erb @@ -25,8 +25,10 @@
    ZIP
    -
    Fork 0
    - + + +
    <%= link_to "Fork", :controller => 'repositories', :action => 'forked'%> + <%= @project.forked_count.to_i %>
    <% if @changesets && !@changesets.empty? %> diff --git a/db/migrate/20151204062220_add_forked_count_to_projects.rb b/db/migrate/20151204062220_add_forked_count_to_projects.rb new file mode 100644 index 000000000..79fdc2573 --- /dev/null +++ b/db/migrate/20151204062220_add_forked_count_to_projects.rb @@ -0,0 +1,5 @@ +class AddForkedCountToProjects < ActiveRecord::Migration + def change + add_column :projects, :forked_count, :integer + end +end diff --git a/db/schema.rb b/db/schema.rb index 6ad6c585f..a1e14c3bd 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20151203072815) do +ActiveRecord::Schema.define(:version => 20151204062220) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -738,17 +738,6 @@ ActiveRecord::Schema.define(:version => 20151203072815) do add_index "homework_commons", ["course_id", "id"], :name => "index_homework_commons_on_course_id_and_id" - create_table "homework_detail_groups", :force => true do |t| - t.integer "homework_common_id" - t.integer "min_num" - t.integer "max_num" - t.integer "base_on_project" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - add_index "homework_detail_groups", ["homework_common_id"], :name => "index_homework_detail_groups_on_homework_common_id" - create_table "homework_detail_manuals", :force => true do |t| t.float "ta_proportion" t.integer "comment_status" @@ -1330,6 +1319,7 @@ ActiveRecord::Schema.define(:version => 20151203072815) do t.integer "project_new_type" t.integer "gpid" t.integer "forked_from_project_id" + t.integer "forked_count" end add_index "projects", ["lft"], :name => "index_projects_on_lft" diff --git a/lib/gitlab-cli/lib/gitlab/client/projects.rb b/lib/gitlab-cli/lib/gitlab/client/projects.rb index 3fab4347f..8d91edd06 100644 --- a/lib/gitlab-cli/lib/gitlab/client/projects.rb +++ b/lib/gitlab-cli/lib/gitlab/client/projects.rb @@ -241,8 +241,9 @@ class Gitlab::Client # Forks a project into the user namespace of the authenticated user. # @param [Integer] - The ID of the project to be forked - def fork(id) - post("/projects/fork/#{id}") + def fork(gpid, gid) + post ("/projects/fork/#{gpid}?user_id=#{gid}") + # post("/projects/fork/#{id}") end # Mark this project as forked from the other From 4a41039fa62546d4b7953507cc3378ef493250a0 Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 4 Dec 2015 15:58:56 +0800 Subject: [PATCH 16/21] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E8=8B=B1=E9=9B=84?= =?UTF-8?q?=E6=A6=9C=E6=94=B9=E6=88=90=E8=AF=BE=E7=A8=8B=E6=B4=BB=E8=B7=83?= =?UTF-8?q?=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/layouts/base_courses.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/layouts/base_courses.html.erb b/app/views/layouts/base_courses.html.erb index 981d44ce7..c37af0dc1 100644 --- a/app/views/layouts/base_courses.html.erb +++ b/app/views/layouts/base_courses.html.erb @@ -208,7 +208,7 @@
    <% unless contributor_course_scor(@course.id).count == 0 %>
      -

      课程贡献榜

      +

      课程活跃度

      <% contributor_course_scor(@course.id).each do |contributor_score| %> <% unless contributor_score.total_score ==0 %>
    • <%=link_to image_tag(url_to_avatar(contributor_score.user), :width => "35", :height => "35", :class=> "rankPortrait"),user_path(contributor_score.user) %> From dfa9b4cf743f5f5165f3d5105683e97a5f0ce718 Mon Sep 17 00:00:00 2001 From: Tim Date: Fri, 4 Dec 2015 16:13:55 +0800 Subject: [PATCH 17/21] =?UTF-8?q?=E5=AD=A6=E7=94=9F=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/courses/member.html.erb | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/app/views/courses/member.html.erb b/app/views/courses/member.html.erb index ce336373b..e906bf778 100644 --- a/app/views/courses/member.html.erb +++ b/app/views/courses/member.html.erb @@ -1,9 +1,10 @@ -
      -

      <%= @subPage_title%>

      -
      -<% if @subPage_title == l(:label_student_list)%> - <%= render :partial => 'course_student', :locals => {:members => @members} %> -<% else%> - <%= render :partial => 'course_teacher', :locals => {:members => @members} %> -<% end%> - +
      +

      <%= @subPage_title%>

      + 修改角色 +
      +<% if @subPage_title == l(:label_student_list)%> + <%= render :partial => 'course_student', :locals => {:members => @members} %> +<% else%> + <%= render :partial => 'course_teacher', :locals => {:members => @members} %> +<% end%> + From b6edabed9c059ccd07750876799310c6f378f319 Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 4 Dec 2015 16:21:48 +0800 Subject: [PATCH 18/21] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=A7=92=E8=89=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/courses_controller.rb | 1 + app/views/courses/settings.html.erb | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index cd1de16fc..5da9db395 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -374,6 +374,7 @@ class CoursesController < ApplicationController def settings if User.current.allowed_to?(:as_teacher,@course) + @issue_custom_fields = IssueCustomField.sorted.all @issue_category ||= IssueCategory.new @member ||= @course.members.new diff --git a/app/views/courses/settings.html.erb b/app/views/courses/settings.html.erb index 5c3918f00..8d3454776 100644 --- a/app/views/courses/settings.html.erb +++ b/app/views/courses/settings.html.erb @@ -1,6 +1,13 @@

      <%= l(:label_course_modify_settings)%>

      +
        @@ -118,4 +125,4 @@ } $("#time_selected").click(select); $("#term_selected").click(select); - + From 9716e99533600417b6b4f0b2b98ba9b2664e3560 Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 4 Dec 2015 16:33:56 +0800 Subject: [PATCH 19/21] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E6=88=90=E5=91=98?= =?UTF-8?q?=E6=8F=90=E4=BA=A4=E2=80=9C=E4=BF=AE=E6=94=B9=E8=A7=92=E8=89=B2?= =?UTF-8?q?=E2=80=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/courses_controller.rb | 2 +- app/views/courses/member.html.erb | 6 +++++- app/views/courses/settings.html.erb | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index 5da9db395..0c61c449e 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -374,7 +374,7 @@ class CoursesController < ApplicationController def settings if User.current.allowed_to?(:as_teacher,@course) - + @select_tab = params[:tab] @issue_custom_fields = IssueCustomField.sorted.all @issue_category ||= IssueCategory.new @member ||= @course.members.new diff --git a/app/views/courses/member.html.erb b/app/views/courses/member.html.erb index e906bf778..3aa7d4b57 100644 --- a/app/views/courses/member.html.erb +++ b/app/views/courses/member.html.erb @@ -1,6 +1,10 @@

        <%= @subPage_title%>

        - 修改角色 + <% if User.current.allowed_to?(:as_teacher,@course) %> + + <%=link_to "修改角色", :controller => 'courses', :action => 'settings', :id => @course.id, :tab=>'member' %> + + <% end %>
        <% if @subPage_title == l(:label_student_list)%> <%= render :partial => 'course_student', :locals => {:members => @members} %> diff --git a/app/views/courses/settings.html.erb b/app/views/courses/settings.html.erb index 8d3454776..3456634d5 100644 --- a/app/views/courses/settings.html.erb +++ b/app/views/courses/settings.html.erb @@ -3,7 +3,7 @@