From 3565b9da881851bd2bccc28a5d7a8a1c21387987 Mon Sep 17 00:00:00 2001 From: nwb Date: Fri, 27 Jun 2014 10:50:23 +0800 Subject: [PATCH 1/8] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E7=95=8C=E9=9D=A2=E5=85=B3=E9=97=AD=E3=80=81?= =?UTF-8?q?=E9=87=8D=E5=90=AF=E8=AF=BE=E7=A8=8B=EF=BC=8C=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E5=88=B7=E6=96=B0=E4=B8=8D=E5=8F=8A=E6=97=B6=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/courses_controller.rb | 25 ++++++++++++++ app/views/courses/finishcourse.js.erb | 14 +++++--- .../_course_list_have_entity_ex.html.erb | 22 +++++++++++++ app/views/users/_my_course.html.erb | 2 +- app/views/users/_my_course_ex.html.erb | 33 +++++++++++++++++++ 5 files changed, 90 insertions(+), 6 deletions(-) create mode 100644 app/views/users/_course_list_have_entity_ex.html.erb create mode 100644 app/views/users/_my_course_ex.html.erb diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index c0d7c1e25..e0daa44f4 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -556,22 +556,47 @@ class CoursesController < ApplicationController end end + def get_courses + @user = User.current + membership = @user.coursememberships.all + membership.sort! {|older, newer| newer.created_on <=> older.created_on } + @memberships = [] + membership.collect { |e| + @memberships.push(e) + } + @memberships_doing = [] + @memberships_done = [] + now_time = Time.now.year + @memberships.map { |e| + end_time = e.course.get_time.year + isDone = course_endTime_timeout?(e.course) + if isDone + @memberships_done.push e + else + @memberships_doing.push e + end + } + end + def finishcourse yesterday = Date.today.prev_day.to_time @course_prefs.endup_time = yesterday @save_flag = @course_prefs.save + get_courses respond_to do |format| format.js end end + def restartcourse day = Time.parse("3000-01-01") @course_prefs.endup_time = day @save_flag = @course_prefs.save + get_courses respond_to do |format| format.js { diff --git a/app/views/courses/finishcourse.js.erb b/app/views/courses/finishcourse.js.erb index 025edb056..e67426953 100644 --- a/app/views/courses/finishcourse.js.erb +++ b/app/views/courses/finishcourse.js.erb @@ -1,8 +1,12 @@ <% if @save_flag %> - <% if Rails.env.development? %> - console.debug('课程修改成功:结束时间改为<%=Course.find_by_extra(@course.extra).try(:endup_time)%>'); - <% end %> - $('#finish_course_<%=@course.id%>').replaceWith("<%= j(render partial: 'courses/set_course_time', :locals => {:course => @course} )%>") +<% if Rails.env.development? %> +console.debug('课程修改成功:结束时间改为<%=Course.find_by_extra(@course.extra).try(:endup_time)%>'); +<% end %> +$('#content-title-top-div').html("<%= j(render partial: 'users/my_course_ex', :locals => {:memberships => @memberships,:user=>@user, +:memberships_doing=>@memberships_doing,:memberships_done=>@memberships_done} )%>") +//$('#finish_course_ <%=@course.id%>').replaceWith("<%= j(render partial: 'courses/set_course_time', :locals => {:course => @course} )%>") <% else %> - alert('权限不足,设置失败,请在论坛提交问题,等待管理员处理。'); +alert('权限不足,设置失败,请在论坛提交问题,等待管理员处理。'); <% end %> + + diff --git a/app/views/users/_course_list_have_entity_ex.html.erb b/app/views/users/_course_list_have_entity_ex.html.erb new file mode 100644 index 000000000..2307f3a2b --- /dev/null +++ b/app/views/users/_course_list_have_entity_ex.html.erb @@ -0,0 +1,22 @@ + + diff --git a/app/views/users/_my_course.html.erb b/app/views/users/_my_course.html.erb index 85f455b19..c6fd032cb 100644 --- a/app/views/users/_my_course.html.erb +++ b/app/views/users/_my_course.html.erb @@ -1,4 +1,4 @@ -
+
<% if @memberships.empty? %> <% if @user != User.current %>

diff --git a/app/views/users/_my_course_ex.html.erb b/app/views/users/_my_course_ex.html.erb new file mode 100644 index 000000000..839b28633 --- /dev/null +++ b/app/views/users/_my_course_ex.html.erb @@ -0,0 +1,33 @@ +<% if memberships.empty? %> + <% if user != User.current %> +

+ <%= l(:label_project_course_un) %> +

+ <% else %> +

+ + <%= l(:label_project_course_unadd) %><%= link_to "#{l(:label_course_new)}", {:controller => 'courses', :action => 'new'}, :class => 'icon icon-add' %> +

+ <% end %> +<% else %> + <%= render partial: 'users/course_list_have_entity_ex',:locals => {:user => user,:memberships_doing=>memberships_doing,:memberships_done=>memberships_done} %> +<% end %> + + \ No newline at end of file From bc587f3e7daf1fad7fd8d5f1a0f95ff3dfacca93 Mon Sep 17 00:00:00 2001 From: z9hang Date: Fri, 27 Jun 2014 11:15:10 +0800 Subject: [PATCH 2/8] =?UTF-8?q?=E5=B1=8F=E8=94=BD=E4=B8=AA=E4=BA=BA?= =?UTF-8?q?=E5=88=86=E6=95=B0=E5=AE=9E=E6=97=B6=E5=88=B7=E6=96=B0=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=20=E4=BF=AE=E5=A4=8D=E4=B8=AA=E4=BA=BA=E5=88=86?= =?UTF-8?q?=E6=95=B0=E8=AE=A1=E5=88=86=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/user_score.rb | 6 +++--- app/views/layouts/base_users.html.erb | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/models/user_score.rb b/app/models/user_score.rb index 1635d612f..6371fc12d 100644 --- a/app/models/user_score.rb +++ b/app/models/user_score.rb @@ -53,7 +53,7 @@ class UserScore < ActiveRecord::Base user_score = current_user.user_score_attr user_grade = nil #项目个人得分 project = obj.project - unless project.nil? && project.project_type == 0 + unless project.nil? user_grade = UserGrade.find_by_user_id_and_project_id(current_user.id, project.id) if user_grade.nil? user_grade = UserGrade.create(:user_id => current_user.id,:project_id => project.id) @@ -178,7 +178,7 @@ class UserScore < ActiveRecord::Base current_user_grade = nil #项目个人得分 target_user_grade = nil project = obj.project - unless project.nil? && project.project_type == 0 + unless project.nil? current_user_grade = UserGrade.find_by_user_id_and_project_id(current_user.id, project.id) target_user_grade = UserGrade.find_by_user_id_and_project_id(target_user.id, project.id) if current_user_grade.nil? @@ -285,7 +285,7 @@ class UserScore < ActiveRecord::Base user_score = current_user.try(:user_score_attr) user_grade = nil #项目个人得分 project = obj.project - unless project.nil? && project.project_type == 0 + unless project.nil? user_grade = UserGrade.find_by_user_id_and_project_id(current_user.id, project.id) if user_grade.nil? user_grade = UserGrade.create(:user_id => current_user.id,:project_id => project.id) diff --git a/app/views/layouts/base_users.html.erb b/app/views/layouts/base_users.html.erb index 5579dfb5b..0f7c273f1 100644 --- a/app/views/layouts/base_users.html.erb +++ b/app/views/layouts/base_users.html.erb @@ -35,7 +35,7 @@ - +
From beeab518e80779b667b0cd09e1b0d1f5d03c5222 Mon Sep 17 00:00:00 2001 From: nwb Date: Fri, 27 Jun 2014 11:24:48 +0800 Subject: [PATCH 3/8] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E5=8A=A8=E6=80=81?= =?UTF-8?q?=E4=B8=AD=E7=95=99=E8=A8=80=E9=93=BE=E6=8E=A5BUG=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/journals_for_message.rb | 10 +++++++--- app/views/courses/show.html.erb | 1 + 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/app/models/journals_for_message.rb b/app/models/journals_for_message.rb index 512a6d8bf..58880919e 100644 --- a/app/models/journals_for_message.rb +++ b/app/models/journals_for_message.rb @@ -33,9 +33,13 @@ class JournalsForMessage < ActiveRecord::Base :description => Proc.new{|o| o.notes }, :type => Proc.new {|o| o.jour_type }, :url => Proc.new {|o| - (o.jour.kind_of? Project) ? {:controller => 'projects', :action => 'feedback', :id => o.jour, :r => o.id, :anchor => "word_li_#{o.id}"} : {} - }#{:controller => 'documents', :action => 'show', :id => o.id}} - acts_as_activity_provider :author_key => :user_id, + if o.jour.kind_of? Project + {:controller => 'projects', :action => 'feedback', :id => o.jour, :r => o.id, :anchor => "word_li_#{o.id}"} + elsif o.jour.kind_of? Course + {:controller => 'courses', :action => 'feedback', :id => o.jour, :r => o.id, :anchor => "word_li_#{o.id}"} + end + } + acts_as_activity_provider :author_key => :user_id, :timestamp => "#{self.table_name}.updated_on", :find_options => {:include => :project } diff --git a/app/views/courses/show.html.erb b/app/views/courses/show.html.erb index a40ace38d..5a440aff3 100644 --- a/app/views/courses/show.html.erb +++ b/app/views/courses/show.html.erb @@ -26,6 +26,7 @@ <%= l(:label_new_activity) %> + <%= link_to "#{eventToLanguageCourse(e.event_type, @course)}: "<< format_activity_title(e.event_title), (e.event_type.eql?("attachment")&&e.container.kind_of?(Course)) ? course_files_path(e.container) : e.event_url %> From ad97066a450c1f5183f177c8425608d2edeb675a Mon Sep 17 00:00:00 2001 From: nwb Date: Fri, 27 Jun 2014 11:42:45 +0800 Subject: [PATCH 4/8] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E5=90=8D=E7=A7=B0?= =?UTF-8?q?=E6=9C=89=E6=95=88=E6=80=A7=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/course.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/models/course.rb b/app/models/course.rb index 2dfb6ae44..51b118679 100644 --- a/app/models/course.rb +++ b/app/models/course.rb @@ -33,8 +33,9 @@ class Course < ActiveRecord::Base acts_as_attachable :view_permission => :view_files, :delete_permission => :manage_files - validates_presence_of :password, :term + validates_presence_of :password, :term,:name validates_format_of :class_period, :with =>/^[1-9]\d*$/ + validates_format_of :name,:with =>/^[a-zA-Z0-9_\u4e00-\u9fa5]+$/ after_save :create_board_sync before_destroy :delete_all_members From 1a4ee62853de61f7aca2c5035a96115a9c92f613 Mon Sep 17 00:00:00 2001 From: nwb Date: Fri, 27 Jun 2014 14:17:21 +0800 Subject: [PATCH 5/8] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E8=AF=BE=E7=A8=8B?= =?UTF-8?q?=E9=94=99=E8=AF=AF=E4=BF=A1=E6=81=AF=E6=98=BE=E7=A4=BA2?= =?UTF-8?q?=E9=81=8D=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/courses/_course_form.html.erb | 1 - 1 file changed, 1 deletion(-) diff --git a/app/views/courses/_course_form.html.erb b/app/views/courses/_course_form.html.erb index d223bbad6..67f3c5a8d 100644 --- a/app/views/courses/_course_form.html.erb +++ b/app/views/courses/_course_form.html.erb @@ -18,7 +18,6 @@ <% object = [] %> <% object << 'course' %> -<% object << 'course' %> <%= error_messages_for object %> From 99c9f81aeacfab4e556f42738becd9215242f5fa Mon Sep 17 00:00:00 2001 From: nwb Date: Fri, 27 Jun 2014 15:26:42 +0800 Subject: [PATCH 6/8] =?UTF-8?q?BUG=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/bids_controller.rb | 1 + app/models/attachment.rb | 2 +- app/views/courses/new_homework.html.erb | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/controllers/bids_controller.rb b/app/controllers/bids_controller.rb index 87879f242..a90ca1d12 100644 --- a/app/controllers/bids_controller.rb +++ b/app/controllers/bids_controller.rb @@ -805,6 +805,7 @@ class BidsController < ApplicationController @homework = @bid @course = Course.find_by_id(params[:course_id]) @course_id = @course.id + render file: 'courses/new_homework', layout: 'base_courses' end end diff --git a/app/models/attachment.rb b/app/models/attachment.rb index fe3ff841c..94f8f7c95 100644 --- a/app/models/attachment.rb +++ b/app/models/attachment.rb @@ -129,7 +129,7 @@ class Attachment < ActiveRecord::Base nil end - def filename=(arg) + def filename=(arg) write_attribute :filename, sanitize_filename(arg.to_s) filename end diff --git a/app/views/courses/new_homework.html.erb b/app/views/courses/new_homework.html.erb index e1fd553b0..ec25cef0f 100644 --- a/app/views/courses/new_homework.html.erb +++ b/app/views/courses/new_homework.html.erb @@ -1,6 +1,6 @@

<%=l(:label_course_new_homework)%>

-<%= labelled_form_for @homework, :url => {:controller => 'bids', :action => 'create_homework'} do |f| %> +<%= labelled_form_for @homework, :url => {:controller => 'bids', :action => 'create_homework',:course_id=>@course.id} do |f| %>
<%= render :partial => 'homework_form', :locals => { :f => f } %> <%= submit_tag l(:button_create), :class => "enterprise" %> From 917288c84c85d713ef83ec64c390bb2100888f30 Mon Sep 17 00:00:00 2001 From: nwb Date: Fri, 27 Jun 2014 15:58:41 +0800 Subject: [PATCH 7/8] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E8=AF=BE=E7=A8=8B?= =?UTF-8?q?=E8=AE=A8=E8=AE=BA=E5=8C=BA=E3=80=81=E8=AF=BE=E7=A8=8B=E9=80=9A?= =?UTF-8?q?=E7=9F=A5=E7=AD=89=E5=88=9B=E5=BB=BA=E6=97=B6BUG=E4=BF=AE?= =?UTF-8?q?=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/messages_controller.rb | 3 +++ app/controllers/news_controller.rb | 2 +- app/views/messages/new.html.erb | 6 +++++- app/views/news/_form.html.erb | 2 +- app/views/news/new.html.erb | 20 ++++++++++++++------ 5 files changed, 24 insertions(+), 9 deletions(-) diff --git a/app/controllers/messages_controller.rb b/app/controllers/messages_controller.rb index c35edfa1f..2a408788e 100644 --- a/app/controllers/messages_controller.rb +++ b/app/controllers/messages_controller.rb @@ -68,6 +68,9 @@ class MessagesController < ApplicationController call_hook(:controller_messages_new_after_save, { :params => params, :message => @message}) render_attachment_warning_if_needed(@message) redirect_to board_message_path(@board, @message) + else + layout_file = @project ? 'base_projects' : 'base_courses' + render :action => 'new', :layout => layout_file end end end diff --git a/app/controllers/news_controller.rb b/app/controllers/news_controller.rb index f91bc4011..8bce84f90 100644 --- a/app/controllers/news_controller.rb +++ b/app/controllers/news_controller.rb @@ -116,7 +116,7 @@ class NewsController < ApplicationController flash[:notice] = l(:notice_successful_create) redirect_to project_news_index_path(@project) else - layout_file = (@project.project_type == 1) ? 'base_courses' : 'base_projects' + layout_file = @project ? 'base_projects' : 'base_courses' render :action => 'new', :layout => layout_file end elsif @course diff --git a/app/views/messages/new.html.erb b/app/views/messages/new.html.erb index f02af1daa..202634238 100644 --- a/app/views/messages/new.html.erb +++ b/app/views/messages/new.html.erb @@ -1,4 +1,8 @@ -

<%= link_to h(@board.name), :controller => 'boards', :action => 'show', :project_id => @project, :id => @board %> » <%= l(:label_message_new) %>

+<% if @project %> +

<%= link_to h(@board.name), :controller => 'boards', :action => 'show', :project_id => @project, :id => @board %> » <%= l(:label_message_new) %>

+<% elsif @course %> +

<%= link_to h(@board.name), :controller => 'boards', :action => 'show', :course_id => @course, :id => @board %> » <%= l(:label_message_new) %>

+<% end %> <%= form_for @message, :url => {:action => 'new'}, :html => {:multipart => true, :id => 'message-form'} do |f| %> <%= render :partial => 'form', :locals => {:f => f} %> diff --git a/app/views/news/_form.html.erb b/app/views/news/_form.html.erb index bfdfeaa37..0601ee25b 100644 --- a/app/views/news/_form.html.erb +++ b/app/views/news/_form.html.erb @@ -1,6 +1,6 @@ <%= error_messages_for @news %>
- <% str = (@project.project_type == 1) ? l(:bale_news_notice) : l(:label_news_new) %> + <% str = @project ? l(:bale_news_notice) : l(:label_news_new) %> <%= str %>
diff --git a/app/views/news/new.html.erb b/app/views/news/new.html.erb index feaf7540b..68fad17f2 100644 --- a/app/views/news/new.html.erb +++ b/app/views/news/new.html.erb @@ -1,9 +1,17 @@ - -<%= labelled_form_for @news, :url => project_news_index_path(@project), - :html => { :id => 'news-form', :multipart => true } do |f| %> - <%= render :partial => 'news/form', :locals => { :f => f } %> - <%= submit_tag l(:button_create), :class => "whiteButton m3p10 h30" %> - <%= preview_link preview_news_path(:project_id => @project), 'news-form' ,target='preview',{:class => 'whiteButton m3p10'}%> +<% if @project %> + <%= labelled_form_for @news, :url => project_news_index_path(@project), + :html => {:id => 'news-form', :multipart => true} do |f| %> + <%= render :partial => 'news/form', :locals => {:f => f} %> + <%= submit_tag l(:button_create), :class => "whiteButton m3p10 h30" %> + <%= preview_link preview_news_path(:project_id => @project), 'news-form', target='preview', {:class => 'whiteButton m3p10'} %> + <% end %> +<% elsif @course %> + <%= labelled_form_for @news, :url => course_news_index_path(@course), + :html => {:id => 'news-form', :multipart => true} do |f| %> + <%= render :partial => 'news/form', :locals => {:f => f} %> + <%= submit_tag l(:button_create), :class => "whiteButton m3p10 h30" %> + <%= preview_link preview_news_path(:course_id => @course), 'news-form', target='preview', {:class => 'whiteButton m3p10'} %> + <% end %> <% end %>
From 25a3114a5a3b9d0d9a40e2ef59f9060a7b4e3084 Mon Sep 17 00:00:00 2001 From: nwb Date: Fri, 27 Jun 2014 16:44:53 +0800 Subject: [PATCH 8/8] =?UTF-8?q?=E8=80=81=E5=B8=88=E7=9A=84=E5=AD=A6?= =?UTF-8?q?=E7=94=9F=E5=88=97=E8=A1=A8=E6=98=BE=E7=A4=BA=E4=B8=BA=E7=9C=9F?= =?UTF-8?q?=E5=AE=9E=E5=A7=93=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/courses/_member_list.html.erb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/views/courses/_member_list.html.erb b/app/views/courses/_member_list.html.erb index e356c22e3..a8a9e8085 100644 --- a/app/views/courses/_member_list.html.erb +++ b/app/views/courses/_member_list.html.erb @@ -6,7 +6,11 @@ <%= content_tag "p", "#{format_date(member.created_on)}#{l(:label_member_since)}", :class => "float_right member_since" %> <% end %> <%= member.user.nil? ? '' : (image_tag(url_to_avatar(member.user), :class => 'avatar')) %> - <%= content_tag "div", link_to(member.user.name, user_path(member.user)), :class => "nomargin avatar_name" %> + <% if @canShowCode %> + <%= content_tag "div", link_to(member.user.show_name, user_path(member.user)), :class => "nomargin avatar_name" %> + <% else %> + <%= content_tag "div", link_to(member.user.name, user_path(member.user)), :class => "nomargin avatar_name" %> + <% end %> <% unless member.user.user_extensions.identity ==0 %>