From fea4f79dc852649ef0ef4f58cad2d80881db9c04 Mon Sep 17 00:00:00 2001 From: cxt Date: Fri, 22 Jan 2016 09:47:18 +0800 Subject: [PATCH 1/6] =?UTF-8?q?=E7=BB=84=E7=BB=87=E5=B8=96=E5=AD=90?= =?UTF-8?q?=E6=A0=8F=E7=9B=AE=E7=9A=84=E9=80=9A=E7=9F=A5=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E7=82=B9=E8=B5=9Etip?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/organizations/_org_subfield_news.html.erb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/organizations/_org_subfield_news.html.erb b/app/views/organizations/_org_subfield_news.html.erb index 074d15a42..fb18c0f7f 100644 --- a/app/views/organizations/_org_subfield_news.html.erb +++ b/app/views/organizations/_org_subfield_news.html.erb @@ -51,7 +51,7 @@ <%= count>0 ? "(#{count})" : "" %> <% if activity.author == User.current %> - + <% else %> <%=render :partial=> "praise_tread/praise", :locals => {:activity=>activity, :user_activity_id=>user_activity_id,:type=>"activity"}%> <% end %> @@ -92,7 +92,7 @@ <%= format_time(comment.created_on) %> <% if comment.author == User.current %> - + <% else %> <%=render :partial=> "praise_tread/praise", :locals => {:activity=>comment, :user_activity_id=>comment.id,:type=>"reply"}%> <% end %> From 6789693fc761f0db4d9509924e8d38b8cc9cf5a1 Mon Sep 17 00:00:00 2001 From: cxt Date: Fri, 22 Jan 2016 10:17:00 +0800 Subject: [PATCH 2/6] =?UTF-8?q?=E5=B7=B2=E8=AF=84=E5=88=86=E4=BD=9C?= =?UTF-8?q?=E5=93=81=E8=B6=85=E8=BF=875=E4=B8=AA=E6=97=B6=EF=BC=8C?= =?UTF-8?q?=E4=BD=9C=E4=B8=9A=E4=BC=98=E7=A7=80=E4=BD=9C=E5=93=81=E6=8E=92?= =?UTF-8?q?=E8=A1=8C=E6=98=BE=E7=A4=BA=E2=80=9C=E6=9B=B4=E5=A4=9A=E2=80=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/organizations/_org_course_homework.html.erb | 4 +++- app/views/users/_course_homework.html.erb | 5 +++-- app/views/users/_user_homework_detail.html.erb | 4 +++- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/app/views/organizations/_org_course_homework.html.erb b/app/views/organizations/_org_course_homework.html.erb index ffee90ede..88170dc2d 100644 --- a/app/views/organizations/_org_course_homework.html.erb +++ b/app/views/organizations/_org_course_homework.html.erb @@ -155,7 +155,9 @@ <% break %> <% end %> <% end %> - <%= link_to "更多>>", student_work_index_path(:homework => activity.id),:class=>'linkGrey2 fl ml50',:style=>'margin-top:60px;'%> + <% if student_works.count > 5 %> + <%= link_to "更多>>", student_work_index_path(:homework => activity.id),:class=>'linkGrey2 fl ml50',:style=>'margin-top:60px;'%> + <% end %>
<% end %> diff --git a/app/views/users/_course_homework.html.erb b/app/views/users/_course_homework.html.erb index 651a284e4..e6ed73036 100644 --- a/app/views/users/_course_homework.html.erb +++ b/app/views/users/_course_homework.html.erb @@ -134,7 +134,6 @@ <% if activity.student_works.count != 0 %> <% sw_id = "("+activity.student_works.map{|sw| sw.id}.join(",")+")" %> <% student_work_scores = StudentWorksScore.find_by_sql("select max(created_at) as created_at, student_work_id, user_id from student_works_scores where student_work_id in #{sw_id} group by student_work_id order by max(created_at) desc") %> - <%# student_work_scores = StudentWorksScore.where("student_work_id in #{sw_id}").reorder("created_at desc") %> <% unless student_work_scores.empty? %> <% last_score = student_work_scores.first %>
@@ -155,7 +154,9 @@ <% break %> <% end %> <% end %> - <%= link_to "更多>>", student_work_index_path(:homework => activity.id),:class=>'linkGrey2 fl ml50',:style=>'margin-top:60px;'%> + <% if student_works.count > 5 %> + <%= link_to "更多>>", student_work_index_path(:homework => activity.id),:class=>'linkGrey2 fl ml50',:style=>'margin-top:60px;'%> + <% end %>
<% end %> diff --git a/app/views/users/_user_homework_detail.html.erb b/app/views/users/_user_homework_detail.html.erb index b3e14d174..bf24ea3b2 100644 --- a/app/views/users/_user_homework_detail.html.erb +++ b/app/views/users/_user_homework_detail.html.erb @@ -156,7 +156,9 @@ <% break %> <% end %> <% end %> - <%= link_to "更多>>", student_work_index_path(:homework => homework_common.id),:class=>'linkGrey2 fl ml50',:style=>'margin-top:60px;'%> + <% if student_works > 5%> + <%= link_to "更多>>", student_work_index_path(:homework => homework_common.id),:class=>'linkGrey2 fl ml50',:style=>'margin-top:60px;'%> + <% end %>
<% end %> From f7be78efc7a2ab14725404507a5668380fdc8522 Mon Sep 17 00:00:00 2001 From: cxt Date: Fri, 22 Jan 2016 11:10:35 +0800 Subject: [PATCH 3/6] =?UTF-8?q?=E5=85=B3=E8=81=94=E9=A1=B9=E7=9B=AE?= =?UTF-8?q?=E7=9A=84=E6=9B=B4=E6=96=B0=E6=97=B6=E9=97=B4=E5=8C=85=E5=90=AB?= =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E7=9A=84=E6=8F=90=E4=BA=A4=E6=97=B6=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../_org_course_homework.html.erb | 3 ++- app/views/users/_course_homework.html.erb | 3 ++- .../users/_user_homework_detail.html.erb | 5 ++-- db/migrate/20160122023014_add_commit_time.rb | 27 +++++++++++++++++++ 4 files changed, 34 insertions(+), 4 deletions(-) create mode 100644 db/migrate/20160122023014_add_commit_time.rb diff --git a/app/views/organizations/_org_course_homework.html.erb b/app/views/organizations/_org_course_homework.html.erb index 88170dc2d..3446a86d4 100644 --- a/app/views/organizations/_org_course_homework.html.erb +++ b/app/views/organizations/_org_course_homework.html.erb @@ -190,10 +190,11 @@ <% else %> <%= image_tag(url_to_avatar(project),:width=>"40",:height => "40",:class => "borderRadius",:id=>"project_img_"+project.id.to_s+"_"+activity.id.to_s,:alt =>"项目头像") %> <% end %> + <% com_time = project.project_score.commit_time %> <% time=project.updated_on %> <% time=ForgeActivity.where("project_id=?",project.id).last.updated_at if ForgeActivity.where("project_id=?",project.id).last %>

<%=(User.find project.user_id).show_name %>(组长)

-

<%=time_from_now time %>  <%= project.project_score.changeset_num %>提交

+

<%=time_from_now !com_time.nil? && format_time(com_time) > format_timetime ? com_time : time %>  <%= project.project_score.changeset_num %>提交

项目名称:<%=project.name %>
创建者:<%=(User.find project.user_id).show_name %>(组长)
diff --git a/app/views/users/_course_homework.html.erb b/app/views/users/_course_homework.html.erb index e6ed73036..5be1334c3 100644 --- a/app/views/users/_course_homework.html.erb +++ b/app/views/users/_course_homework.html.erb @@ -189,10 +189,11 @@ <% else %> <%= image_tag(url_to_avatar(project),:width=>"40",:height => "40",:class => "borderRadius",:id=>"project_img_"+project.id.to_s+"_"+activity.id.to_s,:alt =>"项目头像") %> <% end %> + <% com_time = project.project_score.commit_time %> <% time=project.updated_on %> <% time=ForgeActivity.where("project_id=?",project.id).last.updated_at if ForgeActivity.where("project_id=?",project.id).last %>

<%=(User.find project.user_id).show_name %>(组长)

-

<%=time_from_now time %>  <%= project.project_score.changeset_num %>提交

+

<%=time_from_now !com_time.nil? && format_time(com_time) > format_timetime ? com_time : time %>  <%= project.project_score.changeset_num %>提交

项目名称:<%=project.name %>
创建者:<%=(User.find project.user_id).show_name %>(组长)
diff --git a/app/views/users/_user_homework_detail.html.erb b/app/views/users/_user_homework_detail.html.erb index bf24ea3b2..04c8b8f0a 100644 --- a/app/views/users/_user_homework_detail.html.erb +++ b/app/views/users/_user_homework_detail.html.erb @@ -156,7 +156,7 @@ <% break %> <% end %> <% end %> - <% if student_works > 5%> + <% if student_works.count > 5%> <%= link_to "更多>>", student_work_index_path(:homework => homework_common.id),:class=>'linkGrey2 fl ml50',:style=>'margin-top:60px;'%> <% end %>
@@ -191,10 +191,11 @@ <% else %> <%= image_tag(url_to_avatar(project),:width=>"40",:height => "40",:class => "borderRadius",:id=>"project_img_"+project.id.to_s+"_"+homework_common.id.to_s,:alt =>"项目头像") %> <% end %> + <% com_time = project.project_score.commit_time %> <% time=project.updated_on %> <% time=ForgeActivity.where("project_id=?",project.id).last.updated_at if ForgeActivity.where("project_id=?",project.id).last %>

<%=(User.find project.user_id).show_name %>(组长)

-

<%=time_from_now time %>  <%= project.project_score.changeset_num %>提交

+

<%=time_from_now !com_time.nil? && format_time(com_time) > format_timetime ? com_time : time %>  <%= project.project_score.changeset_num %>提交

项目名称:<%=project.name %>
创建者:<%=(User.find project.user_id).show_name %>(组长)
diff --git a/db/migrate/20160122023014_add_commit_time.rb b/db/migrate/20160122023014_add_commit_time.rb new file mode 100644 index 000000000..d9b860073 --- /dev/null +++ b/db/migrate/20160122023014_add_commit_time.rb @@ -0,0 +1,27 @@ +class AddCommitTime < ActiveRecord::Migration + def up + add_column :project_scores, :commit_time, :datetime, :default => nil + count = ProjectScore.all.count / 30 + 2 + transaction do + for i in 1 ... count do i + ProjectScore.page(i).per(30).each do |ps| + unless ps.project.nil? + unless ps.project.gpid.nil? + g = Gitlab.client + begin + changesets = g.commits(ps.project.gpid) + ps.commit_time = changesets[0].created_at + ps.save + rescue + logger.error("The project's rep is not exit!") + end + end + end + end + end + end + end + + def down + end +end From 338c22484622b7c61ee406ba68babd6b19877ead Mon Sep 17 00:00:00 2001 From: cxt Date: Fri, 22 Jan 2016 15:17:11 +0800 Subject: [PATCH 4/6] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E7=9A=84=E7=BB=93=E6=9D=9F=E5=AD=A6=E6=9C=9F?= =?UTF-8?q?=E5=8F=AF=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/courses_helper.rb | 2 +- app/services/courses_service.rb | 2 ++ app/views/courses/settings.html.erb | 15 +++++++-------- public/javascripts/course.js | 2 +- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/app/helpers/courses_helper.rb b/app/helpers/courses_helper.rb index 097a3c1a4..b062351c1 100644 --- a/app/helpers/courses_helper.rb +++ b/app/helpers/courses_helper.rb @@ -509,7 +509,7 @@ module CoursesHelper type = [] month = Time.now.month now_year = year.nil? ? Time.now.year : (Time.now.year <= year ? Time.now.year : year) - year = month < 3 ? now_year - 1 : now_year + year = month < 3 && now_year >=Time.now.year ? now_year - 1 : now_year for i in (year..year + 10) option = [] option << i diff --git a/app/services/courses_service.rb b/app/services/courses_service.rb index 6f2819f53..ef0c2eb16 100644 --- a/app/services/courses_service.rb +++ b/app/services/courses_service.rb @@ -254,6 +254,8 @@ class CoursesService #course.safe_attributes = params[:course] course.time = params[:time] course.term = params[:term] + course.end_time = params[:end_time] + course.end_term = params[:end_term] course.class_period = params[:class_period].to_i params[:course][:is_public] ? course.is_public = 1 : course.is_public = 0 params[:course][:open_student] ? course.open_student = 1 : course.open_student = 0 diff --git a/app/views/courses/settings.html.erb b/app/views/courses/settings.html.erb index f62951236..984fb4212 100644 --- a/app/views/courses/settings.html.erb +++ b/app/views/courses/settings.html.erb @@ -46,14 +46,15 @@
  • - <%= select_tag :time,options_for_select(course_time_option(@course.time),@course.time), {:id=>"time_selected"} %> - <%= select_tag :term,options_for_select(course_term_option,@course.term || cur_course_term),{:id=>"term_selected"} %> + <%= select_tag :time,options_for_select(course_time_option(@course.time),@course.time), {:id=>"time"} %> + <%= select_tag :term,options_for_select(course_term_option,@course.term || cur_course_term),{:id=>"term"} %>
  • - <%= select_tag :end_time,options_for_select(course_time_option(@course.end_time),@course.end_time), {:id=>"end_time_selected"} %> - <%= select_tag :end_term,options_for_select(course_term_option,@course.end_term || cur_course_term),{:id=>"end_term_selected"} %> + <%= select_tag :end_time,options_for_select(course_time_option(@course.end_time),@course.end_time), {:id=>"end_time"} %> + <%= select_tag :end_term,options_for_select(course_term_option,@course.end_term || cur_course_term),{:id=>"end_term"} %> +
  • @@ -138,8 +139,6 @@ $('#ajax-modal').parent().css("top","").css("left","").css("border","3px solid #269ac9"); $('#ajax-modal').parent().addClass("anonymos"); } - $("#time_selected").click(select); - $("#term_selected").click(select); - $("#end_time_selected").click(select); - $("#end_term_selected").click(select); + $("#time").click(select); + $("#term").click(select); diff --git a/public/javascripts/course.js b/public/javascripts/course.js index 6c2f0af71..fff30dec5 100644 --- a/public/javascripts/course.js +++ b/public/javascripts/course.js @@ -193,7 +193,7 @@ function submit_new_course() function submit_edit_course(id) { - if(regex_course_name()&®ex_course_class_period()&®ex_course_password()) + if(regex_course_name()&®ex_course_class_period()&®ex_time_term()&®ex_course_password()) { $("#edit_course_"+id).submit(); } From e09f795171ec41469befaf2cb6df56fc448a265d Mon Sep 17 00:00:00 2001 From: cxt Date: Fri, 22 Jan 2016 17:05:58 +0800 Subject: [PATCH 5/6] =?UTF-8?q?=E9=99=84=E4=BB=B6=E7=9A=84=E6=98=BE?= =?UTF-8?q?=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/attachments/_project_file_links.html.erb | 2 +- app/views/messages/_course_show.html.erb | 4 ++-- app/views/messages/_org_subfield_show.html.erb | 4 ++-- app/views/messages/_project_show.html.erb | 4 ++-- app/views/news/_course_show.html.erb | 4 ++-- app/views/news/_project_show.html.erb | 4 ++-- app/views/org_document_comments/show.html.erb | 5 +++-- app/views/organizations/_show_org_document.html.erb | 4 ++-- .../student_work/_work_attachments_status.html.erb | 12 ++++++++++-- app/views/student_work/index.html.erb | 2 +- public/stylesheets/courses.css | 1 + public/stylesheets/public.css | 1 + 12 files changed, 29 insertions(+), 18 deletions(-) diff --git a/app/views/attachments/_project_file_links.html.erb b/app/views/attachments/_project_file_links.html.erb index 3b76689f5..0f7e8a012 100644 --- a/app/views/attachments/_project_file_links.html.erb +++ b/app/views/attachments/_project_file_links.html.erb @@ -37,7 +37,7 @@ <% if options[:length] %> <%= link_to_short_attachment attachment, :class => ' link_file_board', :download => true,:length => options[:length] -%> <% else %> - <%= link_to_short_attachment attachment, :class => ' link_file_board', :download => true -%> + <%= link_to_short_attachment attachment, :length=> 58,:class => 'hidden link_file_a fl newsBlue mw400', :download => true -%> <% end %> <%if is_float%> diff --git a/app/views/messages/_course_show.html.erb b/app/views/messages/_course_show.html.erb index c3278a209..c760e686d 100644 --- a/app/views/messages/_course_show.html.erb +++ b/app/views/messages/_course_show.html.erb @@ -84,8 +84,8 @@ <%= @topic.content.html_safe%>
  • -
    - <%= link_to_attachments_course @topic, :author => false %> +
    + <%= render :partial=>"attachments/activity_attach", :locals=>{:activity => @topic} %>
    diff --git a/app/views/messages/_org_subfield_show.html.erb b/app/views/messages/_org_subfield_show.html.erb index 304694b39..6d12fe960 100644 --- a/app/views/messages/_org_subfield_show.html.erb +++ b/app/views/messages/_org_subfield_show.html.erb @@ -113,8 +113,8 @@ <%= @topic.content.html_safe%>
    -
    - <%= link_to_attachments_course @topic, :author => false %> +
    + <%= render :partial=>"attachments/activity_attach", :locals=>{:activity => @topic} %>
    diff --git a/app/views/messages/_project_show.html.erb b/app/views/messages/_project_show.html.erb index e5aba7c02..c98f2983e 100644 --- a/app/views/messages/_project_show.html.erb +++ b/app/views/messages/_project_show.html.erb @@ -139,8 +139,8 @@ <%= @topic.content.html_safe%>
    -
    - <%= link_to_attachments_course @topic, :author => false %> +
    + <%= render :partial=>"attachments/activity_attach", :locals=>{:activity => @topic} %>
    diff --git a/app/views/news/_course_show.html.erb b/app/views/news/_course_show.html.erb index 07aaef26d..767c11553 100644 --- a/app/views/news/_course_show.html.erb +++ b/app/views/news/_course_show.html.erb @@ -89,8 +89,8 @@ <%= @news.description.html_safe%>
    -
    - <%= link_to_attachments_course @news, :author => false %> +
    + <%= render :partial=>"attachments/activity_attach", :locals=>{:activity => @news} %>
    diff --git a/app/views/news/_project_show.html.erb b/app/views/news/_project_show.html.erb index 26ff807db..880bd0885 100644 --- a/app/views/news/_project_show.html.erb +++ b/app/views/news/_project_show.html.erb @@ -89,8 +89,8 @@ <%= @news.description.html_safe%>
    -
    - <%= link_to_attachments_course @news, :author => false %> +
    + <%= render :partial=>"attachments/activity_attach", :locals=>{:activity => @news} %>
    diff --git a/app/views/org_document_comments/show.html.erb b/app/views/org_document_comments/show.html.erb index 26d04924a..405631369 100644 --- a/app/views/org_document_comments/show.html.erb +++ b/app/views/org_document_comments/show.html.erb @@ -29,8 +29,9 @@ <%= @document.content.html_safe %> <% end %> -
    - <%= link_to_attachments_course @document, :author => false %> +
    + <%= render :partial=>"attachments/activity_attach", :locals=>{:activity => @document} %> + <%#= link_to_attachments_course @document, :author => false %>