From 0feb1280fd0f2dcf1a0e866c4784f171390ec8f2 Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 13 May 2016 14:23:36 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E5=90=8D=E5=B8=88=E6=9B=B4=E5=A4=9A?= =?UTF-8?q?=E5=88=97=E8=A1=A8=20=E5=8F=8A=E7=9B=B8=E5=85=B3=E5=85=A5?= =?UTF-8?q?=E5=8F=A3=E8=B7=AF=E7=94=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/organizations_controller.rb | 7 +++++++ app/views/organizations/_org_subfield_rightM2.html.erb | 4 +++- app/views/organizations/_org_teachers_list.html.erb | 2 +- app/views/organizations/teachers.html.erb | 2 +- 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/app/controllers/organizations_controller.rb b/app/controllers/organizations_controller.rb index 98483bb64..4747469cf 100644 --- a/app/controllers/organizations_controller.rb +++ b/app/controllers/organizations_controller.rb @@ -159,6 +159,10 @@ class OrganizationsController < ApplicationController end def teachers + unless @organization.allow_set_teachers + render_403 + return + end q = params[:search].nil? ? "" : "#{params[:search].strip}" if params[:type] == "courses" || params[:type].nil? @org_teachers = User.find_by_sql("select u.*, ue.technical_title, ue.school_id,(select count(*) from courses where courses.tea_id = u.id) as course_count @@ -169,6 +173,9 @@ class OrganizationsController < ApplicationController elsif params[:type] == "resources" @org_teachers = User.find_by_sql("select u.*, ue.technical_title, ue.school_id,(select count(*) from attachments where attachments.author_id = u.id) as course_count from users u, user_extensions ue where u.id = ue.user_id and ue.identity=0 and concat(lastname,firstname,login) like '%#{q}%' order by course_count desc") + elsif params[:type] == "famous" + @org_teachers = User.find_by_sql("select u.*, ue.technical_title, ue.school_id,(select count(*) from courses where courses.tea_id = u.id) as course_count + from users u, user_extensions ue where u.id = ue.user_id and ue.identity=0 and u.excellent_teacher =1 and concat(lastname,firstname,login) like '%#{q}%' order by course_count desc") end limit = 10 # @is_remote = true diff --git a/app/views/organizations/_org_subfield_rightM2.html.erb b/app/views/organizations/_org_subfield_rightM2.html.erb index 567df26d9..17a485583 100644 --- a/app/views/organizations/_org_subfield_rightM2.html.erb +++ b/app/views/organizations/_org_subfield_rightM2.html.erb @@ -1,5 +1,7 @@
-

名师风采更多

+

<%= field.name %> + <%= link_to "更多", teachers_organization_path(@organization, :type => "famous"), :target => "_blank", :class => "more" %> +

<% excellent_teachers.each do |teacher| %>
<%= link_to image_tag(url_to_avatar(teacher), :width => "60", :height => "60", :class => "sn-fl", :style => "display:block;"), user_path(teacher), :alt => "用户头像", :target => '_blank' %> diff --git a/app/views/organizations/_org_teachers_list.html.erb b/app/views/organizations/_org_teachers_list.html.erb index 3f8f5af8e..e24f53862 100644 --- a/app/views/organizations/_org_teachers_list.html.erb +++ b/app/views/organizations/_org_teachers_list.html.erb @@ -19,7 +19,7 @@
-
<%= org_teacher.my_students %>500
+
<%= org_teacher.my_students %>
学生数
diff --git a/app/views/organizations/teachers.html.erb b/app/views/organizations/teachers.html.erb index 35ba9c8fd..54a869221 100644 --- a/app/views/organizations/teachers.html.erb +++ b/app/views/organizations/teachers.html.erb @@ -15,7 +15,7 @@
- <%= link_to "名师列表", teachers_organization_path(@organization), :class => "fontGrey" %> + <%= link_to "名师列表", teachers_organization_path(@organization, :type => "famous"), :class => "fontGrey" %>
From 660cf7ef73d704aa81512d0c0c036b089beb177c Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 13 May 2016 14:52:33 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E5=90=8D=E5=B8=88=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E5=B1=80=E9=83=A8=E6=90=9C=E7=B4=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/organizations_controller.rb | 9 +++++---- app/views/organizations/_org_teachers_list.html.erb | 2 +- app/views/organizations/teachers.html.erb | 4 ++-- app/views/organizations/teachers.js.erb | 5 +++-- 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/app/controllers/organizations_controller.rb b/app/controllers/organizations_controller.rb index 4747469cf..b48488fb8 100644 --- a/app/controllers/organizations_controller.rb +++ b/app/controllers/organizations_controller.rb @@ -164,16 +164,17 @@ class OrganizationsController < ApplicationController return end q = params[:search].nil? ? "" : "#{params[:search].strip}" - if params[:type] == "courses" || params[:type].nil? + @type = params[:type] + if @type == "courses" || @type.nil? @org_teachers = User.find_by_sql("select u.*, ue.technical_title, ue.school_id,(select count(*) from courses where courses.tea_id = u.id) as course_count from users u, user_extensions ue where u.id = ue.user_id and ue.identity=0 and concat(lastname,firstname,login) like '%#{q}%' order by course_count desc") - elsif params[:type] == "students" + elsif @type == "students" @org_teachers = User.find_by_sql("select u.*, ue.technical_title, ue.school_id,(select count(*) from courses where courses.tea_id = u.id) as course_count from users u, user_extensions ue where u.id = ue.user_id and ue.identity=0 and concat(lastname,firstname,login) like '%#{q}%' order by course_count desc") - elsif params[:type] == "resources" + elsif @type == "resources" @org_teachers = User.find_by_sql("select u.*, ue.technical_title, ue.school_id,(select count(*) from attachments where attachments.author_id = u.id) as course_count from users u, user_extensions ue where u.id = ue.user_id and ue.identity=0 and concat(lastname,firstname,login) like '%#{q}%' order by course_count desc") - elsif params[:type] == "famous" + elsif @type == "famous" @org_teachers = User.find_by_sql("select u.*, ue.technical_title, ue.school_id,(select count(*) from courses where courses.tea_id = u.id) as course_count from users u, user_extensions ue where u.id = ue.user_id and ue.identity=0 and u.excellent_teacher =1 and concat(lastname,firstname,login) like '%#{q}%' order by course_count desc") end diff --git a/app/views/organizations/_org_teachers_list.html.erb b/app/views/organizations/_org_teachers_list.html.erb index e24f53862..702675464 100644 --- a/app/views/organizations/_org_teachers_list.html.erb +++ b/app/views/organizations/_org_teachers_list.html.erb @@ -1,4 +1,4 @@ -<% @org_teachers.each do |org_teacher| %> +<% org_teachers.each do |org_teacher| %> <% school = School.where("id =?", org_teacher.school_id).first %>
diff --git a/app/views/organizations/teachers.html.erb b/app/views/organizations/teachers.html.erb index 42dac9070..b3e311ade 100644 --- a/app/views/organizations/teachers.html.erb +++ b/app/views/organizations/teachers.html.erb @@ -1,6 +1,6 @@
-
- <%= form_tag( url_for(:controller => 'organizations', :action => 'teachers'), +
-
<%= org_teacher.try(:realname).nil? ? org_teacher.try(:login) : org_teacher.try(:realname) %> +
<%=link_to org_teacher.try(:realname).nil? ? org_teacher.try(:login) : org_teacher.try(:realname), user_url_in_org(org_teacher) %> <% unless school.nil? %> <%= school.name %> <% end %> @@ -28,12 +28,15 @@
资源数
- <% if User.current.admin? %> + <% if User.current.admin_of_org?(@organization) %> <%= org_teacher.excellent_teacher==0?"设为名师":"取消设置" %> <% else %> - <%= render :partial => 'layouts/user_watch_btn', :locals => {:target => org_teacher} %> - 关注 + + + + + <% end %>