From 470f45becdc39e81a57a8f182f9f443a1cba30b5 Mon Sep 17 00:00:00 2001 From: huang Date: Mon, 4 Jan 2016 17:05:32 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E8=AE=A8=E8=AE=BA=E5=8C=BA?= =?UTF-8?q?=EF=BC=88=E6=9C=AA=E5=AE=8C=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/users_controller.rb | 2 +- app/views/files/_course_file.html.erb | 2 +- app/views/files/_project_file.html.erb | 192 +++++++++++------- app/views/files/_upload_show_project.html.erb | 12 +- app/views/files/index.html.erb | 2 +- app/views/layouts/new_base_user.html.erb | 2 +- config/routes.rb | 24 ++- ...82423_add_pubulish_resource_to_projects.rb | 5 + db/schema.rb | 3 +- 9 files changed, 152 insertions(+), 92 deletions(-) create mode 100644 db/migrate/20160104082423_add_pubulish_resource_to_projects.rb diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 016b4ccbb..fdd2fe419 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -877,7 +877,7 @@ class UsersController < ApplicationController #显示更多用户课程 def user_courses4show @page = params[:page].to_i + 1 - @courses = @user.courses.visible.select("courses.*,(SELECT MAX(created_at) FROM `course_activities` WHERE course_activities.course_id = courses.id) AS a").order("a desc").limit(5).offset(@page * 5) + @courses = @user.courses.visible.where("is_delete =?", 0).select("courses.*,(SELECT MAX(created_at) FROM `course_activities` WHERE course_activities.course_id = courses.id) AS a").order("a desc").limit(5).offset(@page * 5) end #显示更多用户项目 diff --git a/app/views/files/_course_file.html.erb b/app/views/files/_course_file.html.erb index 9513baab0..57de7e3b6 100644 --- a/app/views/files/_course_file.html.erb +++ b/app/views/files/_course_file.html.erb @@ -102,7 +102,7 @@
- <%= render :partial => "files/tag_yun", :locals => {:tag_list => @tag_list,:course => @course,:tag_name => @tag_name}%> + <%#= render :partial => "files/tag_yun", :locals => {:tag_list => @tag_list,:course => @course,:tag_name => @tag_name}%>
diff --git a/app/views/files/_project_file.html.erb b/app/views/files/_project_file.html.erb index b4d849cd6..a92a925a5 100644 --- a/app/views/files/_project_file.html.erb +++ b/app/views/files/_project_file.html.erb @@ -1,82 +1,124 @@ -<% attachmenttypes = @project.attachmenttypes %> -<% sufixtypes = @project.contenttypes %> -
-

<%= l(:lable_file_sharingarea) %>

-
-
- <%#= link_to(l(:label_attachment_new), 'javascript:void(0);', :onclick=>"$('#file_buttons').slideToggle();", :class => 'icon icon-add') if User.current.allowed_to?(:manage_files, @project) %> -
-
- <%= link_to(l(:label_upload_files), 'javascript:void(0);', :class => 'icon m5p5 button_submit', :onclick => "$('#relation_file_div').slideUp();$('#upload_file_div').slideToggle('slow');") if User.current.allowed_to?(:manage_files, @project) %> - <%= link_to(l(:label_relation_files), 'javascript:void(0);', :onclick => "$('#upload_file_div').slideUp();$('#relation_file_div').slideToggle();", :class => 'icon m5p5 button_submit') if User.current.allowed_to?(:manage_files, @project) %> -

-
"> - <%= render :partial => 'new', locals: {project: @project} %> + + +
+
+
资源库
+ +
+
+
+ <%= form_tag( search_course_files_path(@project), method: 'get',:class => "re_search",:remote=>true) do %> + <%= text_field_tag 'name', params[:name], name: "name", :class => 'researchBox fl',:style=>"padding: 0px"%> + <%= submit_tag "课内搜索", :class => "blueBtn mr5 fl",:name => "incourse",:id => "incourse" %> + <%= submit_tag "全站搜索", :class => "blueBtn mr5 fl",:name => "insite",:id => "insite" %> + + <% if (@project.publish_resource==1 && User.current.member_of?(@project) ) %> + + <% end %> + <% end %> + + +
- - -
- - <% if attachmenttypes.any? %> -       - - <%= select_tag "attachment_browse", content_tag(:option, l(:attachment_all), :value => '0') +options_from_collection_for_select(attachmenttypes, "id", "typeName",params[:type]), - :onchange => "attachmenttypes_searchex(this.value)" %> - <% end %> - <% if sufixtypes.any? %> -   - - <%= select_tag "attach_sufix_browse", content_tag(:option, l(:attachment_all), :value => '0') +options_for_select(sufixtypes), - :onchange => "attachment_contenttypes_searchex(this.value)" %> - <% end %> +
+ <%#= render :partial => 'course_list',:locals => {course: @course,all_attachments: @all_attachments,sort:@sort,order:@order,curse_attachments:@obj_attachments} %>
-<%= javascript_tag "observeSearchfield('attach_search', null, '#{ escape_javascript attachments_autocomplete_path(:project_id => @project.id, :format => 'js') }')" %> - -<% delete_allowed = User.current.allowed_to?(:manage_files, @project) %> - -
- <%#= render :partial => 'show_all_attachment' %> - <% if (@attachtype==0 && @contenttype=='0') || (@attachtype.nil? && @contenttype.nil?) %> - <%= render partial: "show_all_attachment"%> - <%else%> - <%= render partial: "sort_by_attachtypel"%> - <%end%> -
- <% html_title(l(:label_attachment_plural)) -%> \ No newline at end of file diff --git a/app/views/files/_upload_show_project.html.erb b/app/views/files/_upload_show_project.html.erb index 53c57b3c6..204243e76 100644 --- a/app/views/files/_upload_show_project.html.erb +++ b/app/views/files/_upload_show_project.html.erb @@ -1,5 +1,5 @@ -
+

<%= l(:label_upload_files)%>

@@ -7,12 +7,12 @@ <%= form_tag(project_files_path(project), :multipart => true,:remote => !ie8?,:name=>"upload_form") do %> - - - <%= render :partial => 'files/attachement_list',:locals => {:project => project} %> + + <%= render :partial => 'attachement_list',:locals => {:project => project} %>
- <%= l(:button_cancel)%> - <%= l(:button_confirm)%> + <%= l(:button_cancel)%> + + <%= submit_tag '确定',:onclick=>'submit_resource();',:onfocus=>'this.blur()',:id=>'submit_resource',:class=>'sendSourceText fr' %> <% end %>
diff --git a/app/views/files/index.html.erb b/app/views/files/index.html.erb index 383ea155e..4ab7e5765 100644 --- a/app/views/files/index.html.erb +++ b/app/views/files/index.html.erb @@ -1,7 +1,7 @@ <% if @container_type == 0 %>
- <%= render :partial => 'project_file_new', locals: {project: @project} %> + <%= render :partial => 'project_file', locals: {project: @project} %>
<% elsif @container_type == 1 %>
diff --git a/app/views/layouts/new_base_user.html.erb b/app/views/layouts/new_base_user.html.erb index b77c5b875..0b32f55b6 100644 --- a/app/views/layouts/new_base_user.html.erb +++ b/app/views/layouts/new_base_user.html.erb @@ -147,7 +147,7 @@ <% end%> <% end%>
- <% courses = @user.courses.visible.where("is_delete =?", 0).select("courses.*,(SELECT MAX(created_at) FROM `course_activities` WHERE course_activities.course_id = courses.id) AS a").order("a desc").limit(5)%> + <% courses = @user.courses.visible.where("is_delete =?", 0).select("courses.*,(SELECT MAX(created_at) FROM `course_activities` WHERE course_activities.course_id = courses.id) AS a").order("a desc").limit(5) %>
    <%= render :partial => 'layouts/user_courses', :locals => {:courses => courses,:user => @user, :page => 0} %> diff --git a/config/routes.rb b/config/routes.rb index 7c473fada..99455743d 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -650,16 +650,28 @@ RedmineApp::Application.routes.draw do match 'issues/update_form', :to => 'issues#update_form', :via => [:put, :post], :as => 'issue_form' resources :files, :only => [:index, :new, :create] do - member do - match "quote_resource_show_project",:via => [:get] - end collection do - match "getattachtype" , :via => [:get, :post] - match "search_project",:via => [:post,:get] - #match 'getattachtype/:attachtype', :to => 'files#getattachtype', :via => [:get, :post] + match "getattachtype", :via => [:get, :post] + match "search",:via => [:post,:get] + match "searchone4reload",:via => [:post,:get] + match "search_tag_attachment", :via => [:post,:get] + end + member do + match "quote_resource_show", :via => [:get] end end + # resources :files, :only => [:index, :new, :create] do + # member do + # match "quote_resource_show_project",:via => [:get] + # end + # collection do + # match "getattachtype" , :via => [:get, :post] + # match "search_project",:via => [:post,:get] + # #match 'getattachtype/:attachtype', :to => 'files#getattachtype', :via => [:get, :post] + # end + # end + resources :versions, :except => [:index, :show, :edit, :update, :destroy] do collection do diff --git a/db/migrate/20160104082423_add_pubulish_resource_to_projects.rb b/db/migrate/20160104082423_add_pubulish_resource_to_projects.rb new file mode 100644 index 000000000..bed68336e --- /dev/null +++ b/db/migrate/20160104082423_add_pubulish_resource_to_projects.rb @@ -0,0 +1,5 @@ +class AddPubulishResourceToProjects < ActiveRecord::Migration + def change + add_column :projects, :publish_resource, :integer, :default => false + end +end diff --git a/db/schema.rb b/db/schema.rb index 3728e8da0..e2b348a1b 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 => 20151231023610) do +ActiveRecord::Schema.define(:version => 20160104082423) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -1396,6 +1396,7 @@ ActiveRecord::Schema.define(:version => 20151231023610) do t.integer "forked_from_project_id" t.integer "forked_count" t.integer "commits_count", :default => 0 + t.integer "publish_resource", :default => 0 end add_index "projects", ["lft"], :name => "index_projects_on_lft"