From cc27fca8aa34e3235d64d2f795fbcacef1ab9145 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Fri, 27 Mar 2015 19:03:38 +0800 Subject: [PATCH 01/19] =?UTF-8?q?=E5=8A=A0=E5=85=A5=E5=BD=93=E5=89=8D?= =?UTF-8?q?=E5=88=86=E7=8F=AD=E6=8C=89=E9=92=AE=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/watchers_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/helpers/watchers_helper.rb b/app/helpers/watchers_helper.rb index 8974a52d3..7995d7e68 100644 --- a/app/helpers/watchers_helper.rb +++ b/app/helpers/watchers_helper.rb @@ -155,7 +155,7 @@ module WatchersHelper else text = l(:label_new_join_group) form_tag({:controller => "courses", :action => "join_group", :object_id => "#{group.id}"}, :remote => true, :method => 'post') do - submit_tag text, class: "group_in", style: "width: 43px;height: 21px;" + submit_tag text, class: "group_in", style: "width: 90px;height: 21px;" end end end From 72d683bdb70ff1ba66113175c23177f08b68df3a Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Fri, 27 Mar 2015 19:50:01 +0800 Subject: [PATCH 02/19] =?UTF-8?q?=E5=8A=A0=E5=85=A5=E8=AF=BE=E7=A8=8B?= =?UTF-8?q?=E4=B8=8E=E9=80=80=E5=87=BA=E8=AF=BE=E7=A8=8Bjs=E5=88=B7?= =?UTF-8?q?=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/courses_controller.rb | 6 +++--- app/helpers/courses_helper.rb | 2 +- app/views/bids/_new_homework_form.html.erb | 3 ++- app/views/courses/_set_join.js.erb | 2 +- app/views/layouts/base_courses.html.erb | 2 +- 5 files changed, 8 insertions(+), 7 deletions(-) diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index ebdb18c08..7b3130026 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -30,19 +30,19 @@ class CoursesController < ApplicationController def join if User.current.logged? cs = CoursesService.new - join = cs.join_course params,User.current + user = User.current + join = cs.join_course params,user @state = join[:state] course = join[:course] else @state = 5 #未登录 end respond_to do |format| - format.js { render :partial => 'set_join', :locals => {:user => User.current, :course => course, :object_id => params[:object_id]} } + format.js { render :partial => 'set_join', :locals => {:user => user, :course => course, :object_id => params[:object_id]} } end rescue Exception => e @state = 4 #已经加入了课程 respond_to do |format| - # format.html { redirect_to_referer_or {render :text => (watching ? 'Watcher added.' : 'Watcher removed.'), :layout => true}} format.js { render :partial => 'set_join', :locals => {:user => User.current, :course => nil, :object_id => nil} } end end diff --git a/app/helpers/courses_helper.rb b/app/helpers/courses_helper.rb index 384fcaa9b..408783934 100644 --- a/app/helpers/courses_helper.rb +++ b/app/helpers/courses_helper.rb @@ -677,7 +677,7 @@ module CoursesHelper #加入课程、退出课程按钮 def join_in_course_header(course, user, options=[]) if user.logged? - joined = user.member_of_course? course + joined = course.members.map{|member| member.user_id}.include? user.id text = joined ? ("".html_safe + l(:label_course_exit_student)) : ("".html_safe + l(:label_course_join_student)) url = joined ? join_path(:object_id => course.id) : try_join_path(:object_id => course.id) method = joined ? 'delete' : 'post' diff --git a/app/views/bids/_new_homework_form.html.erb b/app/views/bids/_new_homework_form.html.erb index 210d96891..9f3bf30c7 100644 --- a/app/views/bids/_new_homework_form.html.erb +++ b/app/views/bids/_new_homework_form.html.erb @@ -33,8 +33,9 @@

  • - + <%= render :partial => 'attachments/new_form', :locals => {:container => bid} %> +
  • <%= l(:button_create)%> diff --git a/app/views/courses/_set_join.js.erb b/app/views/courses/_set_join.js.erb index f65d6e98b..81c7b42e5 100644 --- a/app/views/courses/_set_join.js.erb +++ b/app/views/courses/_set_join.js.erb @@ -1,5 +1,5 @@ <% if object_id%> - $("#<%=object_id%>").replaceWith('<%= escape_javascript join_in_course(course, user) %>'); + $("#join_in_course_header").html("<%= escape_javascript(join_in_course_header(course, user)) %>"); <% end %> <% if @state %> <% if @state == 0 %> diff --git a/app/views/layouts/base_courses.html.erb b/app/views/layouts/base_courses.html.erb index 471902c7a..d35e31dd7 100644 --- a/app/views/layouts/base_courses.html.erb +++ b/app/views/layouts/base_courses.html.erb @@ -77,7 +77,7 @@ <%= set_course_time @course%> <%= link_to "#{l(:button_copy)}".html_safe, copy_course_course_path(@course.id), :class => "pr_join_a" %> <% else%> - <%= join_in_course_header(@course, User.current) %> +
    <%= join_in_course_header(@course, User.current) %>
    <% end%>
    From cee08d9c585e404f821c2433309820f631c42830 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Fri, 27 Mar 2015 20:05:00 +0800 Subject: [PATCH 03/19] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=8A=A0=E5=85=A5?= =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E5=BC=B9=E5=87=BA=E6=A1=86=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/courses/_set_join.js.erb | 1 + app/views/courses/new_join.js.erb | 11 ++- app/views/projects/_new_join.html.erb | 101 +++++++++++--------------- 3 files changed, 53 insertions(+), 60 deletions(-) diff --git a/app/views/courses/_set_join.js.erb b/app/views/courses/_set_join.js.erb index 81c7b42e5..0ccefdba1 100644 --- a/app/views/courses/_set_join.js.erb +++ b/app/views/courses/_set_join.js.erb @@ -4,6 +4,7 @@ <% if @state %> <% if @state == 0 %> alert("加入成功"); + hideModal("#popbox02"); <% elsif @state == 1 %> alert("密码错误"); <% elsif @state == 2 %> diff --git a/app/views/courses/new_join.js.erb b/app/views/courses/new_join.js.erb index c0a6f4a50..00245f8cb 100644 --- a/app/views/courses/new_join.js.erb +++ b/app/views/courses/new_join.js.erb @@ -1,3 +1,8 @@ -$('#ajax-modal').html('<%= escape_javascript(render :partial => 'projects/new_join', :locals => {:course => @course}) %>'); -showModal('ajax-modal', '400px'); -$('#ajax-modal').addClass('new-watcher'); +$('#ajax-modal').html('<%= escape_javascript(render :partial => 'projects/new_join', locals: { :course => @course}) %>'); +showModal('ajax-modal', '500px'); +$('#ajax-modal').css('height','100px'); +$('#ajax-modal').siblings().remove(); +$('#ajax-modal').before("" + +""); +$('#ajax-modal').parent().css("top","").css("left",""); +$('#ajax-modal').parent().addClass("anonymos"); diff --git a/app/views/projects/_new_join.html.erb b/app/views/projects/_new_join.html.erb index b1704ec32..c823f5ed0 100644 --- a/app/views/projects/_new_join.html.erb +++ b/app/views/projects/_new_join.html.erb @@ -1,62 +1,49 @@ - + + + + -

    请输入课程密码

    + + -<%= form_tag({:controller => 'courses', - :action => 'join', - :object_id => course.id}, - :remote => true, - :method => :post, - :id => 'new-watcher-form') do %> - - - - -
    - <%= text_field_tag 'course_password', nil, :style=>'width:100%'%> + +
    +
    + <%= form_tag({:controller => 'courses', + :action => 'join', + :object_id => course.id}, + :remote => true, + :method => :post, + :id => 'new_join_course') do %> + + <%= text_field_tag 'course_password', nil, :style=>'width:300px;'%> + + <% end %>
    +
    + + + -

    - <%= submit_tag l(:label_new_join), :name => nil, :class => "bid_btn", :onclick => "hideModal(this);" %> - <%= submit_tag l(:button_cancel), :name => nil, :class => "bid_btn", :onclick => "hideModal(this);", :type => 'button' %> -

    - -
    -
    -<% end %> From e7da0225641d38c2b9c637aad078212ed7ef6418 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Mon, 30 Mar 2015 10:11:11 +0800 Subject: [PATCH 04/19] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E7=95=8C=E9=9D=A2?= =?UTF-8?q?=E9=BB=98=E8=AE=A4=E5=9B=BE=E7=89=87=E8=B7=AF=E5=BE=84=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/layouts/base_courses.html.erb | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/app/views/layouts/base_courses.html.erb b/app/views/layouts/base_courses.html.erb index d35e31dd7..e787cfa54 100644 --- a/app/views/layouts/base_courses.html.erb +++ b/app/views/layouts/base_courses.html.erb @@ -62,11 +62,7 @@
    ID:<%= @course.id%> From 046536230cf2bcde4eea5d959e2f2138f0765af0 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Mon, 30 Mar 2015 10:47:23 +0800 Subject: [PATCH 05/19] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=AF=BE=E7=A8=8B?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E7=95=8C=E9=9D=A2=E3=80=81=E6=88=90=E5=91=98?= =?UTF-8?q?=E7=9A=84=E5=9F=BA=E6=9C=AC=E4=BF=A1=E6=81=AF=E4=BB=A5=E5=8F=8A?= =?UTF-8?q?=E7=9B=B8=E5=85=B3js?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/courses/settings.html.erb | 157 +++++++++++++++++++--------- public/javascripts/course.js | 10 ++ 2 files changed, 119 insertions(+), 48 deletions(-) diff --git a/app/views/courses/settings.html.erb b/app/views/courses/settings.html.erb index 43261f4e2..1562bedd5 100644 --- a/app/views/courses/settings.html.erb +++ b/app/views/courses/settings.html.erb @@ -2,59 +2,120 @@

    <%= l(:label_course_modify_settings)%>

    -
      - <%= labelled_form_for @course do |f| %> -
    • - <%= render :partial => "avatar/new_avatar_form", :locals => {source: @course} %> -
      -
    • -
    • - - - -
    • -
      -
    • - - - +
      +
        +
      • + 基本信息
      • -
        -
      • - - <%= select_tag :time,options_for_select(course_time_option(@course.time),@course.time), {} %> - <%= select_tag :term,options_for_select(course_term_option,@course.term || cur_course_term),{} %> +
      • + 成员
      • -
        -
      • - - +
      +
      +
      +
        + <%= labelled_form_for @course do |f| %> +
      • + <%= render :partial => "avatar/new_avatar_form", :locals => {source: @course} %> +
        +
      • +
      • + + + +
      • +
        +
      • + + + +
      • +
        +
      • + + <%= select_tag :time,options_for_select(course_time_option(@course.time),@course.time), {} %> + <%= select_tag :term,options_for_select(course_term_option,@course.term || cur_course_term),{} %> +
      • +
        +
      • + + +
        + 学生或其他成员申请加入课程时候需要使用该口令,该口令可以由老师在课堂上公布。 +
      • +
      • + + +
        +
      • +
      • + + id="course_is_public" name="course[is_public]" type="checkbox"> + (打钩为公开,不打钩则不公开,若不公开,仅课程成员可见该课程。) +
        +
      • +
      • + + id="course_open_student" name="course[open_student]" type="checkbox" style="margin-left: 1px;"/> + (打钩为"学生列表公开",不打钩为不公开,若不公开,则课程外部人员看不到学生列表) +
        +
      • +
      • + 提交 + <%= link_to l(:button_cancel), course_path(@course), :class => "blue_btn grey_btn fl c_white" %> +
        +
      • + <% end %> +
      +
      + +
      +
      + +
      +
      +

      添加成员

      +
    • -
    • - - +
        +
      • +
      • +
      • +
      • +
      • +
      • +
      • +
      • +
      • +
      • +
      -
    • -
    • - - id="course_is_public" name="course[is_public]" type="checkbox"> - (打钩为公开,不打钩则不公开,若不公开,仅课程成员可见该课程。) +
      -
    • -
    • - - id="course_open_student" name="course[open_student]" type="checkbox" style="margin-left: 1px;"/> - (打钩为"学生列表公开",不打钩为不公开,若不公开,则课程外部人员看不到学生列表) -
      -
    • -
    • - 提交 - <%= link_to l(:button_cancel), course_path(@course), :class => "blue_btn grey_btn fl c_white" %> +
        +
      • 角色:
      • +
      • +
      • +
      • +
      -
    • - <% end %> -
    + 新增成员 +
    +
    +
    \ No newline at end of file diff --git a/public/javascripts/course.js b/public/javascripts/course.js index e49ecd828..4ca2c3403 100644 --- a/public/javascripts/course.js +++ b/public/javascripts/course.js @@ -1,3 +1,13 @@ +//配置课程信息 +function course_setting(id) +{ + //alert(id); + $('#tb_'+id).removeClass().addClass("hwork_hovertab"); + $('#tbc_0'+id).removeClass().addClass("dis"); + $('#tb_'+(3-id)).removeClass().addClass("hwork_normaltab"); + $('#tbc_0'+(3-id)).removeClass().addClass("undis"); +} + /////////////////////////////////////////////////////////////// //添加分班 function add_group(url,course_id) { From 98bf8dd4942996499cba6f933efc301ac25dad63 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Mon, 30 Mar 2015 11:20:16 +0800 Subject: [PATCH 06/19] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E6=88=90=E5=91=98?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/courses_controller.rb | 3 ++ app/views/courses/_course_members.html.erb | 54 ++++++++++++++++++++++ app/views/courses/_member.html.erb | 13 ++++++ app/views/courses/settings.html.erb | 47 +------------------ public/stylesheets/courses.css | 2 + 5 files changed, 73 insertions(+), 46 deletions(-) create mode 100644 app/views/courses/_course_members.html.erb create mode 100644 app/views/courses/_member.html.erb diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index 7b3130026..8169a9b64 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -402,6 +402,9 @@ class CoursesController < ApplicationController @issue_category ||= IssueCategory.new @member ||= @course.members.new @trackers = Tracker.sorted.all + + @roles = Role.givable.all[3..5] + @members = @course.member_principals.includes(:roles, :principal).all.sort else render_403 end diff --git a/app/views/courses/_course_members.html.erb b/app/views/courses/_course_members.html.erb new file mode 100644 index 000000000..a7c38038b --- /dev/null +++ b/app/views/courses/_course_members.html.erb @@ -0,0 +1,54 @@ +
    + +
    +
    +

    添加成员

    + +
    \ No newline at end of file diff --git a/app/views/courses/_member.html.erb b/app/views/courses/_member.html.erb new file mode 100644 index 000000000..d2612d217 --- /dev/null +++ b/app/views/courses/_member.html.erb @@ -0,0 +1,13 @@ +<% @members.each do |member| %> +
  • + <%= link_to_user_header member.principal,true,:class => "w150 c_orange fl" %> + + <%= h member.roles.sort.collect(&:to_s).join(', ') %> + + 编辑 + <%= delete_link membership_path(member), + :remote => true, + :class => "c_dblue w40 fl", + :data => (!User.current.admin? && member.include?(User.current) ? {:confirm => l(:text_own_membership_delete_confirmation)} : {confirm: l(:label_delete_confirm)}) if member.deletable? %> +
  • +<% end%> \ No newline at end of file diff --git a/app/views/courses/settings.html.erb b/app/views/courses/settings.html.erb index 1562bedd5..569ae302b 100644 --- a/app/views/courses/settings.html.erb +++ b/app/views/courses/settings.html.erb @@ -70,52 +70,7 @@
    -
    - -
    -
    -

    添加成员

    - -
    + <%= render :partial => "course_members" %>
    \ No newline at end of file diff --git a/public/stylesheets/courses.css b/public/stylesheets/courses.css index 11d94e9b2..005f53f2b 100644 --- a/public/stylesheets/courses.css +++ b/public/stylesheets/courses.css @@ -103,6 +103,7 @@ a:hover.grey_btn{ background:#717171; color:#fff;} .f_14{ font-size:14px;} .c_dblue{ color:#3e6d8e;} .w90{width:90px;} +.w40{width:40px;} .ml10{margin-left:10px;} .resource{ width:670px;} .re_top{width:660px; height:40px; background:#eaeaea; padding:5px;} @@ -240,6 +241,7 @@ a:hover.tijiao{ background:#0f99a9;} .members_left ul li{ height:30px; border-bottom:1px solid #E4E4E4; width:410px; padding-top:10px; } .members_left ul li a{ float:left; text-align:center;} .members_left ul li span{ float:left; text-align:center; color:#484747;} + .w150{ text-align:center; width:150px;} .f_b{ font-weight: bold;} .members_right label{ margin-left:15px;} From 083a3b9de6fafbf8f2573ac7e3a7c87571e55d56 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Mon, 30 Mar 2015 13:47:19 +0800 Subject: [PATCH 07/19] =?UTF-8?q?1=E3=80=81=E8=AF=BE=E7=A8=8B=E6=88=90?= =?UTF-8?q?=E5=91=98=E5=88=97=E8=A1=A8=E6=98=BE=E7=A4=BA=E6=98=B5=E7=A7=B0?= =?UTF-8?q?=202=E3=80=81=E6=B7=BB=E5=8A=A0=E8=AF=BE=E7=A8=8B=E6=88=90?= =?UTF-8?q?=E5=91=98=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/members_helper.rb | 11 ++-- app/views/courses/_course_members.html.erb | 63 ++++++++++------------ app/views/courses/_member.html.erb | 2 +- public/stylesheets/courses.css | 3 ++ 4 files changed, 37 insertions(+), 42 deletions(-) diff --git a/app/helpers/members_helper.rb b/app/helpers/members_helper.rb index ed18b7ae4..29ba94924 100644 --- a/app/helpers/members_helper.rb +++ b/app/helpers/members_helper.rb @@ -45,17 +45,14 @@ module MembersHelper # 课程可添加的成员列表 def render_principals_for_new_course_members(course) scope = Principal.active.sorted.not_member_of_course(course).like(params[:q]) - principal_count = scope.count - principal_pages = Redmine::Pagination::Paginator.new principal_count, 10, params['page'] - principals = scope.offset(principal_pages.offset).limit(principal_pages.per_page).all - - s = content_tag('div', principals_check_box_tags_ex('membership[user_ids][]', principals), :id => 'principals') + principals = paginateHelper scope,10 + s = content_tag('ul', project_member_check_box_tags_ex('membership[user_ids][]', principals), :class => 'mb5', :id => 'principals') - links = pagination_links_full(principal_pages, principal_count, :per_page_links => false) {|text, parameters, options| + links = pagination_links_full(@obj_pages, @obj_count, :per_page_links => false, :remote => false, :flag => true) {|text, parameters, options| link_to text, autocomplete_course_memberships_path(course, parameters.merge(:q => params[:q], :format => 'js')), :remote => true } - s + content_tag('div', content_tag('ul', links), :class => 'pagination_new') + s + content_tag('ul', links,:class => 'wlist',:id => "course_member_pagination_links") end diff --git a/app/views/courses/_course_members.html.erb b/app/views/courses/_course_members.html.erb index a7c38038b..b568d3336 100644 --- a/app/views/courses/_course_members.html.erb +++ b/app/views/courses/_course_members.html.erb @@ -17,38 +17,33 @@

    添加成员

    - + <%= form_for(@member, {:as => :membership, :url => course_memberships_path(@course), :remote => true, :method => :post}) do |f| %> + + <% end%>
    \ No newline at end of file diff --git a/app/views/courses/_member.html.erb b/app/views/courses/_member.html.erb index d2612d217..acebc11bd 100644 --- a/app/views/courses/_member.html.erb +++ b/app/views/courses/_member.html.erb @@ -1,6 +1,6 @@ <% @members.each do |member| %>
  • - <%= link_to_user_header member.principal,true,:class => "w150 c_orange fl" %> + <%= link_to_user_header member.principal,false,:class => "w150 c_orange fl" %> <%= h member.roles.sort.collect(&:to_s).join(', ') %> diff --git a/public/stylesheets/courses.css b/public/stylesheets/courses.css index 005f53f2b..f4ffa1fe0 100644 --- a/public/stylesheets/courses.css +++ b/public/stylesheets/courses.css @@ -376,6 +376,9 @@ span.add_attachment {font-size: 80%;line-height: 2.5em;} a:hover.link_file_board{ background:url(../images/pic_file.png) 0 -25px no-repeat; color:#3ca5c6;} a.link_file_board{ background:url(../images/pic_file.png) 0 3px no-repeat !important; padding-left:20px !important; color:#64bdd9 !important; } +#course_member_pagination_links{height: auto;float: left;} +#course_member_pagination_links li{margin-bottom: 5px;} + /* colorbox *******************************************************************************/ /* From 2af071a92e14a8bc20dc163eb180c82174595126 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Mon, 30 Mar 2015 14:55:41 +0800 Subject: [PATCH 08/19] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E6=88=90=E5=91=98=E5=90=8Ejs=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/members_controller.rb | 10 +++++- app/views/courses/_course_members.html.erb | 2 +- app/views/members/create.js.erb | 37 ++++++++++++---------- 3 files changed, 31 insertions(+), 18 deletions(-) diff --git a/app/controllers/members_controller.rb b/app/controllers/members_controller.rb index aaaa4484d..248b22991 100644 --- a/app/controllers/members_controller.rb +++ b/app/controllers/members_controller.rb @@ -133,6 +133,9 @@ class MembersController < ApplicationController elsif @course course_info = [] if params[:membership] + @create_member_error_messages = "角色不能留空" unless params[:membership][:role_ids] + @create_member_error_messages = "用户不能留空" unless params[:membership][:user_ids] + if params[:membership][:user_ids] attrs = params[:membership].dup user_ids = attrs.delete(:user_ids) @@ -140,7 +143,7 @@ class MembersController < ApplicationController member = Member.new(:role_ids => params[:membership][:role_ids], :user_id => user_id) role = Role.find_by_id(params[:membership][:role_ids]) # 这里的判断只能通过角色名,可以弄成常量 - if role.name == "学生" || role.name == "Student" + if role && (role.name == "学生" || role.name == "Student") StudentsForCourse.create(:student_id => user_id, :course_id =>@course.id) end members << member @@ -159,6 +162,11 @@ class MembersController < ApplicationController end @course.members << members @course.course_infos << course_info + + @roles = Role.givable.all[3..5] + members = @course.member_principals.includes(:roles, :principal).all.sort + else + @create_member_error_messages = l(:label_user_role_null) end respond_to do |format| format.html { redirect_to_settings_in_courses } diff --git a/app/views/courses/_course_members.html.erb b/app/views/courses/_course_members.html.erb index b568d3336..87cf59c3b 100644 --- a/app/views/courses/_course_members.html.erb +++ b/app/views/courses/_course_members.html.erb @@ -11,7 +11,7 @@
  • - <%= render :partial => "member" %> + <%= render :partial => "courses/member" %>
    diff --git a/app/views/members/create.js.erb b/app/views/members/create.js.erb index 35280b7a4..93aad5b5e 100644 --- a/app/views/members/create.js.erb +++ b/app/views/members/create.js.erb @@ -1,22 +1,27 @@ <%if @project%> $('#tab-content-members').html('<%= escape_javascript(render :partial => 'projects/settings/members') %>'); -<%elsif @course%> -$('#tab-content-members').html('<%= escape_javascript(render :partial => 'courses/settings/members') %>'); -<%end%> - -hideOnLoad(); <%if !@applied_members%> - <% if @members.present? && @members.all? {|m| m.valid? } %> - <% @members.each do |member| %> - $("#member-<%= member.id %>").effect("highlight"); - <% end %> - <% else %> - <% if @members %> - <% errors = @members.collect {|m| m.errors.full_messages}.flatten.uniq.join(', ')%> - alert('<%= raw(escape_javascript(l(:notice_failed_to_save_members, :errors => errors || ''))) %>'); - <% else%> +<% if @members.present? && @members.all? {|m| m.valid? } %> +<% @members.each do |member| %> +$("#member-<%= member.id %>").effect("highlight"); +<% end %> +<% else %> +<% if @members %> +<% errors = @members.collect {|m| m.errors.full_messages}.flatten.uniq.join(', ')%> +alert('<%= raw(escape_javascript(l(:notice_failed_to_save_members, :errors => errors || ''))) %>'); +<% else%> // alert(''); - <% end%> - <% end %> +<% end%> <% end %> +<% end %> +<%elsif @course%> + <% if @create_member_error_messages%> + alert("<%= @create_member_error_messages%>"); + <% else%> + $('#tbc_02').html('<%= escape_javascript(render :partial => 'courses/course_members') %>'); + alert("添加成功"); + <% end%> +<%end%> + +hideOnLoad(); From ed02959e0027ab0555f7dd23028ec533254f3083 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Mon, 30 Mar 2015 15:57:10 +0800 Subject: [PATCH 09/19] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=88=90=E5=91=98?= =?UTF-8?q?=E8=A7=92=E8=89=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/members_controller.rb | 2 ++ app/views/courses/_course_members.html.erb | 4 +-- app/views/courses/_member.html.erb | 38 ++++++++++++++++++---- app/views/members/update.js.erb | 9 +++-- public/stylesheets/courses.css | 3 +- 5 files changed, 43 insertions(+), 13 deletions(-) diff --git a/app/controllers/members_controller.rb b/app/controllers/members_controller.rb index 248b22991..170e64ef6 100644 --- a/app/controllers/members_controller.rb +++ b/app/controllers/members_controller.rb @@ -250,6 +250,8 @@ class MembersController < ApplicationController end end end + @roles = Role.givable.all[3..5] + @members = @course.member_principals.includes(:roles, :principal).all.sort end saved = @member.save diff --git a/app/views/courses/_course_members.html.erb b/app/views/courses/_course_members.html.erb index 87cf59c3b..9d7db7b98 100644 --- a/app/views/courses/_course_members.html.erb +++ b/app/views/courses/_course_members.html.erb @@ -35,13 +35,13 @@ <% @roles.each do |role| %>
  • - <%= check_box_tag 'membership[role_ids][]', role.id %> + <%= radio_button_tag 'membership[role_ids][]', role.id %>
  • <% end %>
    - + 新增成员 diff --git a/app/views/courses/_member.html.erb b/app/views/courses/_member.html.erb index acebc11bd..53e7c15a5 100644 --- a/app/views/courses/_member.html.erb +++ b/app/views/courses/_member.html.erb @@ -2,12 +2,36 @@
  • <%= link_to_user_header member.principal,false,:class => "w150 c_orange fl" %> - <%= h member.roles.sort.collect(&:to_s).join(', ') %> - - 编辑 - <%= delete_link membership_path(member), - :remote => true, - :class => "c_dblue w40 fl", - :data => (!User.current.admin? && member.include?(User.current) ? {:confirm => l(:text_own_membership_delete_confirmation)} : {confirm: l(:label_delete_confirm)}) if member.deletable? %> + <%= h member.roles.sort.collect(&:to_s).join(', ') %> + <%= form_for(member, {:as => :membership, :remote => true, :url => membership_path(member), + :method => :put, + :html => {:id => "member-#{member.id}-roles-form", :class => 'hol'}} + ) do |f| %> + <% @roles.each do |role| %> + + + <% end %> + <%= hidden_field_tag 'membership[role_ids][]', '' %> +
    + + <%= l(:button_change)%> + + + <%= l(:button_cancel)%> + +
    + <% end %> + + <% unless member.roles.first.to_s == "Manager"%> + 编辑 + <%= delete_link membership_path(member), + :remote => true, + :class => "c_dblue w40 fl", + :data => (!User.current.admin? && member.include?(User.current) ? {:confirm => l(:text_own_membership_delete_confirmation)} : {confirm: l(:label_delete_confirm)}) if member.deletable? %> + <% end%>
  • <% end%> \ No newline at end of file diff --git a/app/views/members/update.js.erb b/app/views/members/update.js.erb index 9f6709701..c72c16fc5 100644 --- a/app/views/members/update.js.erb +++ b/app/views/members/update.js.erb @@ -1,7 +1,10 @@ <%if @project%> $('#tab-content-members').html('<%= escape_javascript(render :partial => 'projects/settings/members') %>'); +$("#member-<%= @member.id %>").effect("highlight"); +hideOnLoad(); <%elsif @course%> -$('#tab-content-members').html('<%= escape_javascript(render :partial => 'courses/settings/members') %>'); -<%end%> +$('#tbc_02').html('<%= escape_javascript(render :partial => 'courses/course_members') %>'); hideOnLoad(); -$("#member-<%= @member.id %>").effect("highlight"); +<%end%> + + diff --git a/public/stylesheets/courses.css b/public/stylesheets/courses.css index f4ffa1fe0..89925371e 100644 --- a/public/stylesheets/courses.css +++ b/public/stylesheets/courses.css @@ -272,8 +272,9 @@ a:hover.tijiao{ background:#0f99a9;} .member_search_input{ border:1px solid #15bccf; background:#fff; width:170px; height:24px; color:#9b9b9b; padding-left:5px; margin-bottom:10px;} .member_search_btn{ background:#15bccf; color:#fff; text-align: center; width:40px; height:22px;border:1px solid #15bccf; padding-top:2px; cursor:pointer;} .member_search_btn:hover{ background:#0da1b2; border:1px solid #0da1b2;} -a.member_btn{ padding:5px; background:#15bccf; color:#fff;} +a.member_btn{ padding: 3px 5px; background:#15bccf; color:#fff;} a:hover.member_btn{ background:#329cbd;} +.hol{display: none;} /* 新建项目 */ .pro_new{ } From 5640eae39b9b28459491926c52c02b5c03321c23 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Mon, 30 Mar 2015 15:59:57 +0800 Subject: [PATCH 10/19] =?UTF-8?q?=E5=88=A0=E9=99=A4=E8=AF=BE=E7=A8=8B?= =?UTF-8?q?=E6=88=90=E5=91=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/members_controller.rb | 3 ++- app/views/members/destroy.js.erb | 4 ++-- app/views/members/update.js.erb | 3 +-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/controllers/members_controller.rb b/app/controllers/members_controller.rb index 170e64ef6..078cb1db5 100644 --- a/app/controllers/members_controller.rb +++ b/app/controllers/members_controller.rb @@ -314,7 +314,8 @@ class MembersController < ApplicationController joined.each do |join| join.delete end - + @roles = Role.givable.all[3..5] + @members = @course.member_principals.includes(:roles, :principal).all.sort end respond_to do |format| format.html { redirect_to_settings_in_courses } diff --git a/app/views/members/destroy.js.erb b/app/views/members/destroy.js.erb index 2d0d26271..912cfde58 100644 --- a/app/views/members/destroy.js.erb +++ b/app/views/members/destroy.js.erb @@ -1,6 +1,6 @@ <%if @project%> -$('#tab-content-members').html('<%= escape_javascript(render :partial => 'projects/settings/members') %>'); + $('#tab-content-members').html('<%= escape_javascript(render :partial => 'projects/settings/members') %>'); <%elsif @course%> - $('#tab-content-members').html('<%= escape_javascript(render :partial => 'courses/settings/members') %>'); + $('#tbc_02').html('<%= escape_javascript(render :partial => 'courses/course_members') %>'); <%end%> hideOnLoad(); diff --git a/app/views/members/update.js.erb b/app/views/members/update.js.erb index c72c16fc5..a166e76ab 100644 --- a/app/views/members/update.js.erb +++ b/app/views/members/update.js.erb @@ -1,10 +1,9 @@ <%if @project%> $('#tab-content-members').html('<%= escape_javascript(render :partial => 'projects/settings/members') %>'); $("#member-<%= @member.id %>").effect("highlight"); -hideOnLoad(); <%elsif @course%> $('#tbc_02').html('<%= escape_javascript(render :partial => 'courses/course_members') %>'); -hideOnLoad(); <%end%> +hideOnLoad(); From de0403580ed3a7a4d064ca1f6de8c7af21a50892 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Mon, 30 Mar 2015 16:03:24 +0800 Subject: [PATCH 11/19] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E8=AF=BE=E7=A8=8B?= =?UTF-8?q?=E6=88=90=E5=91=98=E6=97=B6=E5=A2=9E=E5=8A=A0=E9=BB=98=E8=AE=A4?= =?UTF-8?q?=E9=80=89=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/courses/_course_members.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/courses/_course_members.html.erb b/app/views/courses/_course_members.html.erb index 9d7db7b98..38ef7e9db 100644 --- a/app/views/courses/_course_members.html.erb +++ b/app/views/courses/_course_members.html.erb @@ -35,7 +35,7 @@ <% @roles.each do |role| %>
  • - <%= radio_button_tag 'membership[role_ids][]', role.id %> + <%= radio_button_tag 'membership[role_ids][]', role.id, role.name == "学生" || role.name == "Student" %>
  • <% end %> From 94ecc3e59e2fa1ab9cb0354552333bf5cac0785e Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Mon, 30 Mar 2015 17:03:20 +0800 Subject: [PATCH 12/19] =?UTF-8?q?1=E3=80=81=E8=AF=BE=E7=A8=8B=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=E6=88=90=E5=91=98=E5=88=86=E9=A1=B5=E6=8E=A7=E4=BB=B6?= =?UTF-8?q?=E6=A0=B7=E5=BC=8F=202=E3=80=81=E8=AF=BE=E7=A8=8B=E8=80=81?= =?UTF-8?q?=E5=B8=88=E5=88=97=E8=A1=A8=E7=BF=BB=E9=A1=B5=E4=B8=8D=E5=8F=AF?= =?UTF-8?q?=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/courses_controller.rb | 1 + app/controllers/members_controller.rb | 1 + lib/redmine/pagination.rb | 2 +- public/stylesheets/courses.css | 3 ++- 4 files changed, 5 insertions(+), 2 deletions(-) diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index 8169a9b64..581005bf7 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -323,6 +323,7 @@ class CoursesController < ApplicationController end respond_to do |format| if params[:page] + format.html {render :layout => 'base_courses'} format.js else format.html {render :layout => 'base_courses'} diff --git a/app/controllers/members_controller.rb b/app/controllers/members_controller.rb index 078cb1db5..fc243741a 100644 --- a/app/controllers/members_controller.rb +++ b/app/controllers/members_controller.rb @@ -252,6 +252,7 @@ class MembersController < ApplicationController end @roles = Role.givable.all[3..5] @members = @course.member_principals.includes(:roles, :principal).all.sort + @member = @course.members.new end saved = @member.save diff --git a/lib/redmine/pagination.rb b/lib/redmine/pagination.rb index 00a20c15e..41702e2ce 100644 --- a/lib/redmine/pagination.rb +++ b/lib/redmine/pagination.rb @@ -260,7 +260,7 @@ module Redmine end if page == paginator.page if flag - html << '
  • ' << page.to_s << '
  • ' + html << '
  • ' << content_tag('a', page.to_s, :class => 'current-page c_white') << '
  • ' else html << '
  • ' << content_tag('span', page.to_s, :class => 'current-page') << '
  • ' end diff --git a/public/stylesheets/courses.css b/public/stylesheets/courses.css index 89925371e..6053940d6 100644 --- a/public/stylesheets/courses.css +++ b/public/stylesheets/courses.css @@ -63,7 +63,8 @@ ul.wlist{ float:right; border-bottom:none; height:30px; margin-top:20px; } ul.wlist li{float: left;} ul.wlist li a{ border:1px solid #15bccf; padding: 1px 4px 1px 4px; margin-left:3px;} ul.wlist li a:hover{ background:#15bccf; color:#fff; text-decoration:none;} -.wlist_select { background-color:#64bdd9; color:#fff; padding: 1px 5px 0px 5px; margin-left:3px;margin-top: -2px; border:1px solid #64bdd9;} +/*.wlist_select { background-color:#64bdd9; color:#fff; padding: 1px 5px 0px 5px; margin-left:3px;margin-top: -2px; border:1px solid #64bdd9;}*/ +.wlist_select a{background-color: #64bdd9;cursor: default;} /****讨论区***/ .talk_top{ margin:10px 0; font-size:14px; color:#4c4c4c;} .talk_top span{ color:#ff7143;} From 4817e2e1a798a0461396b1638fb8c9906a13ae44 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Mon, 30 Mar 2015 17:04:36 +0800 Subject: [PATCH 13/19] =?UTF-8?q?=E6=96=B0=E5=BB=BA=E8=AF=BE=E7=A8=8B?= =?UTF-8?q?=E5=8F=96=E6=B6=88=E5=90=8E=E8=BF=94=E5=9B=9Ehost=5Fcourse?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/courses/new.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/courses/new.html.erb b/app/views/courses/new.html.erb index 3d1a3f6a4..3057285a7 100644 --- a/app/views/courses/new.html.erb +++ b/app/views/courses/new.html.erb @@ -47,7 +47,7 @@
  • 提交 - 取消 + 取消
  • <% end%> From eabcd4e92b68348c90f6eeb06c2c97aaa3d6ade4 Mon Sep 17 00:00:00 2001 From: z9hang Date: Mon, 30 Mar 2015 17:14:52 +0800 Subject: [PATCH 14/19] =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E8=B5=84=E6=BA=90?= =?UTF-8?q?=E6=A8=A1=E5=9D=97=E6=96=B0=E7=95=8C=E9=9D=A2=EF=BC=88=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E6=98=BE=E7=A4=BA=EF=BC=8C=E6=8E=92=E5=BA=8F=E7=AD=89?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=EF=BC=8C=E6=A0=B7=E5=BC=8F=E5=B0=9A=E6=9C=AA?= =?UTF-8?q?=E8=B0=83=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/files_controller.rb | 34 +++++++---- app/helpers/attachments_helper.rb | 10 ++++ app/helpers/files_helper.rb | 11 ++++ app/views/files/_course_file.html.erb | 2 +- app/views/files/_project_file_list.html.erb | 58 ++++++++++++++++++ app/views/files/_project_file_new.html.erb | 65 +++++++++++++++++++++ app/views/files/index.html.erb | 2 +- config/locales/projects/zh.yml | 3 +- db/schema.rb | 22 ++----- 9 files changed, 178 insertions(+), 29 deletions(-) create mode 100644 app/views/files/_project_file_list.html.erb create mode 100644 app/views/files/_project_file_new.html.erb diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb index 28156ac0c..0d459e3ba 100644 --- a/app/controllers/files_controller.rb +++ b/app/controllers/files_controller.rb @@ -41,8 +41,8 @@ class FilesController < ApplicationController @feedback_count = @all_attachments.count @feedback_pages = Paginator.new @feedback_count, @limit, params['page'] @offset ||= @feedback_pages.offset - @curse_attachments_all = @all_attachments[@offset, @limit] - @curse_attachments = paginateHelper @all_attachments,10 + #@curse_attachments_all = @all_attachments[@offset, @limit] + @obj_attachments = paginateHelper @all_attachments,10 end def search @@ -132,16 +132,30 @@ class FilesController < ApplicationController attribute = "downloads" when "created_on" attribute = "created_on" + when "quotes" + attribute = "quotes" end - - if order_by.count == 1 - sort += "#{Attachment.table_name}.#{attribute} asc " if attribute - elsif order_by.count == 2 - sort += "#{Attachment.table_name}.#{attribute} #{order_by[1]} " if attribute && order_by[1] - end - if sort_type != params[:sort].split(",").last - sort += "," + @sort = order_by[0] + @order = order_by[1] + if order_by.count == 1 && attribute + sort += "#{Attachment.table_name}.#{attribute} asc " + if sort_type != params[:sort].split(",").last + sort += "," + end + elsif order_by.count == 2 && order_by[1] + sort += "#{Attachment.table_name}.#{attribute} #{order_by[1]} " + if sort_type != params[:sort].split(",").last + sort += "," + end end + # if order_by.count == 1 + # sort += "#{Attachment.table_name}.#{attribute} asc " if attribute + # elsif order_by.count == 2 + # sort += "#{Attachment.table_name}.#{attribute} #{order_by[1]} " if attribute && order_by[1] + # end + # if sort_type != params[:sort].split(",").last + # sort += "," + # end end end diff --git a/app/helpers/attachments_helper.rb b/app/helpers/attachments_helper.rb index 2e07421f8..8843b1a76 100644 --- a/app/helpers/attachments_helper.rb +++ b/app/helpers/attachments_helper.rb @@ -77,6 +77,7 @@ module AttachmentsHelper end end + #判断课程course中是否包含课件attachment,course中引用了attachment也算作包含 def course_contains_attachment? course,attachment course.attachments.each do |att| if att.id == attachment.id || (!att.copy_from.nil? && !attachment.copy_from.nil? && att.copy_from == attachment.copy_from) || att.copy_from == attachment.id || att.id == attachment.copy_from @@ -85,6 +86,15 @@ module AttachmentsHelper end false end + #判断项目project中是否包含课件attachment,project中引用了attachment也算作包含 + def project_contains_attachment? project,attachment + project.attachments.each do |att| + if att.id == attachment.id || (!att.copy_from.nil? && !attachment.copy_from.nil? && att.copy_from == attachment.copy_from) || att.copy_from == attachment.id || att.id == attachment.copy_from + return true + end + end + false + end def get_qute_number attachment if attachment.copy_from diff --git a/app/helpers/files_helper.rb b/app/helpers/files_helper.rb index 884ebc2eb..08b17ea7a 100644 --- a/app/helpers/files_helper.rb +++ b/app/helpers/files_helper.rb @@ -66,6 +66,17 @@ module FilesHelper result end + #判断用户是否拥有不包含当前资源的项目,需用户在该项目中有资源管理相关资源 + def has_project? user,file + result = false + user.projects.each do |project| + if !project_contains_attachment?(project,file) && User.current.allowed_to?(:manage_files, project) + return true + end + end + result + end + # 判断指定的资源时候符合类型 def isTypeOk(attachment, type, contentType) result = false diff --git a/app/views/files/_course_file.html.erb b/app/views/files/_course_file.html.erb index ea499477a..b6f65e9b2 100644 --- a/app/views/files/_course_file.html.erb +++ b/app/views/files/_course_file.html.erb @@ -55,7 +55,7 @@
    - <%= render :partial => 'course_list',:locals => {course: @course,all_attachments: @all_attachments,sort:@sort,order:@order,curse_attachments:@curse_attachments} %> + <%= render :partial => 'course_list',:locals => {course: @course,all_attachments: @all_attachments,sort:@sort,order:@order,curse_attachments:@obj_attachments} %>
    diff --git a/app/views/files/_project_file_list.html.erb b/app/views/files/_project_file_list.html.erb new file mode 100644 index 000000000..60675194b --- /dev/null +++ b/app/views/files/_project_file_list.html.erb @@ -0,0 +1,58 @@ + +
    +

    共有 <%= all_attachments.count%> 个资源

    +

    + <% if order == "asc" %> + 按 <%= link_to "时间",params.merge(:sort=>"created_on:desc"),:class => "f_b c_grey",:remote => @is_remote %><%= render partial: 'arrow_show',locals: { sort: sort,order:order,current:"created_on"} %> /  + <%= link_to "下载次数",params.merge(:sort=>"downloads:desc"),:class => "f_b c_grey",:remote => @is_remote %><%= render partial: 'arrow_show',locals: { sort: sort,order:order,current:"downloads"} %> /  + <%= link_to "引用次数",params.merge(:sort=>"quotes:desc"),:class => "f_b c_grey",:remote => @is_remote %><%= render partial: 'arrow_show',locals: { sort: sort,order:order,current:"quotes"} %> 排序 + <% else %> + 按 <%= link_to "时间",params.merge(:sort=>"created_on:asc"),:class => "f_b c_grey" ,:remote => @is_remote %><%= render partial: 'arrow_show',locals: { sort: sort,order:order,current:"created_on"} %> /  + <%= link_to "下载次数",params.merge(:sort=>"downloads:asc"),:class => "f_b c_grey",:remote => @is_remote %><%= render partial: 'arrow_show',locals: { sort: sort,order:order,current:"downloads"} %>  /  + <%= link_to "引用次数",params.merge(:sort=>"quotes:asc"),:class => "f_b c_grey",:remote => @is_remote %><%= render partial: 'arrow_show',locals: { sort: sort,order:order,current:"quotes"} %> 排序 + <% end %> +

    +
    +
    +
    + <% project_attachments.each do |file| %> +
    +
    + <%= link_to_attachment file, :download => true,:text => truncate(file.filename,length: 35, omission: '...'), :title => file.filename+"\n"+file.description.to_s, :style => "overflow: hidden; white-space: nowrap;text-overflow: ellipsis;",:class => "c_dblue f_14 f_b f_l" %> + <% if User.current.logged? %> + <% if (is_course_teacher(User.current,@course) || file.author_id == User.current.id) && project_contains_attachment?(project,file) %> + <%= link_to(l(:label_slected_to_other_project),quote_resource_show_course_file_path(@course,file),:class => "f_l re_select",:remote => true) if has_project?(User.current,file) %> + + <% if manage_allowed && file.container_id == project.id && file.container_type == "Project" %> + + <%= link_to (file.is_public? ? "公开":"私有"), update_file_dense_attachments_path(:attachmentid=>file.id,:newtype=>(file.is_public? ? 0:1)),:remote=>true,:class=>"f_l re_open",:method => :post %> + + <% else %> + + <% end %> + <% else %> + <%= link_to(l(:label_slected_to_project),quote_resource_show_course_file_path(@course,file),:class => "f_l re_select",:remote => true) if has_course?(User.current,file) %> + <% end %> + <% else %> + <% end %> +
    +
    +
    +

    文件大小:<%= number_to_human_size(file.filesize) %>

    + <%= link_to( l(:button_delete), attachment_path(file), + :data => {:confirm => l(:text_are_you_sure)}, :method => :delete,:class => "f_r re_de") if manage_allowed && file.container_id == project.id && file.container_type == "Project"%> +

    <%= time_tag(file.created_on).html_safe %><%= l(:label_bids_published_ago) %>  |  下载<%= file.downloads %>  |  引用<%= file.quotes.nil? ? 0:file.quotes %>

    +
    +
    +
    + <%= render :partial => 'tags/tag_new', :locals => {:obj => file, :object_flag => "10"} %> + <%= render :partial => 'tags/tag_add', :locals => {:obj => file, :object_flag => "10"} %> +
    +
    +
    + <% end %> +
    + +
    \ No newline at end of file diff --git a/app/views/files/_project_file_new.html.erb b/app/views/files/_project_file_new.html.erb new file mode 100644 index 000000000..977a7e5ab --- /dev/null +++ b/app/views/files/_project_file_new.html.erb @@ -0,0 +1,65 @@ + +
    +

    <%= l(:lable_file_sharingarea) %>

    +
    + + + + +
    +
    +
    + <%#= form_tag( search_course_files_path(@course), method: 'get',:class => "re_search f_l",:remote=>true) do %> + <%#= text_field_tag 'name', params[:name], name: "name", :class => 're_schbox',:style=>"padding: 0px"%> + <%#= submit_tag "课内搜索", :class => "re_schbtn b_lblue",:name => "incourse",:id => "incourse", :onmouseover => "presscss('incourse')",:onmouseout =>"buttoncss()" %> + <%#= submit_tag "全站搜索", :class => "re_schbtn b_lblue",:name => "insite",:id => "insite",:onmouseover => "presscss('insite')",:onmouseout =>"buttoncss()" %> + <%# end %> + <% manage_allowed = User.current.allowed_to?(:manage_files, @project) %> + <% if manage_allowed %> + 上传资源 + <% end %> +
    +
    + +
    + <%= render :partial => 'project_file_list',:locals => {project: @project,all_attachments: @all_attachments,sort:@sort,order:@order,project_attachments:@obj_attachments,:manage_allowed => manage_allowed} %> +
    + +
    +
    +<% html_title(l(:label_attachment_plural)) -%> \ No newline at end of file diff --git a/app/views/files/index.html.erb b/app/views/files/index.html.erb index 4b6df47cb..aefa1a5a9 100644 --- a/app/views/files/index.html.erb +++ b/app/views/files/index.html.erb @@ -1,6 +1,6 @@
    <% if @isproject %> - <%= render :partial => 'project_file', locals: {project: @project} %> + <%= render :partial => 'project_file_new', locals: {project: @project} %> <% else %> <%= render :partial => 'course_file', locals: {course: @course} %> <% end %> diff --git a/config/locales/projects/zh.yml b/config/locales/projects/zh.yml index 9f1a95201..bb78fda4d 100644 --- a/config/locales/projects/zh.yml +++ b/config/locales/projects/zh.yml @@ -106,7 +106,8 @@ zh: lable_file_sharingarea: 资源共享区 label_upload_files: 上传文件 - + label_slected_to_other_project: 选入我的其他项目 + label_slected_to_project: 选入我的项目 # 资源库(附件)公用 > 关联资源 label_relation_files: 关联已有资源 diff --git a/db/schema.rb b/db/schema.rb index b149a870b..295b459e6 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 => 20150309090143) do +ActiveRecord::Schema.define(:version => 20150324021043) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -638,16 +638,6 @@ ActiveRecord::Schema.define(:version => 20150309090143) do add_index "journal_details", ["journal_id"], :name => "journal_details_journal_id" - create_table "journal_details_copy", :force => true do |t| - t.integer "journal_id", :default => 0, :null => false - t.string "property", :limit => 30, :default => "", :null => false - t.string "prop_key", :limit => 30, :default => "", :null => false - t.text "old_value" - t.text "value" - end - - add_index "journal_details_copy", ["journal_id"], :name => "journal_details_journal_id" - create_table "journal_replies", :id => false, :force => true do |t| t.integer "journal_id" t.integer "user_id" @@ -1069,12 +1059,12 @@ ActiveRecord::Schema.define(:version => 20150309090143) do end create_table "roles", :force => true do |t| - t.string "name", :limit => 90 - t.integer "position" - t.boolean "assignable" - t.integer "builtin" + t.string "name", :limit => 30, :default => "", :null => false + t.integer "position", :default => 1 + t.boolean "assignable", :default => true + t.integer "builtin", :default => 0, :null => false t.text "permissions" - t.string "issues_visibility", :limit => 90 + t.string "issues_visibility", :limit => 30, :default => "default", :null => false end create_table "schools", :force => true do |t| From a84af9d13865bc556e878648f9b9a7551e15209b Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Mon, 30 Mar 2015 17:44:40 +0800 Subject: [PATCH 15/19] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E7=A7=81=E6=9C=89?= =?UTF-8?q?=E8=B5=84=E6=BA=90=E4=B8=8D=E6=98=BE=E7=A4=BA=E5=9C=A8=E6=B2=A1?= =?UTF-8?q?=E6=9C=89=E6=9D=83=E9=99=90=E6=9F=A5=E7=9C=8B=E7=9A=84=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E4=B8=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/courses_helper.rb | 10 ++++++++++ app/helpers/files_helper.rb | 10 ---------- app/views/layouts/base_courses.html.erb | 7 +++++-- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/app/helpers/courses_helper.rb b/app/helpers/courses_helper.rb index 408783934..f4ba5040e 100644 --- a/app/helpers/courses_helper.rb +++ b/app/helpers/courses_helper.rb @@ -736,4 +736,14 @@ module CoursesHelper "未启用匿评".html_safe end end + + def visable_attachemnts_incourse course + result = [] + course.attachments.each do |attachment| + if attachment.is_public? || User.current.member_of_course?(course) + result << attachment + end + end + result + end end diff --git a/app/helpers/files_helper.rb b/app/helpers/files_helper.rb index 884ebc2eb..749e7e437 100644 --- a/app/helpers/files_helper.rb +++ b/app/helpers/files_helper.rb @@ -97,16 +97,6 @@ module FilesHelper result end - def visable_attachemnts_incourse attachments - result = [] - attachments.each do |attachment| - if attachment.is_public? || (attachment.author.member_of_course?(Course.find(attachment.container_id)))|| attachment.author_id == User.current.id - result << attachment - end - end - result - end - def visable_attachemnts_insite attachments,course result = [] attachments.each do |attachment| diff --git a/app/views/layouts/base_courses.html.erb b/app/views/layouts/base_courses.html.erb index e787cfa54..25b08ce7d 100644 --- a/app/views/layouts/base_courses.html.erb +++ b/app/views/layouts/base_courses.html.erb @@ -1,6 +1,7 @@ <% course_model %> <% teacher_num = teacherCount(@course) %> <% student_num = studentCount(@course) %> +<% course_file_num = visable_attachemnts_incourse(@course).count%> <% is_teacher = User.current.logged? && (User.current.admin? || User.current.allowed_to?(:as_teacher,@course)) %> @@ -94,7 +95,7 @@ <%= l(:label_account_identity_student)%>(<%= course_student_link student_num %>) - <%= l(:project_module_attachments)%>(<%= link_to @course.attachments.count, course_files_path(@course), :class => 'info_foot_num c_blue' %>)
    + <%= l(:project_module_attachments)%>(<%= link_to course_file_num, course_files_path(@course), :class => 'info_foot_num c_blue' %>)
    @@ -125,7 +126,9 @@ <%= link_to( "+#{l(:label_course_news_new)}", new_course_news_path(@course), :class => 'subnav_green c_white') if is_teacher %>