diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 6387a97a4..cbf2c30bb 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -418,6 +418,8 @@ class ApplicationController < ActionController::Base @project = Project.find(params[:project_id]) elsif params[:course_id] @course = Course.find(params[:course_id]) + elsif params[:org_subfield_id] + @org_subfield = OrgSubfield.find(params[:org_subfield_id]) end rescue ActiveRecord::RecordNotFound render_404 diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb index 37182dbcf..d371ed4cb 100644 --- a/app/controllers/attachments_controller.rb +++ b/app/controllers/attachments_controller.rb @@ -240,6 +240,8 @@ class AttachmentsController < ApplicationController format.html { redirect_to_referer_or respond_path(@attachment.container) } elsif !@attachment.container.nil? && @attachment.container.is_a?(PhoneAppVersion) format.html { redirect_to_referer_or mobile_version_path } + elsif !@attachment.container.nil? && @attachment.container.is_a?(OrgSubfield) + format.html {redirect_to_referer_or org_subfield_files_path(@attachment.container)} else if @project.nil? format.html { redirect_to_referer_or forum_memo_path(@attachment.container.forum, @attachment.container) } diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb index c894680a6..328446fbb 100644 --- a/app/controllers/files_controller.rb +++ b/app/controllers/files_controller.rb @@ -299,6 +299,10 @@ class FilesController < ApplicationController render :layout => 'base_courses' elsif params[:org_subfield_id] @container_type = 2 + @organization = Organization.find(params[:organization_id]) + @containers = [ OrgSubfield.includes(:attachments).reorder(sort).find(@org_subfield.id)] + show_attachments @containers + render :layout => 'base_org' # @subfield = params[:org_subfield_id] end @@ -424,8 +428,39 @@ class FilesController < ApplicationController redirect_to course_files_url(@course) } end - end + elsif @org_subfield + @addTag=false + # if params[:in_org_subfield_toolbar] + # @in_org_subfield_toolbar = params[:in_org_subfield_toolbar] + # end + attachments = Attachment.attach_filesex(@org_subfield, params[:attachments], params[:org_subfield_attachment_type]) + # if !attachments.empty? && !attachments[:files].blank? && Setting.notified_events.include?('file_added') + # Mailer.run.attachments_added(attachments[:files]) + # end + + # TODO: 临时用 nyan + sort_init 'created_on', 'desc' + sort_update 'created_on' => "#{Attachment.table_name}.created_on", + 'filename' => "#{Attachment.table_name}.filename", + 'size' => "#{Attachment.table_name}.filesize", + 'downloads' => "#{Attachment.table_name}.downloads" + + @containers = [OrgSubfield.includes(:attachments).reorder("#{Attachment.table_name}.created_on DESC").find(@org_subfield.id)] #modify by Long Jun + # @containers += @org_subfield.versions.includes(:attachments).reorder("#{Attachment.table_name}.created_on DESC").all.sort + + show_attachments @containers + + @attachtype = 0 + @contenttype = 0 + + respond_to do |format| + format.js + format.html { + redirect_to org_subfield_files_url(@org_subfield) + } + end + end end end diff --git a/app/controllers/my_controller.rb b/app/controllers/my_controller.rb index 794347591..0883b3799 100644 --- a/app/controllers/my_controller.rb +++ b/app/controllers/my_controller.rb @@ -85,7 +85,7 @@ class MyController < ApplicationController flash[:notice] = l(:notice_mail_notification_updated) redirect_to my_account_url else - redirect_to signin_url + redirect_to signin_url end end @@ -223,7 +223,7 @@ class MyController < ApplicationController end flash.now[:error] = l(:notice_account_old_wrong_password) end - render :template => 'my/account',:layout=>'base_users_new' + render :template => 'my/account',:layout=>'new_base_user' end # Create a new feeds key diff --git a/app/controllers/org_subfields_controller.rb b/app/controllers/org_subfields_controller.rb index 00b88fdaa..1dc7885fe 100644 --- a/app/controllers/org_subfields_controller.rb +++ b/app/controllers/org_subfields_controller.rb @@ -17,4 +17,8 @@ class OrgSubfieldsController < ApplicationController @organization = Organization.find(@subfield.organization_id) @subfield.update_attributes(:name => params[:name]) end + + def show + + end end diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 88aae0f8b..ab2cfa2ba 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -30,7 +30,7 @@ class ProjectsController < ApplicationController before_filter :find_project, :except => [ :index, :search,:list, :new, :create, :copy, :statistics, :new_join, :course, :enterprise_course, :course_enterprise,:view_homework_attaches,:join_project] before_filter :authorize, :only => [:show, :settings, :edit, :sort_project_members, :update, :modules, :close, :reopen,:view_homework_attaches,:course] before_filter :authorize_global, :only => [:new, :create,:view_homework_attaches] - before_filter :require_admin, :only => [ :copy, :archive, :unarchive, :destroy, :calendar] + before_filter :require_admin, :only => [ :copy, :unarchive, :destroy, :calendar] before_filter :file, :statistics #:watcherlist # 除非项目内人员,不可查看成员, TODO: 完了写报表里去 # before_filter :memberAccess, only: :member diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb index 1fe798328..b79adda2d 100644 --- a/app/controllers/student_work_controller.rb +++ b/app/controllers/student_work_controller.rb @@ -923,7 +923,7 @@ class StudentWorkController < ApplicationController #成绩计算 def set_final_score homework,student_work if homework && homework.homework_detail_manual - if homework.homework_type == 1 #匿评作业 + if homework.homework_type != 2 #匿评作业 if homework.teacher_priority == 1 #教师优先 if student_work.teacher_score student_work.final_score = student_work.teacher_score diff --git a/app/helpers/files_helper.rb b/app/helpers/files_helper.rb index 9a1765ddc..cf9cbcc32 100644 --- a/app/helpers/files_helper.rb +++ b/app/helpers/files_helper.rb @@ -113,7 +113,8 @@ module FilesHelper if attachment.is_public? || (attachment.container_type == "Project" && User.current.member_of?(attachment.project)) || (attachment.container_type == "Course" && User.current.member_of_course?(Course.find(attachment.container_id)))|| - attachment.author_id == User.current.id + attachment.author_id == User.current.id || + attachment.container_type == "OrgSubfield" result << attachment end end diff --git a/app/models/attachment.rb b/app/models/attachment.rb index 8d4a1a524..ad5655b02 100644 --- a/app/models/attachment.rb +++ b/app/models/attachment.rb @@ -22,6 +22,7 @@ class Attachment < ActiveRecord::Base belongs_to :container, :polymorphic => true belongs_to :project, foreign_key: 'container_id', conditions: "attachments.container_type = 'Project'" belongs_to :course, foreign_key: 'container_id', conditions: "attachments.container_type = 'Course'" + belongs_to :org_subfield, foreign_key: 'container_id', conditions: "attachements.container_type = 'OrgSubfield'" belongs_to :softapplication, foreign_key: 'container_id', conditions: "attachments.container_type = 'Softapplication'" belongs_to :author, :class_name => "User", :foreign_key => "author_id" belongs_to :attachmentstype, :foreign_key => "attachtype",:primary_key => "id" diff --git a/app/models/memo.rb b/app/models/memo.rb index 2ead1cbb6..ee9f4c8db 100644 --- a/app/models/memo.rb +++ b/app/models/memo.rb @@ -18,10 +18,28 @@ class Memo < ActiveRecord::Base #elasticsearch kaminari init Kaminari::Hooks.init Elasticsearch::Model::Response::Response.__send__ :include, Elasticsearch::Model::Response::Pagination::Kaminari - settings index: { number_of_shards: 5 } do + settings index: { + number_of_shards: 5 , + analysis: { + char_filter: { + and_filter: { + type: "mapping", + mappings: [ "&=> and "] + } + }, + analyzer: { + my_analyzer: { + type: 'custom', + tokenizer: 'standard', + filter: ['classic'], + char_filter: ['html_strip'] + } + } + } + } do mappings dynamic: 'false' do - indexes :subject, analyzer: 'smartcn',index_options: 'offsets' - indexes :content, analyzer: 'smartcn',index_options: 'offsets' + indexes :subject, analyzer: 'smartcn',index_options: 'offsets'#, char_filter: 'html_strip' + indexes :content, analyzer:'my_analyzer',index_options: 'offsets',search_analyzer: 'smartcn' indexes :updated_at,index:"not_analyzed" ,type:'date' end end diff --git a/app/models/org_subfield.rb b/app/models/org_subfield.rb index efe9699c3..f95bb3eba 100644 --- a/app/models/org_subfield.rb +++ b/app/models/org_subfield.rb @@ -1,4 +1,9 @@ class OrgSubfield < ActiveRecord::Base belongs_to :organization, :foreign_key => :organization_id has_many :org_document_comments, :dependent => :destroy + has_many :files + acts_as_attachable + + def project + end end \ No newline at end of file diff --git a/app/models/student_work.rb b/app/models/student_work.rb index c6e2a6584..144f3859f 100644 --- a/app/models/student_work.rb +++ b/app/models/student_work.rb @@ -46,7 +46,7 @@ class StudentWork < ActiveRecord::Base #成绩计算 def set_final_score homework,student_work if homework && homework.homework_detail_manual - if homework.homework_type == 1 #匿评作业 + if homework.homework_type != 2 #匿评作业 if homework.teacher_priority == 1 #教师优先 if student_work.teacher_score student_work.final_score = student_work.teacher_score diff --git a/app/services/users_service.rb b/app/services/users_service.rb index 8b39c39ab..8df42fb41 100644 --- a/app/services/users_service.rb +++ b/app/services/users_service.rb @@ -228,7 +228,7 @@ class UsersService end course_list end - + #修改密码 def change_password params @current_user = User.find(params[:current_user_id]) diff --git a/app/views/courses/settings.html.erb b/app/views/courses/settings.html.erb index 650127aef..634f26495 100644 --- a/app/views/courses/settings.html.erb +++ b/app/views/courses/settings.html.erb @@ -89,7 +89,7 @@ <% end %> <% if @course.is_delete == 1 %> -
<%=link_to "恢复该课程", renew_course_path(@course) %>
+
<%=link_to "恢复该课程", renew_course_path(@course) %>
<% else %>
<%=link_to "删除该课程", course_path(@course), :method => :delete, :confirm=>"确认要删除该课程吗?" %> diff --git a/app/views/files/_attachement_list.html.erb b/app/views/files/_attachement_list.html.erb index 25cc7f68a..a9d399511 100644 --- a/app/views/files/_attachement_list.html.erb +++ b/app/views/files/_attachement_list.html.erb @@ -20,6 +20,25 @@ :lebel_file_uploding => l(:lebel_file_uploding), :delete_all_files => l(:text_are_you_sure_all) } %> +<% elsif @project %> + <%= file_field_tag 'attachments[dummy][file]', + :id => '_file', + :class => ie8? ? '':'file_selector', + :multiple => true, + :onchange => 'addInputFiles(this);', + :style => ie8? ? '': 'display:none', + :data => { + :max_file_size => Setting.attachment_max_size.to_i.kilobytes, + :max_file_size_message => l(:error_attachment_too_big, :max_size => number_to_human_size(Setting.attachment_max_size.to_i.kilobytes)), + :max_concurrent_uploads => Redmine::Configuration['max_concurrent_ajax_uploads'].to_i, + :upload_path => uploads_path(:format => 'js'), + :description_placeholder => l(:label_optional_description), + :field_is_public => l(:field_is_public), + :are_you_sure => l(:text_are_you_sure), + :file_count => l(:label_file_count), + :lebel_file_uploding => l(:lebel_file_uploding), + :delete_all_files => l(:text_are_you_sure_all) + } %> <% else %> <%= file_field_tag 'attachments[dummy][file]', :id => '_file', diff --git a/app/views/files/_org_subfield_list.html.erb b/app/views/files/_org_subfield_list.html.erb new file mode 100644 index 000000000..a8aa13458 --- /dev/null +++ b/app/views/files/_org_subfield_list.html.erb @@ -0,0 +1,56 @@ +<% delete_allowed = User.current.admin? %> +
+

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

+

+ <% if order == "asc" %> + 按 <%= link_to "时间",params.merge(:sort=>"created_on:desc"),:class => "f_b c_grey",:remote => @is_remote %><%= render partial: 'files/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: 'files/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: 'files/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: 'files/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: 'files/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: 'files/arrow_show',locals: { sort: sort,order:order,current:"quotes"} %> 排序 + <% end %> +

+
+
+ + + + +
+ +
+ <% org_subfield_attachments.each do |file| %> + <% if 1 %> +
+
+ <%= link_to truncate(file.filename,length: 35, omission: '...'), + download_named_attachment_path(file.id, file.filename), + :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? %> + <%= file_preview_tag(file, class: 'f_l re_open', style:'text-align: center;') %> + <% 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 (delete_allowed || User.current.id == file.author_id) && file.container_id == @org_subfield.id && file.container_type == "OrgSubfield"%> +

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

+
+
+ + + + + +
+
+ <% end %> + <% end %> +
+ +
diff --git a/app/views/files/_subfield_files.html.erb b/app/views/files/_subfield_files.html.erb new file mode 100644 index 000000000..ea408c7a6 --- /dev/null +++ b/app/views/files/_subfield_files.html.erb @@ -0,0 +1,97 @@ +<%= stylesheet_link_tag 'courses' %> + + +
+
+
+ <%= form_tag( search_org_subfield_files_path(@org_subfield), 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 => "inorg_subfield",:id => "inorg_subfield", :onmouseover => "presscss('inorg_subfield')",:onmouseout =>"buttoncss()" %> + <%= submit_tag "全站搜索", :class => "re_schbtn b_lblue",:name => "insite",:id => "insite",:onmouseover => "presscss('insite')",:onmouseout =>"buttoncss()" %> + <% end %> + <%# if is_org_subfield_teacher(User.current,@org_subfield) || (@org_subfield.publish_resource==1 && User.current.member_of_org_subfield?(@org_subfield) ) %> + +

+ 上传: + 课件 |  + 软件 |  + 媒体 |  + 代码 |  + 论文 |  + 其他 +

+ <%# end %> +
+
+ +
+ <%= render :partial => 'org_subfield_list',:locals => {org_subfield: @org_subfield,all_attachments: @all_attachments,sort:@sort,order:@order,org_subfield_attachments:@obj_attachments} %> +
+ +
+
+<% html_title(l(:label_attachment_plural)) -%> \ No newline at end of file diff --git a/app/views/files/_subfield_files_list.html.erb b/app/views/files/_subfield_files_list.html.erb new file mode 100644 index 000000000..d762743ad --- /dev/null +++ b/app/views/files/_subfield_files_list.html.erb @@ -0,0 +1,55 @@ +<% delete_allowed = User.current.admin? %> +
+

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

+

+ <% if order == "asc" %> + 按 <%= link_to "时间",params.merge(:sort=>"created_on:desc"),:class => "f_b c_grey",:remote => @is_remote %><%= render partial: 'files/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: 'files/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: 'files/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: 'files/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: 'files/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: 'files/arrow_show',locals: { sort: sort,order:order,current:"quotes"} %> 排序 + <% end %> +

+
+
+ +
+ <%= render :partial => "files/tag_yun", :locals => {:tag_list => @tag_list,:course => course,:tag_name => @tag_name}%> +
+
+ +
+ <% curse_attachments.each do |file| %> + <% if file.is_public? || User.current.admin? %> +
+
+ <%= link_to truncate(file.filename,length: 35, omission: '...'), + download_named_attachment_path(file.id, file.filename), + :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" %> +
+
+
+

文件大小:<%= 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 (delete_allowed || User.current.id == file.author_id) && file.container_id == @org_subfield.id && file.container_type == "OrgSubfield"%> +

<%= 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 => "6",:tag_name => @tag_name} %> + <%= render :partial => 'tags/tag_add', :locals => {:obj => file, :object_flag => "6",:tag_name => @tag_name} %> +
+
+
+ <% else %> +
<%= file.filename %>是私有资源
+ <% end %> + <% end %> +
+ +
diff --git a/app/views/files/_upload_subfield_file.html.erb b/app/views/files/_upload_subfield_file.html.erb new file mode 100644 index 000000000..c3ca72ecd --- /dev/null +++ b/app/views/files/_upload_subfield_file.html.erb @@ -0,0 +1,31 @@ + +
+
+

<%= l(:label_upload_files)%>

+
+ <%= error_messages_for 'attachment' %> + + + <%= form_tag(org_subfield_files_path(org_subfield), :multipart => true,:remote => !ie8?,:name=>"upload_form") do %> + + + + <%= render :partial => 'files/attachement_list',:locals => {:org_subfield => org_subfield} %> +
+ <%= l(:button_cancel)%> + <%= l(:button_confirm)%> + <% end %> +
+ +
+ <% content_for :header_tags do %> + <%= javascript_include_tag 'attachments' %> + <% end %> +
+ + \ No newline at end of file diff --git a/app/views/files/create.js.erb b/app/views/files/create.js.erb index 9de7aa042..4d8bb26ca 100644 --- a/app/views/files/create.js.erb +++ b/app/views/files/create.js.erb @@ -52,6 +52,17 @@ $('#upload_file_div').slideToggle('slow'); setTimeout( function(){div.remove();},3000) <% end %> <%end%> + <% elsif @org_subfield %> + hideModal(); + $("#resource_list").html('<%= j(render partial: "subfield_files" ,locals: {org_subfield: @org_subfield}) %>'); +// $("#courses_files_count_info").html("<%#= @all_attachments.count%>"); +// $("#courses_files_count_nav").html("(<%#= @all_attachments.count%>)") + // 添加文件上传成功提示, + <% unless params[:attachments].nil? %> + var div = $('
文件上传成功!
'); + $("#org_subfield_list").prepend(div); + setTimeout( function(){div.remove();},3000) + <% end %> <% end %> <% end %> $(document).ready(img_thumbnails); diff --git a/app/views/files/index.html.erb b/app/views/files/index.html.erb index 3dad88868..dff20a20b 100644 --- a/app/views/files/index.html.erb +++ b/app/views/files/index.html.erb @@ -1,8 +1,10 @@
- <% if @isproject %> + <% if @container_type == 0 %> <%= render :partial => 'project_file_new', locals: {project: @project} %> - <% else %> + <% elsif @container_type == 1 %> <%= render :partial => 'course_file', locals: {course: @course} %> + <% elsif @container_type == 2 %> + <%= render :partial => 'files/subfield_files', locals: {org_subfield: @org_subfield} %> <% end %>
diff --git a/app/views/forums/show.html.erb b/app/views/forums/show.html.erb index ad9195804..280d378f3 100644 --- a/app/views/forums/show.html.erb +++ b/app/views/forums/show.html.erb @@ -115,10 +115,7 @@ $.ajax({ url:'/forums/'+'<%= @forum.id.to_s%>'+'/memos', type:'post', - data:{ - 'memo[content]':$("#memo_content").val(), - 'memo[subject]':$("#memo_subject").val() - }, + data:$("#new_memo").serialize(), success:function(data){ }, diff --git a/app/views/my/account.html.erb b/app/views/my/account.html.erb index 94f62638e..604953ad9 100644 --- a/app/views/my/account.html.erb +++ b/app/views/my/account.html.erb @@ -30,7 +30,7 @@
  •