From 5d2bb4ccbdafedbab3ac6d206c375284bfe5a39e Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Tue, 13 May 2014 10:30:15 +0800 Subject: [PATCH 1/6] =?UTF-8?q?1.=E9=80=89=E6=8B=A9=E5=AD=A6=E6=A0=A1?= =?UTF-8?q?=E8=BF=9B=E5=85=A5=E5=AD=A6=E6=A0=A1=E8=AF=BE=E7=A8=8B=E5=88=97?= =?UTF-8?q?=E8=A1=A8=EF=BC=8C=E7=82=B9=E5=87=BB=E6=9B=B4=E5=A4=9A=E7=94=B1?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E6=89=80=E6=9C=89=E8=AF=BE=E7=A8=8B=E5=8F=AF?= =?UTF-8?q?=E8=83=BD=E6=94=B9=E4=B8=BA=E6=98=BE=E7=A4=BA=E5=BD=93=E5=89=8D?= =?UTF-8?q?=E5=AD=A6=E6=A0=A1=E8=AF=BE=E7=A8=8B=E5=88=97=E8=A1=A8=EF=BC=8C?= =?UTF-8?q?=E4=B9=8B=E5=90=8E=E6=8E=92=E5=BA=8F=E4=B9=9F=E4=B8=80=E6=A0=B7?= =?UTF-8?q?=202.=E5=BD=93=E6=9F=A5=E8=AF=A2=E5=AD=A6=E6=A0=A1=E8=AF=BE?= =?UTF-8?q?=E7=A8=8B=E5=88=97=E8=A1=A8=E4=B8=BA=E7=A9=BA=E6=97=B6=EF=BC=8C?= =?UTF-8?q?=E6=8E=A8=E8=8D=90=E6=94=B9=E4=B8=BA=E6=9C=AC=E7=B3=BB=E7=BB=9F?= =?UTF-8?q?=E4=B8=AD=E6=9C=AC=E5=B9=B4=E5=BA=A6=E5=BC=80=E8=AE=BE=E7=9A=84?= =?UTF-8?q?=E6=9C=80=E5=A5=BD=E7=9A=84=E8=AF=BE=E7=A8=8B=EF=BC=8C=E5=90=8C?= =?UTF-8?q?=E6=97=B6=E5=8A=A0=E5=85=A5=E8=AF=BE=E7=A8=8B=E6=94=B9=E4=B8=BA?= =?UTF-8?q?=E5=85=B3=E6=B3=A8=E8=AF=BE=E7=A8=8B=E3=80=82=E6=AD=A4=E6=97=B6?= =?UTF-8?q?=E7=82=B9=E5=87=BB=E6=9B=B4=E5=A4=9A=E6=9F=A5=E7=9C=8B=E7=9A=84?= =?UTF-8?q?=E4=B8=BA=E6=89=80=E6=9C=89=E8=AF=BE=E7=A8=8B=203.=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=E5=87=BA=E8=AF=BE=E7=A8=8B=E5=88=97=E8=A1=A8=E5=B0=86?= =?UTF-8?q?=E5=AD=A6=E6=A0=A1=E5=92=8C=E6=95=99=E5=B8=88=E6=94=BE=E5=9C=A8?= =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E4=B8=8A=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/projects_controller.rb | 2 +- app/helpers/projects_helper.rb | 26 +- app/helpers/welcome_helper.rb | 6 + app/views/projects/course.html.erb | 2 +- app/views/welcome/course.html.erb | 321 +++++++++++++------------ 5 files changed, 185 insertions(+), 172 deletions(-) diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index d26cf698e..a120394ef 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -198,7 +198,7 @@ class ProjectsController < ApplicationController @project_type = params[:project_type] @school_id = params[:school_id] per_page_option = 10 - if @school_id == "0" or @school.nil? + if @school_id == "0" or @school_id.nil? @projects_all = Project.active.visible. joins("LEFT JOIN #{ProjectStatus.table_name} ON #{Project.table_name}.id = #{ProjectStatus.table_name}.project_id"). where("#{Project.table_name}.project_type = ? ", Project::ProjectType_course) diff --git a/app/helpers/projects_helper.rb b/app/helpers/projects_helper.rb index 5bd677bdf..bddf9d0d4 100644 --- a/app/helpers/projects_helper.rb +++ b/app/helpers/projects_helper.rb @@ -62,33 +62,33 @@ module ProjectsHelper content_tag('div', content, :class => "tabs_enterprise") end - def sort_course(state, project_type) + def sort_course(state, project_type, school_id) content = ''.html_safe case state when 0 - content << content_tag('li', link_to(l(:label_sort_by_time), course_path(:project_sort_type => '0', :project_type => project_type), :class=>"selected"), :class=>"selected") - content << content_tag('li', link_to(l(:label_sort_by_active), course_path(:project_sort_type => '1', :project_type => project_type))) + content << content_tag('li', link_to(l(:label_sort_by_time), course_path(:project_sort_type => '0', :project_type => project_type), :school_id => school_id, :class=>"selected"), :class=>"selected") + content << content_tag('li', link_to(l(:label_sort_by_active), course_path(:project_sort_type => '1', :project_type => project_type, :school_id => school_id))) # content << content_tag('li', link_to(l(:label_sort_by_influence), course_path(:project_sort_type => '2', :project_type => project_type))) - content << content_tag('li', link_to(l(:label_sort_by_activity), course_path(:project_sort_type => '3', :project_type => project_type))) + content << content_tag('li', link_to(l(:label_sort_by_activity), course_path(:project_sort_type => '3', :project_type => project_type, :school_id => school_id))) when 1 - content << content_tag('li', link_to(l(:label_sort_by_time), course_path(:project_sort_type => '0', :project_type => project_type))) - content << content_tag('li', link_to(l(:label_sort_by_active), course_path(:project_sort_type => '1', :project_type => project_type), :class=>"selected"), :class=>"selected") + content << content_tag('li', link_to(l(:label_sort_by_time), course_path(:project_sort_type => '0', :project_type => project_type, :school_id => school_id))) + content << content_tag('li', link_to(l(:label_sort_by_active), course_path(:project_sort_type => '1', :project_type => project_type, :school_id => school_id), :class=>"selected"), :class=>"selected") # content << content_tag('li', link_to(l(:label_sort_by_influence), course_path(:project_sort_type => '2', :project_type => project_type))) - content << content_tag('li', link_to(l(:label_sort_by_activity), course_path(:project_sort_type => '3', :project_type => project_type))) + content << content_tag('li', link_to(l(:label_sort_by_activity), course_path(:project_sort_type => '3', :project_type => project_type, :school_id => school_id))) when 2 - content << content_tag('li', link_to(l(:label_sort_by_time), course_path(:project_sort_type => '0', :project_type => project_type))) - content << content_tag('li', link_to(l(:label_sort_by_active), course_path(:project_sort_type => '1', :project_type => project_type))) + content << content_tag('li', link_to(l(:label_sort_by_time), course_path(:project_sort_type => '0', :project_type => project_type, :school_id => school_id))) + content << content_tag('li', link_to(l(:label_sort_by_active), course_path(:project_sort_type => '1', :project_type => project_type, :school_id => school_id))) # content << content_tag('li', link_to(l(:label_sort_by_influence), course_path(:project_sort_type => '2', :project_type => project_type), :class=>"selected"), :class=>"selected") - content << content_tag('li', link_to(l(:label_sort_by_activity), course_path(:project_sort_type => '3', :project_type => project_type))) + content << content_tag('li', link_to(l(:label_sort_by_activity), course_path(:project_sort_type => '3', :project_type => project_type, :school_id => school_id))) #gcm when 3 - content << content_tag('li', link_to(l(:label_sort_by_time), course_path(:project_sort_type => '0', :project_type => project_type))) - content << content_tag('li', link_to(l(:label_sort_by_active), course_path(:project_sort_type => '1', :project_type => project_type))) + content << content_tag('li', link_to(l(:label_sort_by_time), course_path(:project_sort_type => '0', :project_type => project_type, :school_id => school_id))) + content << content_tag('li', link_to(l(:label_sort_by_active), course_path(:project_sort_type => '1', :project_type => project_type, :school_id => school_id))) # content << content_tag('li', link_to(l(:label_sort_by_influence), course_path(:project_sort_type => '2', :project_type => project_type))) - content << content_tag('li', link_to(l(:label_sort_by_activity), course_path(:project_sort_type => '3', :project_type => project_type), :class=>"selected"), :class=>"selected") + content << content_tag('li', link_to(l(:label_sort_by_activity), course_path(:project_sort_type => '3', :project_type => project_type, :school_id => school_id), :class=>"selected"), :class=>"selected") end #gcmend diff --git a/app/helpers/welcome_helper.rb b/app/helpers/welcome_helper.rb index ed435fe6d..e05f789a9 100644 --- a/app/helpers/welcome_helper.rb +++ b/app/helpers/welcome_helper.rb @@ -154,6 +154,12 @@ module WelcomeHelper sort_course_by_hot limit end + def find_all_new_hot_course limit = 9 + #sort_project_by_hot_rails 1, 'course_ac_para DESC', limit + time_now = Time.new.strftime("%Y"); + Project.visible.joins(:project_status).where("#{Project.table_name}.project_type = ? and #{Project.table_name}.created_on like '%#{time_now}%'", 1).order("course_ac_para DESC").limit(limit).all + end + def find_all_hot_bid sort_bid_by_hot end diff --git a/app/views/projects/course.html.erb b/app/views/projects/course.html.erb index 1359b8bea..98228c168 100644 --- a/app/views/projects/course.html.erb +++ b/app/views/projects/course.html.erb @@ -30,7 +30,7 @@ <% end %> -<%= sort_course(@s_type, @project_type)%> +<%= sort_course(@s_type, @project_type, @school_id)%>
<%= render_project_hierarchy(@projects)%> diff --git a/app/views/welcome/course.html.erb b/app/views/welcome/course.html.erb index 286ff60d3..005f53710 100644 --- a/app/views/welcome/course.html.erb +++ b/app/views/welcome/course.html.erb @@ -1,197 +1,204 @@ <%= stylesheet_link_tag 'welcome' %> <%= javascript_include_tag 'welcome' %>
- -
-
- <%= image_tag(@logoLink, size:'75x75') %> + +
+
+ <%= image_tag(@logoLink, size:'75x75') %> -
-
-
+
+
+
<% if params[:school_id].nil? and User.current.user_extensions.school.nil? %> - <% else%> + <% else%> <% if params[:school_id] == "0" %> - <% else %> + <% else %> <% if params[:school_id].nil? %> <%= link_to School.find(User.current.user_extensions.school.id).name, options={:action => 'course',:school_id => User.current.user_extensions.school.id}, html_options={:class => 'font_welcome_school',:method => 'get'}%> -
+
<% else %> <%= link_to School.find(params[:school_id]).name ,options={:action => 'course',:school_id => params[:school_id]}, html_options={:class => 'font_welcome_school',:method => 'get'}%> -
+
<% end %> <% end %> <% end %>
- <%= l(:label_welcome_trustie) %><%= l(:label_welcome_trustie_course) %> - <% if params[:school_id].nil? and User.current.user_extensions.school.nil? %> - , <%= l(:label_welcome_trustie_course_description) %> - <% else %> - <% if params[:school_id] == "0" %> - , <%= l(:label_welcome_trustie_course_description) %> - <% end %> - <% end %> -
- -
-
+ <%= l(:label_welcome_trustie) %><%= l(:label_welcome_trustie_course) %> + <% if params[:school_id].nil? and User.current.user_extensions.school.nil? %> + , <%= l(:label_welcome_trustie_course_description) %> + <% else %> + <% if params[:school_id] == "0" %> + , <%= l(:label_welcome_trustie_course_description) %> + <% end %> + <% end %> +
+ +
+
-
+
-

新开课程

- <%= link_to "更多>>", {:controller => 'projects', :action => 'course', :project_type => 1, :school_id => params[:school_id]} %> -
-
    - -
+

新开课程

+ <% if(find_miracle_course(10, 7,params[:school_id]).map.count == 0) %> + <%= link_to "更多>>", {:controller => 'projects', :action => 'course', :project_type => 1, :school_id => nil} %> +
+
    -
      - <% if(find_miracle_course(10, 7,params[:school_id]).map.count == 0) %> -

      -

      - 该学校未开设任何课程,您可以查看其他学校课程 -

      -

      - <% find_all_hot_course(9).map do |project| %> -
    • > -
      - <%= image_tag(get_course_avatar(project), :class => "avatar-4") %> -
      - -
      - [<%= get_course_term project %>] - <%= link_to( project.name, project_path(project.id), :class => "d-g-blue d-p-project-name",:title => "#{project.name}" )%> - (<%= link_to "#{studentCount(project)}人", project_member_path(project, :role => 2) ,:course =>'1' %>) - <% files_count = (project.attachments.count.to_i+Version.joins(:project).where("projects.id=#{project.id}").count.to_i).to_s %> - (<%=link_to "#{files_count}份", project_files_path(project) %>资料) -
      -
      - - <% course = Course.find_by_extra(project.identifier)%> - <% if(course.school == nil) %> -               - <% else %> - <%= course.school.name.try(:gsub, /(.+)$/, '\1:') %> - <% end %> - - - <%= link_to(course.try(:teacher).try(:name), user_path(course.teacher)) %> - <%#=course.try(:teacher).try(:name)%> - -
      - - -
    • - <% end %> - <% else %> - <% find_miracle_course(10, 7,params[:school_id]).map do |project| %> -
    • > -
      - <%= image_tag(get_course_avatar(project), :class => "avatar-4") %> -
      - -
      - [<%= get_course_term project %>] - <%= link_to( project.name, project_path(project.id), :class => "d-g-blue d-p-project-name",:title => "#{project.name}" )%> - (<%= link_to "#{studentCount(project)}人", project_member_path(project, :role => 2) ,:course =>'1' %>) - <% files_count = (project.attachments.count.to_i+Version.joins(:project).where("projects.id=#{project.id}").count.to_i).to_s %> - (<%=link_to "#{files_count}份", project_files_path(project) %>资料) -
      -
      - - <% course = Course.find_by_extra(project.identifier) %> - <%= course.school.name.try(:gsub, /(.+)$/, '\1:') %> - - - <%= link_to(course.try(:teacher).try(:name), user_path(course.teacher)) %> +
    +
      +

      +

      + 该学校未开设任何课程,您可以查看其他学校课程 +

      +

      + <% find_all_new_hot_course(9).map do |project| %> +
    • > +
      + <%= image_tag(get_course_avatar(project), :class => "avatar-4") %> +
      + +
      + + <% course = Course.find_by_extra(project.identifier)%> + <% if(course.school == nil) %> +               + <% else %> + <%= course.school.name.try(:gsub, /(.+)$/, '\1:') %> + <% end %> + + + <%= link_to(course.try(:teacher).try(:name), user_path(course.teacher)) %> <%#=course.try(:teacher).try(:name)%> - -
      - - -
    • - <% end; reset_cycle %> + +
+
+ [<%= get_course_term project %>] + <%= link_to( project.name, project_path(project.id), :class => "d-g-blue d-p-project-name",:title => "#{project.name}" )%> + (<%= link_to "#{studentCount(project)}人", project_member_path(project, :role => 2) ,:course =>'1' %>) + <% files_count = (project.attachments.count.to_i+Version.joins(:project).where("projects.id=#{project.id}").count.to_i).to_s %> + (<%=link_to "#{files_count}份", project_files_path(project) %>资料) +
+ +
+ <% if !course_endTime_timeout?(project)%> +
+ <%= new_watcher_link(project, User.current)%> +
+ <% end %> +
+ <% end %> - -
+ +
+ <% else %> + <%= link_to "更多>>", {:controller => 'projects', :action => 'course', :project_type => 1, :school_id => params[:school_id]} %> +
+ + +
+ <% end %>
-

- 问题和反馈动态 - <%= link_to "我要提问" , newbie_send_path, {:class => 'orangeButton idea_btn', :style => "color: #EEEEEE" }%> - <%= link_to "我要反馈" , suggestion_send_path, {:class => 'orangeButton idea_btn', :style => "color: #EEEEEE" }%> -

- <%= link_to "更多>>", forums_path %> -
- +
\ No newline at end of file From 75f584a6e25b2f69891ac07aaf0538d3829c40ee Mon Sep 17 00:00:00 2001 From: nwb Date: Tue, 13 May 2014 11:54:21 +0800 Subject: [PATCH 2/6] =?UTF-8?q?1.=E5=AE=8C=E6=88=90=E5=88=86=E7=B1=BB?= =?UTF-8?q?=E8=B5=84=E6=BA=90=E4=B8=8B=E8=BD=BD=E8=A7=86=E5=9B=BE=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=202.=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81=EF=BC=8C?= =?UTF-8?q?=E5=88=A0=E9=99=A4=E5=86=97=E4=BD=99=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/files_controller.rb | 21 +- app/controllers/school_controller.rb | 2 +- app/views/files/_show_all_attachment.html.erb | 61 +++ app/views/files/_show_by_attachtype.html.erb | 421 ------------------ app/views/files/_sort_by_attachtypel.html.erb | 57 +++ app/views/files/getattachtype.js.erb | 5 + app/views/files/index.html.erb | 149 +------ app/views/files/show_by_attachtype.html.erb | 421 ------------------ config/routes.rb | 9 +- 9 files changed, 157 insertions(+), 989 deletions(-) create mode 100644 app/views/files/_show_all_attachment.html.erb delete mode 100644 app/views/files/_show_by_attachtype.html.erb create mode 100644 app/views/files/_sort_by_attachtypel.html.erb create mode 100644 app/views/files/getattachtype.js.erb delete mode 100644 app/views/files/show_by_attachtype.html.erb diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb index c67310f6f..075a54f65 100644 --- a/app/controllers/files_controller.rb +++ b/app/controllers/files_controller.rb @@ -19,8 +19,8 @@ class FilesController < ApplicationController layout 'base_projects'#by young menu_item :files - before_filter :find_project_by_project_id - before_filter :authorize + before_filter :find_project_by_project_id#, :except => [:getattachtype] + before_filter :authorize, :except => [:getattachtype] helper :sort include SortHelper @@ -62,20 +62,21 @@ class FilesController < ApplicationController redirect_to project_files_path(@project) end - def showbyattachtype - sort_init 'created_on', 'desc' - sort_update 'created_on' => "#{Attachment.table_name}.created_on", + # 返回制定资源类型的资源列表 + def getattachtype + 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 = [ Project.includes(:attachments).reorder("#{Attachment.table_name}.created_on DESC").find(@project.id)] #modify by Long Jun @containers += @project.versions.includes(:attachments).reorder("#{Attachment.table_name}.created_on DESC").all.sort + + @attachtype = params[:type].to_i - if @project.project_type == 1 - render :layout => 'base_courses' - else - render :layout => !request.xhr? + respond_to do |format| + format.js end end end diff --git a/app/controllers/school_controller.rb b/app/controllers/school_controller.rb index b4f5b0468..b8fb7a6f6 100644 --- a/app/controllers/school_controller.rb +++ b/app/controllers/school_controller.rb @@ -23,7 +23,7 @@ class SchoolController < ApplicationController end end - + def upload_logo end diff --git a/app/views/files/_show_all_attachment.html.erb b/app/views/files/_show_all_attachment.html.erb new file mode 100644 index 000000000..c65f58cc5 --- /dev/null +++ b/app/views/files/_show_all_attachment.html.erb @@ -0,0 +1,61 @@ +<% delete_allowed = User.current.allowed_to?(:manage_files, @project) %> + diff --git a/app/views/files/_show_by_attachtype.html.erb b/app/views/files/_show_by_attachtype.html.erb deleted file mode 100644 index eedc90684..000000000 --- a/app/views/files/_show_by_attachtype.html.erb +++ /dev/null @@ -1,421 +0,0 @@ - -<%isCategoryBrowser=true%> -<% selAttachType =1%> -<% attachmenttypes = @project.attachmenttypes %> - - - -<%=(@project.project_type == 1) ? t(:label_user_course) : t(:label_project) %>资源共享区 - -
- <%#= 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('上传文件', new_project_file_path(@project), :class => 'icon m5p5 button_submit') 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) %> - - <% if attachmenttypes.any? %> - - <%= select_tag "attachment_browse", content_tag('option', '') +options_from_collection_for_select(attachmenttypes, "id", "typeName"), - :onchange=>"attachmenttypes_search(this.value)"%> - <% end %> - - - -
- -
-<%= 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) %> - -<%if !isCategoryBrowser%> -
- -
-<%else%> -
- -
-<%end%> -<% html_title(l(:label_attachment_plural)) -%> - - - -<%inited=false%> - \ No newline at end of file diff --git a/app/views/files/_sort_by_attachtypel.html.erb b/app/views/files/_sort_by_attachtypel.html.erb new file mode 100644 index 000000000..d07ed399c --- /dev/null +++ b/app/views/files/_sort_by_attachtypel.html.erb @@ -0,0 +1,57 @@ +<% selAttachType =@attachtype%> +<% delete_allowed = User.current.allowed_to?(:manage_files, @project) %> +
+