组织添加设为精品项目,热门课程
This commit is contained in:
parent
b1cb4e5f94
commit
27a9170318
|
@ -6,7 +6,7 @@ class OrgSubfieldsController < ApplicationController
|
|||
if OrgSubfield.where("organization_id=#{params[:organization_id]} and name=?",params[:name]).count == 0
|
||||
@res = true
|
||||
@organization = Organization.find(params[:organization_id])
|
||||
@subfield = OrgSubfield.create(:name => params[:name], :organization_id => params[:organization_id],:priority => @organization.org_subfields.order("priority").last.priority + 1)
|
||||
@subfield = OrgSubfield.create(:name => params[:name], :organization_id => params[:organization_id], :priority => @organization.org_subfields.order("priority").last.priority + 1)
|
||||
if !params[:sub_dir].blank?
|
||||
sql = "select subfield_subdomain_dirs.* from subfield_subdomain_dirs, org_subfields where subfield_subdomain_dirs.org_subfield_id = org_subfields.id "+
|
||||
"and org_subfields.organization_id=#{@organization.id} and subfield_subdomain_dirs.name='#{params[:sub_dir]}'"
|
||||
|
@ -15,15 +15,29 @@ class OrgSubfieldsController < ApplicationController
|
|||
end
|
||||
end
|
||||
@subfield.update_attributes(:field_type => params[:field_type])
|
||||
# 如果栏目是教师或学生,不参入类型的配置,默认定义为右三模式
|
||||
if params[:field_type] == "Comptec" || params[:field_type] == "Compstu"
|
||||
@subfield.update_attribute(:status, 6)
|
||||
end
|
||||
# admin配置的类型
|
||||
update_status_by_type(@subfield, params[:field_type])
|
||||
else
|
||||
@res = false
|
||||
end
|
||||
end
|
||||
|
||||
# status类型说明,详见SubField
|
||||
def update_status_by_type subfield, type
|
||||
case type
|
||||
when "Comptec"
|
||||
subfield.update_attribute(:status, 6)
|
||||
when "Compstu"
|
||||
subfield.update_attribute(:status, 7)
|
||||
when "Comppro"
|
||||
subfield.update_attribute(:status, 8)
|
||||
when "Compcou"
|
||||
subfield.update_attribute(:status, 9)
|
||||
when "Compact"
|
||||
subfield.update_attribute(:status, 10)
|
||||
end
|
||||
end
|
||||
|
||||
def show
|
||||
@flag = params[:flag] || false
|
||||
sort = ""
|
||||
|
|
|
@ -28,7 +28,8 @@ class OrganizationsController < ApplicationController
|
|||
helper :project_score
|
||||
helper :issues
|
||||
include UsersHelper
|
||||
before_filter :find_organization, :only => [:show, :members, :apply_subdomain, :select_org_layout, :teachers, :students]
|
||||
before_filter :find_organization, :only => [:show, :members, :apply_subdomain, :select_org_layout, :teachers, :students, :projects, :courses]
|
||||
before_filter :allow_as_admin, :only => [:students, :teachers, :projects, :courses, :acts]
|
||||
layout 'base_org'
|
||||
def index
|
||||
|
||||
|
@ -159,10 +160,6 @@ class OrganizationsController < ApplicationController
|
|||
end
|
||||
|
||||
def teachers
|
||||
unless User.current.admin?
|
||||
render_403
|
||||
return
|
||||
end
|
||||
q = params[:search].nil? ? "" : "#{params[:search].strip}"
|
||||
@field = params[:org_subfield_id].nil? ? OrgSubfield.where("organization_id =? and field_type =?", params[:id].to_i, "Comptec").first : OrgSubfield.find(params[:org_subfield_id])
|
||||
@type = params[:type]
|
||||
|
@ -187,10 +184,6 @@ class OrganizationsController < ApplicationController
|
|||
end
|
||||
|
||||
def students
|
||||
unless User.current.admin?
|
||||
render_403
|
||||
return
|
||||
end
|
||||
q = params[:search].nil? ? "" : "#{params[:search].strip}"
|
||||
@field = params[:org_subfield_id].nil? ? OrgSubfield.where("organization_id =? and field_type =?", params[:id].to_i, "Compstu").first : OrgSubfield.find(params[:org_subfield_id])
|
||||
@type = params[:type]
|
||||
|
@ -214,6 +207,56 @@ class OrganizationsController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
def atta_page_public container
|
||||
limit = 10
|
||||
@containers_count = container.count
|
||||
@atta_pages = Paginator.new @containers_count, limit, params['page'] || 1
|
||||
@offset ||= @atta_pages.offset
|
||||
@containers = paginateHelper container, limit
|
||||
respond_to do |format|
|
||||
format.html
|
||||
format.js
|
||||
end
|
||||
end
|
||||
|
||||
def projects
|
||||
q = params[:search].nil? ? "" : "#{params[:search].strip}"
|
||||
@field = params[:org_subfield_id].nil? ? OrgSubfield.where("organization_id =? and field_type =?", params[:id].to_i, "Comppro").first : OrgSubfield.find(params[:org_subfield_id])
|
||||
@type = params[:type]
|
||||
if @type.nil?
|
||||
@containers = Project.find_by_sql("SELECT * FROM `projects` where status = 1 and is_public = 1 and name like '%#{q}%' order by updated_on desc;")
|
||||
elsif @type == "famous"
|
||||
@containers = Project.find_by_sql("SELECT * FROM `projects` where status =1 and is_public = 1 and hot = 1 and name like '%#{q}%' order by updated_on desc;")
|
||||
end
|
||||
atta_page_public @containers
|
||||
end
|
||||
|
||||
def courses
|
||||
q = params[:search].nil? ? "" : "#{params[:search].strip}"
|
||||
@field = params[:org_subfield_id].nil? ? OrgSubfield.where("organization_id =? and field_type =?", params[:id].to_i, "Compstu").first : OrgSubfield.find(params[:org_subfield_id])
|
||||
@type = params[:type]
|
||||
if @type.nil?
|
||||
@containers = Course.find_by_sql("SELECT * FROM `courses` where is_delete = 0 and is_public = 1 and name like '%#{q}%' order by updated_at desc;")
|
||||
elsif @type == "famous"
|
||||
@containers = Course.find_by_sql("SELECT * FROM `courses` where is_delete = 0 and is_public = 1 and hot = 1 and name like '%#{q}%' order by updated_at desc;")
|
||||
end
|
||||
atta_page_public @containers
|
||||
end
|
||||
|
||||
def acts
|
||||
q = params[:search].nil? ? "" : "#{params[:search].strip}"
|
||||
@field = params[:org_subfield_id].nil? ? OrgSubfield.where("organization_id =? and field_type =?", params[:id].to_i, "Compstu").first : OrgSubfield.find(params[:org_subfield_id])
|
||||
@type = params[:type]
|
||||
if @type == "courses" || @type.nil?
|
||||
@org_students = User.find_by_sql("select u.*, ue.student_id, 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= 1 and concat(lastname,firstname,login) like '%#{q}%' order by course_count desc")
|
||||
elsif @type == "famous"
|
||||
@org_students = User.find_by_sql("select u.*, ue.student_id, 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= 1 and u.excellent_student =1 and concat(lastname,firstname,login) like '%#{q}%' order by course_count desc")
|
||||
end
|
||||
atta_page_public container @containers
|
||||
end
|
||||
|
||||
def searchmember_by_name members, name
|
||||
#searchPeopleByRoles(project, StudentRoles)
|
||||
mems = []
|
||||
|
@ -344,6 +387,13 @@ class OrganizationsController < ApplicationController
|
|||
@organization = Organization.find(params[:id])
|
||||
end
|
||||
|
||||
def allow_as_admin
|
||||
unless User.current.admin?
|
||||
render_403
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
def setting
|
||||
@organization = Organization.find(params[:id])
|
||||
|
||||
|
|
|
@ -175,6 +175,11 @@ module OrganizationsHelper
|
|||
end
|
||||
end
|
||||
|
||||
# 获取最新动态
|
||||
def get_latest_acts
|
||||
acts = UserActivity.find_by_sql("SELECT * FROM `user_activities` where act_type in ('HomeworkCommon', 'news', 'message', 'Issue') and (container_type = 'Course' or container_type = 'Project') order by created_at limit 10;")
|
||||
end
|
||||
|
||||
def org_teacher_resource_count user
|
||||
results = Attachment.find_by_sql("SELECT * FROM attachments where author_id = #{user.id};").count
|
||||
end
|
||||
|
|
|
@ -11,7 +11,7 @@ class OrgSubfield < ActiveRecord::Base
|
|||
acts_as_attachable
|
||||
after_create :create_board_sync
|
||||
after_destroy :update_priority
|
||||
# status 为栏目定制决定参数,1 左一 2 左二 3 左三 4 右一 5 右二 6 右三
|
||||
# status 为栏目定制决定参数,1 左一 2 左二 3 左三 4 右一 5 右二 6 右三 默认的 7 学霸 8 热门项目 9 精品课程 10 最新动态
|
||||
|
||||
# 创建资源栏目讨论区
|
||||
def create_board_sync
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
<% containers.each do |container| %>
|
||||
<div class="teacher-list-row">
|
||||
<div>
|
||||
<div class="teacher-avatar">
|
||||
<%= link_to image_tag(url_to_avatar(container), :width => "90", :height => "90"), container.class == Course ? course_path(container) : project_path(container) %>
|
||||
</div>
|
||||
<div class="fl">
|
||||
<div class="ml25 mb20"><span class="teacher-name"><%=link_to container.name, container.class == Course ? course_path(container) : project_path(container) %></span></div>
|
||||
<div class="teacher-social-block">
|
||||
<div class="block-num"><%= container.members.count %></div>
|
||||
<div class="block-title">成员</div>
|
||||
</div>
|
||||
<div class="block-slice"></div>
|
||||
<div class="teacher-social-block">
|
||||
<div class="block-num"><%= container.attachments.count %></div>
|
||||
<div class="block-title">资源</div>
|
||||
</div>
|
||||
</div>
|
||||
<a href="javascript:void(0);" class="fr teacher-select" onclick="admin_hide_org($(this),'<%= container.id %>');" id="hide_<%= container.id %>">
|
||||
<%= (container.class == Course ? container.is_excellent == 0 : container.hot ==0) ? "设为热门" : "取消设置" %></a>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<script>
|
||||
function hide(content, id){
|
||||
if (content.text() == '设为热门')
|
||||
$.ajax({
|
||||
url: "/organizations/set_excellent_teacher?user=" + id + "&type=student",
|
||||
type: "post"
|
||||
});
|
||||
else
|
||||
$.ajax({
|
||||
url: "/organizations/reset_excellent_teacher?user=" + id + "&type=student",
|
||||
type: "post"
|
||||
});
|
||||
}
|
||||
</script>
|
|
@ -9,4 +9,22 @@
|
|||
<input type="radio" id="orgStu" value="Compstu" name="field_type" />
|
||||
<label for="Comptec">学生</label>
|
||||
</li>
|
||||
<% end %>
|
||||
<% if allow_to_create?(@organization, "Comppro") %>
|
||||
<li class="fl mr15">
|
||||
<input type="radio" id="orgPro" value="Comppro" name="field_type" />
|
||||
<label for="Comppro">热门项目</label>
|
||||
</li>
|
||||
<% end %>
|
||||
<% if allow_to_create?(@organization, "Compcou") %>
|
||||
<li class="fl mr15">
|
||||
<input type="radio" id="orgCou" value="Compcou" name="field_type" />
|
||||
<label for="Compcou">精品课程</label>
|
||||
</li>
|
||||
<% end %>
|
||||
<% if allow_to_create?(@organization, "Compact") %>
|
||||
<li class="fl mr15">
|
||||
<input type="radio" id="orgAct" value="Compact" name="field_type" />
|
||||
<label for="Compact">最新动态</label>
|
||||
</li>
|
||||
<% end %>
|
|
@ -125,6 +125,22 @@
|
|||
<div class="homepageLeftMenuBlock">
|
||||
<%= link_to "#{field.name}", students_organization_path(organization, :org_subfield_id => field.id), :class => "homepageMenuText homepageMenuControl hidden", :onclick => "$('#homepageLeftMenuPost').slideToggle();" %>
|
||||
</div>
|
||||
<% elsif field.field_type == "Compstu" && User.current.admin? %>
|
||||
<div class="homepageLeftMenuBlock">
|
||||
<%= link_to "#{field.name}", students_organization_path(organization, :org_subfield_id => field.id), :class => "homepageMenuText homepageMenuControl hidden", :onclick => "$('#homepageLeftMenuPost').slideToggle();" %>
|
||||
</div>
|
||||
<% elsif field.field_type == "Comppro" && User.current.admin? %>
|
||||
<div class="homepageLeftMenuBlock">
|
||||
<%= link_to "#{field.name}", projects_organization_path(organization, :org_subfield_id => field.id), :class => "homepageMenuText homepageMenuControl hidden", :onclick => "$('#homepageLeftMenuPost').slideToggle();" %>
|
||||
</div>
|
||||
<% elsif field.field_type == "Compcou" && User.current.admin? %>
|
||||
<div class="homepageLeftMenuBlock">
|
||||
<%= link_to "#{field.name}", courses_organization_path(organization, :org_subfield_id => field.id), :class => "homepageMenuText homepageMenuControl hidden", :onclick => "$('#homepageLeftMenuPost').slideToggle();" %>
|
||||
</div>
|
||||
<% elsif field.field_type == "Compact" && User.current.admin? %>
|
||||
<div class="homepageLeftMenuBlock">
|
||||
<%= link_to "#{field.name}", acts_organization_path(organization, :org_subfield_id => field.id), :class => "homepageMenuText homepageMenuControl hidden", :onclick => "$('#homepageLeftMenuPost').slideToggle();" %>
|
||||
</div>
|
||||
<% elsif field.field_type == "Resource" %>
|
||||
<div class="homepageLeftMenuBlock">
|
||||
<% if !field.subfield_subdomain_dir.nil? %>
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
<div class="homepageRightBanner">
|
||||
<div class="f16 fontGrey3">
|
||||
<% if @type == "famous" %>
|
||||
精品课程
|
||||
<% else %>
|
||||
<%= @field.name %>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
<div class="resources mt10">
|
||||
<div class="function-row" id="org_student_search">
|
||||
<%= form_tag(url_for(:controller => 'organizations', :action => 'courses', :type => @type), :remote => true , :method => 'get', :id => 'resource_search_form') do %>
|
||||
<input type="text" name="search" placeholder="输入项目名进行搜索" class="teacher-list-search fl" />
|
||||
<%= submit_tag '', :class => 'homepageSearchIcon', :onfocus => 'this.blur();', :class => "teacher-search-icon fl" %>
|
||||
<!--<a href="javascript:void(0);" onclick='this.parent.submit();return false;' class="searchIcon"></a>-->
|
||||
<% end %>
|
||||
<div class="sn-font-grey fr">
|
||||
<%= link_to "精品课程", courses_organization_path(@organization, :type => "famous", :org_subfield_id => @field.id), :class => "fontGrey2" %>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
<div id="org_container_list">
|
||||
<%=render 'organizations/org_container', :containers => @containers %>
|
||||
</div>
|
||||
<div>
|
||||
<ul class="wlist" id="pages" style="margin-top: 15px;">
|
||||
<%= pagination_links_full @atta_pages, @containers_count, :per_page_links => false, :flag => true %>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
|
@ -0,0 +1,3 @@
|
|||
$("#org_container_list").html('<%= escape_javascript( render :partial => 'organizations/org_container', :locals => {:containers => @containers})%>');
|
||||
$("#pages").html('<%= pagination_links_full @atta_pages, @container_count, :per_page_links => false, :remote => @is_remote, :flag => true %>');
|
||||
$("#org_student_search").attr('href','<%= courses_organization_path(@organization, :type => @type) %>');
|
|
@ -0,0 +1,30 @@
|
|||
<div class="homepageRightBanner">
|
||||
<div class="f16 fontGrey3">
|
||||
<% if @type == "famous" %>
|
||||
热门项目
|
||||
<% else %>
|
||||
<%= @field.name %>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
<div class="resources mt10">
|
||||
<div class="function-row" id="org_student_search">
|
||||
<%= form_tag(url_for(:controller => 'organizations', :action => 'projects', :type => @type), :remote => true , :method => 'get', :id => 'resource_search_form') do %>
|
||||
<input type="text" name="search" placeholder="输入项目名进行搜索" class="teacher-list-search fl" />
|
||||
<%= submit_tag '', :class => 'homepageSearchIcon', :onfocus => 'this.blur();', :class => "teacher-search-icon fl" %>
|
||||
<!--<a href="javascript:void(0);" onclick='this.parent.submit();return false;' class="searchIcon"></a>-->
|
||||
<% end %>
|
||||
<div class="sn-font-grey fr">
|
||||
<%= link_to "热门项目", projects_organization_path(@organization, :type => "famous", :org_subfield_id => @field.id), :class => "fontGrey2" %>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
<div id="org_container_list">
|
||||
<%=render 'organizations/org_container', :containers => @containers %>
|
||||
</div>
|
||||
<div>
|
||||
<ul class="wlist" id="pages" style="margin-top: 15px;">
|
||||
<%= pagination_links_full @atta_pages, @containers_count, :per_page_links => false, :flag => true %>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
|
@ -0,0 +1,3 @@
|
|||
$("#org_container_list").html('<%= escape_javascript( render :partial => 'organizations/org_container', :locals => {:containers => @containers})%>');
|
||||
$("#pages").html('<%= pagination_links_full @atta_pages, @container_count, :per_page_links => false, :remote => @is_remote, :flag => true %>');
|
||||
$("#org_student_search").attr('href','<%= projects_organization_path(@organization, :type => @type) %>');
|
|
@ -78,6 +78,9 @@ RedmineApp::Application.routes.draw do
|
|||
get 'search_courses'
|
||||
get 'teachers'
|
||||
get 'students'
|
||||
get 'projects'
|
||||
get 'courses'
|
||||
get 'acts'
|
||||
post 'join_course_menu'
|
||||
post 'join_courses'
|
||||
get 'search_projects'
|
||||
|
@ -99,6 +102,8 @@ RedmineApp::Application.routes.draw do
|
|||
post 'reset_excellent_teacher'
|
||||
post 'reset_excellent_student'
|
||||
post 'agree_apply_subdomain'
|
||||
post 'update_field_by_admin'
|
||||
post 'reset_update_field_by_admin'
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
class AddHotToProject < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :projects, :hot, :integer, :default => false
|
||||
end
|
||||
end
|
|
@ -11,7 +11,7 @@
|
|||
#
|
||||
# It's strongly recommended to check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(:version => 20160531021244) do
|
||||
ActiveRecord::Schema.define(:version => 20160601073753) do
|
||||
|
||||
create_table "activities", :force => true do |t|
|
||||
t.integer "act_id", :null => false
|
||||
|
@ -1810,6 +1810,7 @@ ActiveRecord::Schema.define(:version => 20160531021244) do
|
|||
t.integer "journals_count", :default => 0
|
||||
t.integer "boards_reply_count", :default => 0
|
||||
t.integer "visits", :default => 0
|
||||
t.integer "hot", :default => 0
|
||||
end
|
||||
|
||||
add_index "projects", ["lft"], :name => "index_projects_on_lft"
|
||||
|
|
|
@ -108,4 +108,23 @@ function chooseTeacherType(org_id){
|
|||
}
|
||||
}
|
||||
lastSendType = sendType;
|
||||
}
|
||||
|
||||
//修改状态
|
||||
function admin_hide_org(content, id){
|
||||
if (content.text() == '设为热门')
|
||||
$.ajax({
|
||||
url: "/organizations/update_field_by_admin?user=" + id + "&type=project",
|
||||
type: "post"
|
||||
});
|
||||
else if (content.text() == '设为精品')
|
||||
$.ajax({
|
||||
url: "/organizations/update_field_by_admin?user=" + id + "&type=course",
|
||||
type: "post"
|
||||
});
|
||||
else if (content.text() == '取消设置')
|
||||
$.ajax({
|
||||
url: "/organizations/reset_update_field_by_admin?user=" + id + "&type=student",
|
||||
type: "post"
|
||||
});
|
||||
}
|
Loading…
Reference in New Issue