From c51794d7546aab016d8a51ce91f9d0acec9413af Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Mon, 11 May 2015 16:06:40 +0800 Subject: [PATCH 1/8] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E9=80=9A=E7=9F=A5?= =?UTF-8?q?=E8=BF=9E=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/news/_course_form.html.erb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/views/news/_course_form.html.erb b/app/views/news/_course_form.html.erb index b757ab274..a76d84701 100644 --- a/app/views/news/_course_form.html.erb +++ b/app/views/news/_course_form.html.erb @@ -25,11 +25,11 @@
  • <% if is_new %> - <%= link_to l(:button_create), "#", :onclick => 'submitNews();', :onmouseover => 'submitFocus(this);', :class => 'blue_btn fl c_white' %> + <%= link_to l(:button_create), "javascript:void(0)", :onclick => 'submitNews();', :onmouseover => 'submitFocus(this);', :class => 'blue_btn fl c_white' %> <%= link_to l(:button_cancel), course_news_index_path(@course), :onclick => '$("#add-news").hide()', :class => 'blue_btn grey_btn fl c_white' %> <% else %> - <%= link_to l(:button_save), "#", :onclick => "submitNews();",:onmouseover => 'this.focus()',:class => 'blue_btn fl c_white' %> - <%= link_to l(:button_cancel), "#", :onclick => '$("#edit-news").hide(); return false;',:class => 'blue_btn grey_btn fl c_white' %> + <%= link_to l(:button_save), "javascript:void(0)", :onclick => "submitNews();",:onmouseover => 'this.focus()',:class => 'blue_btn fl c_white' %> + <%= link_to l(:button_cancel), "javascript:void(0)", :onclick => '$("#edit-news").hide(); return false;',:class => 'blue_btn grey_btn fl c_white' %> <% end %>
  • From 25bcc676b975b26003f6b40bea1c16c35881b8f3 Mon Sep 17 00:00:00 2001 From: alan <547533434@qq.com> Date: Mon, 11 May 2015 16:23:15 +0800 Subject: [PATCH 2/8] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E9=99=84=E4=BB=B6?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=E4=BB=A5=E5=8F=8A=E4=BF=AE=E6=94=B9=E8=B7=AF?= =?UTF-8?q?=E7=94=B1=E8=B7=B3=E8=BD=AC=20Signed-off-by:=20alan=20<54753343?= =?UTF-8?q?4@qq.com>?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/boards_controller.rb | 2 +- app/views/boards/_course_new.html.erb | 2 +- app/views/boards/_course_show.html.erb | 3 +++ app/views/boards/_edit.html.erb | 7 ++++--- app/views/boards/_form_project.html.erb | 2 +- app/views/boards/_project_new_topic.html.erb | 2 +- app/views/boards/_project_show.html.erb | 8 ++++++-- public/stylesheets/pleft.css | 2 +- 8 files changed, 18 insertions(+), 10 deletions(-) diff --git a/app/controllers/boards_controller.rb b/app/controllers/boards_controller.rb index f6ec09b2a..03581d0c2 100644 --- a/app/controllers/boards_controller.rb +++ b/app/controllers/boards_controller.rb @@ -27,7 +27,7 @@ class BoardsController < ApplicationController include SortHelper helper :watchers helper :project_score - + helper :attachments def index #modify by nwb @flag = params[:flag] || false diff --git a/app/views/boards/_course_new.html.erb b/app/views/boards/_course_new.html.erb index 94ba51529..e80ce8135 100644 --- a/app/views/boards/_course_new.html.erb +++ b/app/views/boards/_course_new.html.erb @@ -1,6 +1,6 @@ <%= form_for @message, :url =>{:controller=>'messages',:action => 'new', :board_id => @board.id, :is_board => 'true'}, :html => {:multipart => true, :id => 'message-form'} do |f| %> - <%= render :partial => 'form_course', :locals => {:f => f} %> + <%= render :partial => 'form_course', :locals => {:f => f, :topic => @message} %>
  • <%= link_to l(:button_cancel), course_boards_path(@course), :class => 'grey_btn fr ml10' %> <%= l(:button_submit)%> diff --git a/app/views/boards/_course_show.html.erb b/app/views/boards/_course_show.html.erb index c55bb8336..34ce6e55f 100644 --- a/app/views/boards/_course_show.html.erb +++ b/app/views/boards/_course_show.html.erb @@ -57,6 +57,7 @@
    + <% if topic.content.size > 300 %>

    <%= topic.content %> @@ -66,6 +67,8 @@

    + <% end %> + <%= link_to_attachments_course topic, :author => false %> <%= l(:label_activity_time)%>:  <%= format_time topic.created_on %>
    <%= toggle_link l(:button_reply), "reply" + topic.id.to_s, :focus => 'message_content',:class => ' c_dblue fr' %> diff --git a/app/views/boards/_edit.html.erb b/app/views/boards/_edit.html.erb index c41f723de..a4b2aff73 100644 --- a/app/views/boards/_edit.html.erb +++ b/app/views/boards/_edit.html.erb @@ -11,9 +11,10 @@ :method => :post} } do |f| %> <%= render :partial => 'form_project', - :locals => {:f => f, :replying => !topic.parent.nil?} %> + :locals => {:f => f, :replying => !topic.parent.nil?, :topic => topic} %> <%= l(:button_submit)%> - <%= link_to l(:button_cancel), board_message_url(topic.board, topic.root, :r => (topic.parent_id && topic.id)), :class => "blue_btn grey_btn fl c_white" %> + <%= l(:button_cancel) %> + <%#= link_to l(:button_cancel), board_message_url(topic.board, topic.root, :r => (topic.parent_id && topic.id)), :class => "blue_btn grey_btn fl c_white" %> <% end %> @@ -29,7 +30,7 @@ :method => :post} } do |f| %> <%= render :partial => 'form_course', - :locals => {:f => f, :replying => !topic.parent.nil?} %> + :locals => {:f => f, :replying => !topic.parent.nil?, :topic => topic} %> <%= l(:button_submit)%> <%= link_to l(:button_cancel), board_message_url(topic.board,topic.root, :r => (topic.parent_id &&topic.id)), :class => "blue_btn grey_btn fl c_white" %> diff --git a/app/views/boards/_form_project.html.erb b/app/views/boards/_form_project.html.erb index b42cabbeb..4e0ffe8e7 100644 --- a/app/views/boards/_form_project.html.erb +++ b/app/views/boards/_form_project.html.erb @@ -51,7 +51,7 @@
  • <% unless replying %>
    - <%= render :partial => 'attachments/form_project', :locals => {:container => @message,:isReply => @isReply} %> + <%= render :partial => 'attachments/form_project', :locals => {:container => topic,:isReply => true} %>
    <% end %>
  • diff --git a/app/views/boards/_project_new_topic.html.erb b/app/views/boards/_project_new_topic.html.erb index 371007a72..2207c4b10 100644 --- a/app/views/boards/_project_new_topic.html.erb +++ b/app/views/boards/_project_new_topic.html.erb @@ -1,6 +1,6 @@ <%= form_for @message, :url =>{:controller=>'messages',:action => 'new', :board_id => @board.id, :is_board => 'true'}, :html => {:multipart => true, :id => 'message-form'} do |f| %> - <%= render :partial => 'form_project', :locals => {:f => f} %> + <%= render :partial => 'form_project', :locals => {:f => f, :topic => @message} %>
  • <%= link_to l(:button_cancel), project_boards_path(@project), :class => 'grey_btn fr ml10' %> <%= l(:button_submit)%> diff --git a/app/views/boards/_project_show.html.erb b/app/views/boards/_project_show.html.erb index d0fd6215a..15237756a 100644 --- a/app/views/boards/_project_show.html.erb +++ b/app/views/boards/_project_show.html.erb @@ -61,6 +61,7 @@

    <%= topic.content %>

    + <% if topic.content.size > 300 %>

    @@ -68,14 +69,17 @@

    - - + <% end %> + <%= link_to_attachments_course topic, :author => false %> <%= l(:label_activity_time)%>:  <%= format_time topic.created_on %> + <%= toggle_link l(:button_reply), "reply" + topic.id.to_s, :focus => 'message_content',:class => ' c_dblue fr' %>
    + +
    diff --git a/public/stylesheets/pleft.css b/public/stylesheets/pleft.css index 4d495e999..6554db7ec 100644 --- a/public/stylesheets/pleft.css +++ b/public/stylesheets/pleft.css @@ -49,7 +49,7 @@ a:hover.subnav_green{ background:#14ad5a;} /*简介*/ .project_intro{ width:220px; padding:10px; background:#fff; margin-top:10px; padding-top:5px; color:#6d6d6d; line-height:1.9;} .course_description{max-height: 112px;overflow:hidden; word-break: break-all;word-wrap: break-word;} -.project_board_content{overflow: hidden;max-height: 50px;word-break: break-all;word-wrap: break-word;} +.project_board_content{overflow: hidden;max-height: 55px;word-break: break-all;word-wrap: break-word;} .course_description_none{max-height: none;} .lg-foot{ border:1px solid #e8eef2; color: #929598; text-align:center; width:220px; height:23px; cursor:pointer;display: none;} .lg-foot:hover{ color:#787b7e; border:1px solid #d4d4d4;} From 79c0c6f551aa67bfed5ed42efbd8af7084c93da5 Mon Sep 17 00:00:00 2001 From: alan <547533434@qq.com> Date: Mon, 11 May 2015 16:45:03 +0800 Subject: [PATCH 3/8] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=B7=AF=E7=94=B1?= =?UTF-8?q?=E8=B7=B3=E8=BD=AC=20Signed-off-by:=20alan=20<547533434@qq.com>?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/boards/_course_show.html.erb | 4 ++-- app/views/boards/_project_show.html.erb | 2 +- app/views/layouts/_base_development_group.html.erb | 2 +- app/views/layouts/_base_friend_group.html.erb | 2 +- app/views/layouts/_base_research_team.html.erb | 2 +- app/views/layouts/base_courses.html.erb | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/app/views/boards/_course_show.html.erb b/app/views/boards/_course_show.html.erb index 34ce6e55f..3962a5b12 100644 --- a/app/views/boards/_course_show.html.erb +++ b/app/views/boards/_course_show.html.erb @@ -39,7 +39,7 @@ <%= link_to author, user_path(topic.author), :class =>"talkmain_name fl " %>

      <%= h(topic.subject) %>

    - <% if topic.editable_by?(User.current) %> + <% if topic.course_editable_by?(User.current) %> <%= l(:button_edit) %> <% end %> @@ -75,7 +75,7 @@
    -
    + -
    + <% end%> diff --git a/app/views/layouts/_base_friend_group.html.erb b/app/views/layouts/_base_friend_group.html.erb index 16ccc09e5..71d375501 100644 --- a/app/views/layouts/_base_friend_group.html.erb +++ b/app/views/layouts/_base_friend_group.html.erb @@ -12,7 +12,7 @@ (<%= @project.boards.first.topics.count %>) <% end %> <% if User.current.member_of?(@project) %> - <%= link_to "+"+l(:project_module_boards_post), new_board_message_path(@project.boards.first), :layout => 'base_projects', :class => "subnav_green ml105" %> + <%= link_to "+"+l(:project_module_boards_post), project_boards_path(@project, :flag => true), :layout => 'base_projects', :class => "subnav_green ml105" %> <% end %>
    <% end%> diff --git a/app/views/layouts/_base_research_team.html.erb b/app/views/layouts/_base_research_team.html.erb index a214e8c20..f228f0439 100644 --- a/app/views/layouts/_base_research_team.html.erb +++ b/app/views/layouts/_base_research_team.html.erb @@ -23,7 +23,7 @@ (<%= @project.boards.first.topics.count %>) <% end %> <% if User.current.member_of?(@project) %> - <%= link_to "+"+l(:project_module_boards_post), new_board_message_path(@project.boards.first), :layout => 'base_projects', :class => "subnav_green ml105" %> + <%= link_to "+"+l(:project_module_boards_post), project_boards_path(@project, :flag => true), :layout => 'base_projects', :class => "subnav_green ml105" %> <% end %>
    <% end%> diff --git a/app/views/layouts/base_courses.html.erb b/app/views/layouts/base_courses.html.erb index 2a26ff59f..6923b17c2 100644 --- a/app/views/layouts/base_courses.html.erb +++ b/app/views/layouts/base_courses.html.erb @@ -133,7 +133,7 @@ <%= toggle_link l(:button_reply), "reply" + topic.id.to_s, :focus => 'message_content',:class => ' c_dblue fr' %>
    + +
  • <% unless replying %>
    - <%= render :partial => 'attachments/form_project', :locals => {:container => @message,:isReply => @isReply} %> + <%= render :partial => 'attachments/form_project', :locals => {:container => topic,:isReply => @isReply} %>
    <% end %>
  • diff --git a/public/javascripts/attachments.js b/public/javascripts/attachments.js index 2c10d28e4..6eb73182d 100644 --- a/public/javascripts/attachments.js +++ b/public/javascripts/attachments.js @@ -23,9 +23,10 @@ function reload(fileSpan) { } -function addFile(inputEl, file, eagerUpload) { +function addFile_board(inputEl, file, eagerUpload, id) { - if ($('#attachments_fields').children().length < 30) { + var attachments_frame = '#attachments_fields' + id; + if ($(attachments_frame).children().length < 30) { deleteallfiles = $(inputEl).data('deleteAllFiles'); var attachmentId = addFile.nextAttachmentId++; @@ -48,7 +49,7 @@ function addFile(inputEl, file, eagerUpload) { }).toggle(!eagerUpload), $('
    ', { 'class': 'div_attachments', 'name': 'div_'+'attachments_' + attachmentId} ) - ).appendTo('#attachments_fields'); + ).appendTo(attachments_frame); if(eagerUpload) { ajaxUpload(file, attachmentId, fileSpan, inputEl); @@ -58,7 +59,42 @@ function addFile(inputEl, file, eagerUpload) { } return null; } +function addFile(inputEl, file, eagerUpload) { + + var attachments_frame = '#attachments_fields'; + if ($(attachments_frame).children().length < 30) { + deleteallfiles = $(inputEl).data('deleteAllFiles'); + var attachmentId = addFile.nextAttachmentId++; + + var fileSpan = $('', { 'id': 'attachments_' + attachmentId, 'class':'attachment' }); + + fileSpan.append( + $('', { 'type': 'text', 'class': 'filename readonly', 'name': 'attachments[' + attachmentId + '][filename]', 'readonly': 'readonly'} ).val(file.name), + $('', { 'type': 'text', 'class': 'description', 'name': 'attachments[' + attachmentId + '][description]', 'maxlength': 254, 'placeholder': $(inputEl).data('descriptionPlaceholder') } ).toggle(!eagerUpload), + $(''+$(inputEl).data('fieldIsPublic')+':').attr({ 'class': 'ispublic-label' }) , + $('', { 'type': 'checkbox', 'class': 'is_public_checkbox','value':1, 'name': 'attachments[' + attachmentId + '][is_public_checkbox]', checked:'checked' } ).toggle(!eagerUpload), + $(' ').attr({ 'href': "#", 'class': 'remove-upload' }).click(function(){ + if(confirm($(inputEl).data('areYouSure'))){ + removeFile(); + if(!eagerUpload){ + (function(e){ + reload(e); + })(fileSpan); + } + } + }).toggle(!eagerUpload), + $('
    ', { 'class': 'div_attachments', 'name': 'div_'+'attachments_' + attachmentId} ) + ).appendTo('#attachments_fields'); + + if(eagerUpload) { + ajaxUpload(file, attachmentId, fileSpan, inputEl); + + } + return attachmentId; + } + return null; +} addFile.nextAttachmentId = 1; function ajaxUpload(file, attachmentId, fileSpan, inputEl) { @@ -202,7 +238,26 @@ function addInputFiles(inputEl) { //clearedFileInput.insertAfter('#attachments_fields'); } +function addInputFiles_board(inputEl, id) { + // var clearedFileInput = $(inputEl).clone().val(''); + + if (inputEl.files) { + // upload files using ajax + uploadAndAttachFiles_board(inputEl.files, inputEl, id); + // $(inputEl).remove(); + } else { + // browser not supporting the file API, upload on form submission + var attachmentId; + var aFilename = inputEl.value.split(/\/|\\/); + attachmentId = addFile_board(inputEl, { name: aFilename[ aFilename.length - 1 ] }, false, id); + if (attachmentId) { + $(inputEl).attr({ name: 'attachments[' + attachmentId + '][file]'}).hide(); + $('#upload_file_count').html(""+count+""+$(inputEl).data('fileCount')); + } + } + //clearedFileInput.insertAfter('#attachments_fields'); +} function uploadAndAttachFiles(files, inputEl) { var maxFileSize = $(inputEl).data('max-file-size'); @@ -218,7 +273,21 @@ function uploadAndAttachFiles(files, inputEl) { $.each(files, function() {addFile(inputEl, this, true);}); } } +function uploadAndAttachFiles_board(files, inputEl, id) { + var maxFileSize = $(inputEl).data('max-file-size'); + var maxFileSizeExceeded = $(inputEl).data('max-file-size-message'); + + var sizeExceeded = false; + $.each(files, function() { + if (this.size && maxFileSize != null && this.size > parseInt(maxFileSize)) {sizeExceeded=true;} + }); + if (sizeExceeded) { + window.alert(maxFileSizeExceeded); + } else { + $.each(files, function() {addFile_board(inputEl, this, true, id);}); + } +} function handleFileDropEvent(e) { $(this).removeClass('fileover'); diff --git a/public/stylesheets/courses.css b/public/stylesheets/courses.css index f49ef22f1..132cddadc 100644 --- a/public/stylesheets/courses.css +++ b/public/stylesheets/courses.css @@ -83,8 +83,8 @@ a:hover.talk_edit{ color:#ff5722;} .talkpage_text{ border:1px solid #64bdd9; width:600px; color:#7d7d7d; padding:5px; margin:10px 0 10px 50px; background:#fff;} /****新建讨论***/ .talk_new{ color:#4c4c4c;} -.talk_input{ border:1px solid #64bdd9; height:16px; width:585px; background:#fff; margin-bottom:10px; padding:5px;} -.talk_text{ border:1px solid #64bdd9; height:100px;width:585px; background:#fff; margin-left:5px; padding:5px; margin-bottom:10px;} +.talk_input{ border:1px solid #64bdd9; height:16px; width:550px; background:#fff; margin-bottom:10px; padding:5px;} +.talk_text{ border:1px solid #64bdd9; height:100px;width:550px; background:#fff; margin-left:5px; padding:5px; margin-bottom:10px;} .talk_new ul li{ } .sb{width:70px; height:26px; color:#606060; cursor:pointer;} a.blue_btn{ background:#64bdd9; display:block; font-size:14px;color:#fff; font-weight:normal; text-align:center; margin-left:10px; margin-bottom:10px; padding:2px 10px;} @@ -364,6 +364,23 @@ span.add_attachment {font-size: 80%;line-height: 2.5em;} .reply_btn:hover{ background:#999; color:#fff; } #attachments_fields div.ui-progressbar { width: 100px; height:14px; margin: 2px 0 -5px 8px; display: inline-block; } + +.attachments_fields input.description {margin-left:4px; width:100px; } +.attachments_fields span .boldSpan{display:block; white-space:nowrap; font-family:'微软雅黑';} +.attachments_fields div.ui-progressbar { width: 100px; height:14px; margin: 2px 0 -5px 8px; display: inline-block; } +a.remove-upload:hover {text-decoration:none !important;} +.attachments_fields input.is_public_checkbox {width:20px;} + + +.attachments_fields span.ispublic-label {display: inline-block;width: 30px;margin-left: 10px;} +a.remove-upload {background: url(../images/delete.png) no-repeat 1px 50%;width: 1px;display: inline-block;padding-left: 16px;} +.attachments_fields input.filename {border: 0;height: 1.8em;width: 150px;color: #555;background-color: inherit;background: url(../images/attachment.png) no-repeat 1px 50%;padding-left: 18px;padding-top: 2px;} +span.add_attachment {font-size: 80%;line-height: 2.5em;} +.attachments_fields span {display: block;white-space: nowrap;} +.file_selector{position: relative;opacity: 0;filter: alpha(opacity:0);} +.attachments_fields .ajax-waiting input.filename {background:url(../images/hourglass.png) no-repeat 0px 50%;} +.attachments_fields .ajax-loading input.filename {background:url(../images/loading.gif) no-repeat 0px 50%;} + .ui-widget { font-family: Verdana, sans-serif; font-size: 1.1em; diff --git a/public/stylesheets/project.css b/public/stylesheets/project.css index 98194b73c..14a7a9a34 100644 --- a/public/stylesheets/project.css +++ b/public/stylesheets/project.css @@ -123,8 +123,8 @@ a:hover.talk_edit{ color:#ff5722;} .recall_con{ float:left;color:#777777; width:520px; margin-left:10px; } /****新建讨论***/ .talk_new{ color:#4c4c4c;} -.talk_input{ border:1px solid #64bdd9; height:16px; width:585px; background:#fff; margin-bottom:10px; padding:5px;} -.talk_text{ border:1px solid #64bdd9; height:100px;width:585px; background:#fff; margin-left:5px; padding:5px; margin-bottom:10px;} +.talk_input{ border:1px solid #64bdd9; height:16px; width:550px; background:#fff; margin-bottom:10px; padding:5px;} +.talk_text{ border:1px solid #64bdd9; height:100px;width:550px; background:#fff; margin-left:5px; padding:5px; margin-bottom:10px;} .talk_new ul li{ } .sb{width:70px; height:26px; color:#606060; cursor:pointer;} /*a.blue_btn{ background:#64bdd9; display:block; font-size:14px;color:#fff; font-weight:normal; text-align:center; margin-left:10px; margin-bottom:10px; padding:2px 10px;}*/ @@ -254,7 +254,21 @@ span.add_attachment {font-size: 80%;line-height: 2.5em;} .reply_btn{ cursor:pointer; -moz-border-radius:3px; -webkit-border-radius:3px; border:1px solid #ccc; color:#999; border-radius:3px; padding:2px 10px; margin-bottom:10px;display: block;margin-left: 470px;} .reply_btn:hover{ background:#999; color:#fff; } +.attachments_fields input.description {margin-left:4px; width:100px; } +.attachments_fields span .boldSpan{display:block; white-space:nowrap; font-family:'微软雅黑';} +.attachments_fields div.ui-progressbar { width: 100px; height:14px; margin: 2px 0 -5px 8px; display: inline-block; } +a.remove-upload:hover {text-decoration:none !important;} +.attachments_fields input.is_public_checkbox {width:20px;} + +.attachments_fields span.ispublic-label {display: inline-block;width: 30px;margin-left: 10px;} +a.remove-upload {background: url(../images/delete.png) no-repeat 1px 50%;width: 1px;display: inline-block;padding-left: 16px;} +.attachments_fields input.filename {border: 0;height: 1.8em;width: 150px;color: #555;background-color: inherit;background: url(../images/attachment.png) no-repeat 1px 50%;padding-left: 18px;padding-top: 2px;} +span.add_attachment {font-size: 80%;line-height: 2.5em;} +.attachments_fields span {display: block;white-space: nowrap;} +.file_selector{position: relative;opacity: 0;filter: alpha(opacity:0);} +.attachments_fields .ajax-waiting input.filename {background:url(../images/hourglass.png) no-repeat 0px 50%;} +.attachments_fields .ajax-loading input.filename {background:url(../images/loading.gif) no-repeat 0px 50%;} .ui-widget { font-family: Verdana, sans-serif; From 3fae37fa90911663b2bd1497ce4e114a0e85bb3c Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Wed, 13 May 2015 09:56:34 +0800 Subject: [PATCH 8/8] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E5=AD=A6=E7=94=9F?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E4=B8=8B=E5=95=A6=E5=88=B7=E6=96=B0=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=EF=BC=8C=E6=9F=A5=E7=9C=8B=E5=8E=86=E6=AC=A1=E4=BD=9C?= =?UTF-8?q?=E4=B8=9A=E6=88=90=E7=BB=A9=E7=9A=84=E4=B8=8B=E5=95=A6=E5=88=B7?= =?UTF-8?q?=E6=96=B0=E6=98=BE=E7=A4=BAapi=E6=94=B9=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/mobile/apis/courses.rb | 20 ++++++++++++++++++++ app/api/mobile/apis/users.rb | 1 + app/api/mobile/entities/homework_attach.rb | 1 - app/api/mobile/entities/homeworkscore.rb | 18 ++++++++++++++++++ app/api/mobile/entities/member.rb | 1 + app/services/courses_service.rb | 17 +++++++++++++++++ app/services/users_service.rb | 12 ++++++++---- db/schema.rb | 10 ++++++++++ 8 files changed, 75 insertions(+), 5 deletions(-) create mode 100644 app/api/mobile/entities/homeworkscore.rb diff --git a/app/api/mobile/apis/courses.rb b/app/api/mobile/apis/courses.rb index 0d0c4651f..b2a2532bc 100644 --- a/app/api/mobile/apis/courses.rb +++ b/app/api/mobile/apis/courses.rb @@ -168,6 +168,14 @@ module Mobile present :status, 0 end + desc "设置教辅" + params do + + end + post 'set_user_as_assitant' do + + end + desc "返回单个课程" params do requires :id, type: Integer @@ -254,6 +262,18 @@ module Mobile present :status, 0 end + desc '查看用户历次作业成绩' + params do + requires :token,type:String + requires :member_id,type:Integer,desc:'课程member_id' + optional :homeworkName,type:String,desc:'作业名称以及作业名称可能包含的字符' + end + get '/show_member_score/:member_id' do + cs = CoursesService.new + homeworkscore = cs.show_member_score params + present :data,homeworkscore,with: Mobile::Entities::Homeworkscore + present :status,0 + end end end end diff --git a/app/api/mobile/apis/users.rb b/app/api/mobile/apis/users.rb index 063cfafae..3ef2c3237 100644 --- a/app/api/mobile/apis/users.rb +++ b/app/api/mobile/apis/users.rb @@ -83,6 +83,7 @@ module Mobile params do requires :name, type: String, desc: '用户名关键字' requires :search_by, type: String,desc: '搜索依据:0 昵称,1 用户名,2 邮箱,3 昵称和姓名' + optional :is_search_assitant,type:Integer,desc:'是否搜索注册用户来作为助教' end get 'search/search_user' do us = UsersService.new diff --git a/app/api/mobile/entities/homework_attach.rb b/app/api/mobile/entities/homework_attach.rb index 690ec8e94..2ad11fe36 100644 --- a/app/api/mobile/entities/homework_attach.rb +++ b/app/api/mobile/entities/homework_attach.rb @@ -37,7 +37,6 @@ module Mobile f.send(:attachments) end end - #homework_attach_expose :user end end end \ No newline at end of file diff --git a/app/api/mobile/entities/homeworkscore.rb b/app/api/mobile/entities/homeworkscore.rb new file mode 100644 index 000000000..e0c501c58 --- /dev/null +++ b/app/api/mobile/entities/homeworkscore.rb @@ -0,0 +1,18 @@ +module Mobile + module Entities + class Homeworkscore < Grape::Entity + include Redmine::I18n + include ApplicationHelper + def self.homeworkscore_expose(field) + expose field do |f,opt| + if f.is_a?(Hash) && f.key?(field) + f[field] + end + end + end + + homeworkscore_expose :name + homeworkscore_expose :score + end + end +end \ No newline at end of file diff --git a/app/api/mobile/entities/member.rb b/app/api/mobile/entities/member.rb index 837ec788a..f9dd1e849 100644 --- a/app/api/mobile/entities/member.rb +++ b/app/api/mobile/entities/member.rb @@ -28,6 +28,7 @@ module Mobile end member_expose :student_id member_expose :score + member_expose :id end end end \ No newline at end of file diff --git a/app/services/courses_service.rb b/app/services/courses_service.rb index 22249b953..fd7ec55fb 100644 --- a/app/services/courses_service.rb +++ b/app/services/courses_service.rb @@ -458,6 +458,21 @@ class CoursesService @all_members = searchmember_by_name(student_homework_score(0,params[:course_id], 10,"desc"),params[:name]) end + def show_member_score params + @member_score = Member.find(params[:member_id]) if params[:member_id] + atta = @member_score.student_homework_score[0] + result = [] + atta.each do |t| + if !params[:homeworkName].nil? && params[:homeworkName] != "" + result << {:name=>t[:name],:score=>t[:score]} if t[:name].include?(params[:homeworkName]) + else + result << {:name=>t[:name],:score=>t[:score]} + end + + end + result + end + private def searchmember_by_name members, name #searchPeopleByRoles(project, StudentRoles) @@ -559,4 +574,6 @@ class CoursesService end + + end \ No newline at end of file diff --git a/app/services/users_service.rb b/app/services/users_service.rb index 3a92bf8f1..17557872b 100644 --- a/app/services/users_service.rb +++ b/app/services/users_service.rb @@ -205,10 +205,14 @@ class UsersService "show_changesets" => true } scope = User.logged.status(status) - watcher = User.watched_by(params[:user_id]) - watcher.push(params[:user_id]) - search_by = params[:search_by] ? params[:search_by] : "0" - scope = scope.where("id not in (?)",watcher).like(params[:name],search_by) if params[:name].present? + if params[:is_search_assitant].nil? + watcher = User.watched_by(params[:user_id]) + watcher.push(params[:user_id]) + search_by = params[:search_by] ? params[:search_by] : "0" + scope = scope.where("id not in (?)",watcher).like(params[:name],search_by) if params[:name].present? + else + scope = scope.like(params[:name],search_by) if params[:name].present? + end scope end diff --git a/db/schema.rb b/db/schema.rb index e798dba1c..94210e8f2 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -659,6 +659,16 @@ ActiveRecord::Schema.define(:version => 20150505025537) 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"