diff --git a/Gemfile b/Gemfile index 6e8a4dcdf..1c1edfd35 100644 --- a/Gemfile +++ b/Gemfile @@ -50,10 +50,10 @@ gem 'elasticsearch-model' gem 'elasticsearch-rails' #rails 3.2.22.2 bug -gem "test-unit", "~>3.0" +gem "test-unit", "~>3.0" ### profile -# gem 'oneapm_rpm' +gem 'oneapm_rpm' group :development do gem 'grape-swagger' diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb index 397235f4b..935ca1d71 100644 --- a/app/controllers/admin_controller.rb +++ b/app/controllers/admin_controller.rb @@ -154,6 +154,19 @@ class AdminController < ApplicationController end end + # 单位名称列表下的已审批按照名字排序 + def apply_shcool_sort + @order = "" + @sort = "" + if params[:sort] && (params[:order] == 'name') + # courses = School.find_by_sql("SELECT c.*,count(c.id) FROM courses c,course_activities ca WHERE c.id = ca.course_id AND c.name like '%#{name}%' GROUP BY c.id ORDER BY count(c.id) #{params[:sort]}, c.id desc") + school = School.find_by_sql(" SELECT aas.name FROM apply_add_schools aas where aas.status = '0' ORDER BY CONVERT(aas.name USING gbk) #{params[:sort]}, aas.id asc ") + @order = params[:order] + @sort = params[:sort] + end + redirect_to unapplied_schools_url + end + #精品课程下的全部课程 def excellent_all_courses name = params[:name] @@ -602,8 +615,10 @@ class AdminController < ApplicationController # 获取申请的高校列表 # status: 0 未审批; 1 已批阅; def applied_schools - @name = params[:name] - @apply_status = ApplyAddSchools.where(:status => 0).order('created_at desc') + @name = params[:name] || "" + condition = "#{@name.strip}".gsub(" ","") + + @apply_status = ApplyAddSchools.where("status = 0 and name like '%#{condition}%'").order('created_at desc') @apply_count = @apply_status.count @apply_pages = Paginator.new @apply_count, 30, params['page'] || 1 @@ -616,8 +631,10 @@ class AdminController < ApplicationController end def has_applied_schools - @name = params[:name] - @has_apply_status = ApplyAddSchools.where("status = 1 or status = 2").order('created_at desc') + @name = params[:name] || "" + condition = "#{@name.strip}".gsub(" ","") + + @has_apply_status = ApplyAddSchools.where("(status = 1 or status = 2) and name like '%#{condition}%'").order('created_at desc') @has_apply_count = @has_apply_status.count @has_apply_pages = Paginator.new @has_apply_count, 30, params['page'] || 1 @@ -700,8 +717,10 @@ class AdminController < ApplicationController user.update_column("school_id", nil) end applied_school.school.destroy - respond_to do |format| - format.html{ redirect_to unapplied_schools_url } + if params[:tip] == "unapplied" + redirect_to unapplied_schools_url + elsif params[:tip] == "applied" + redirect_to applied_schools_url end end diff --git a/app/controllers/applied_project_controller.rb b/app/controllers/applied_project_controller.rb index d779c7759..883fd1c68 100644 --- a/app/controllers/applied_project_controller.rb +++ b/app/controllers/applied_project_controller.rb @@ -59,12 +59,14 @@ class AppliedProjectController < ApplicationController @flag = 2 elsif params[:member].nil? @flag = 3 + elsif !AppliedProject.where(:project_id => @project.id, :user_id => User.current.id).first.nil? + @flag = 5 else @flag = 4 - role = params[:member] == "member_manager" ? 3 : (params[:member] = "member_developer" ? 4 :5) + role = params[:member] == "member_manager" ? 3 : (params[:member] == "member_developer" ? 4 :5) applied_project = AppliedProject.create(:user_id => User.current.id, :project_id => @project.id, :role => role) # 申请成功则给项目管理员发送邮件及发送消息 - Mailer.run.applied_project(applied_project) + # Mailer.run.applied_project(applied_project) end end diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index f135c8ab2..5dcf493ee 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -792,6 +792,11 @@ class ProjectsController < ApplicationController members = Member.where(:user_id => User.current.id, :project_id=>params[:id]).first if members != nil && members.roles.first.to_s != "Manager" members.destroy + # 移出的时候删除申请消息,不需要删除消息,所以不必要关联删除 + applied_projects = AppliedProject.where(:project_id => @project.id, :user_id => members.user_id).first + unless applied_projects.nil? + applied_projects.delete + end end respond_to do |format| format.js diff --git a/app/controllers/school_controller.rb b/app/controllers/school_controller.rb index dd3169905..76d149f94 100644 --- a/app/controllers/school_controller.rb +++ b/app/controllers/school_controller.rb @@ -184,6 +184,15 @@ class SchoolController < ApplicationController applyschool.user_id = User.current.id if applyschool.save data[:school_id] = school.id + user_extention= User.current.extensions + user_extention.school_id = school.id + user_extention.save! + + # status=4 向管理员发送信息 + users = User.where(:admin => 1) + users.each do |user| + AppliedMessage.create(:user_id => user.id, :status => 4, :applied_user_id => User.current.id, :viewed => true, :applied_id => school.id, :applied_type => "ApplyAddSchools", :name => school.name ) + end else data[:result] = 3 end @@ -207,4 +216,69 @@ class SchoolController < ApplicationController render :json =>status end + + def edit_apply_name + name = params[:name] || "" + status = -1 + + if name != "" + applyschool = ApplyAddSchools.where("id=?",params[:id]).first + + applyschool.name = name.strip + + if applyschool.school + applyschool.school.name = name + applyschool.school.pinyin = Pinyin.t(name.strip, splitter: '') + applyschool.school.save! + end + applyschool.save! + status = 0 + end + + render :json=>{:status=>status,:id=>params[:id],:name=>name} + end + + def edit_apply_address + address = params[:address] || "" + + status = -1 + + if address != "" + applyschool = ApplyAddSchools.where("id=?",params[:id]).first + applyschool.address = address + applyschool.save! + status = 0 + end + + render :json=>{:status=>status,:id=>params[:id],:address=>address} + end + + def edit_apply_province + province = params[:province] || "" + city = params[:city] || "" + status = -1 + + if(province != "") &&(city != "") + applyschool = ApplyAddSchools.where("id=?",params[:id]).first + applyschool.province = province + applyschool.city = city + + if applyschool.school + applyschool.school.province = province + applyschool.school.save! + end + applyschool.save! + + if applyschool.user_id && applyschool.user_id != 0 + user = User.find(applyschool.user_id) + user_extention= user.extensions + user_extention.location = province + user_extention.location_city = city + user_extention.save! + end + status = 0 + end + + render :json=>{:status=>status,:id=>params[:id],:province=>province,:city=>city} + end end diff --git a/app/models/applied_message.rb b/app/models/applied_message.rb index ee22f21c8..cbba74f95 100644 --- a/app/models/applied_message.rb +++ b/app/models/applied_message.rb @@ -1,6 +1,7 @@ class AppliedMessage < ActiveRecord::Base # status: 0表示未批准; status:1表示已批准; status: 2表示已拒绝 - attr_accessible :applied_id, :applied_type, :status, :user_id, :viewed, :applied_user_id, :role, :project_id + + attr_accessible :applied_id, :applied_type, :status, :user_id, :viewed, :applied_user_id, :role, :project_id, :name belongs_to :applied ,:polymorphic => true belongs_to :apply_add_schools belongs_to :user diff --git a/app/models/user.rb b/app/models/user.rb index 0ce0e25a0..a4b7f3b25 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -42,12 +42,12 @@ class User < Principal # Different ways of displaying/sorting users USER_FORMATS = { :firstname_lastname => { - :string => '#{firstname} #{lastname}', + :string => '#{firstname}#{lastname}', :order => %w(firstname lastname id), :setting_order => 1 }, :firstname_lastinitial => { - :string => '#{firstname} #{lastname.to_s.chars.first}.', + :string => '#{firstname}#{lastname.to_s.chars.first}.', :order => %w(firstname lastname id), :setting_order => 2 }, @@ -57,7 +57,7 @@ class User < Principal :setting_order => 3 }, :lastname_firstname => { - :string => '#{lastname} #{firstname}', + :string => '#{lastname}#{firstname}', :order => %w(lastname firstname id), :setting_order => 4 }, diff --git a/app/services/courses_service.rb b/app/services/courses_service.rb index f60021e71..ce3157d5f 100644 --- a/app/services/courses_service.rb +++ b/app/services/courses_service.rb @@ -399,6 +399,8 @@ class CoursesService if course if course_endTime_timeout? course @state = 2 + elsif course[:is_delete] == 1 + @state = 11 else if current_user.member_of_course?(course) #如果已经是成员 @state = 3 diff --git a/app/views/admin/_all_schools.html.erb b/app/views/admin/_all_schools.html.erb index 0ecb38544..d4cf916f5 100644 --- a/app/views/admin/_all_schools.html.erb +++ b/app/views/admin/_all_schools.html.erb @@ -1,5 +1,4 @@ <%= stylesheet_link_tag 'css/common','css/popup' %> -
更改为
@@ -16,7 +15,7 @@ function school_submit() { var checkboxs = $("input[name='school_id[]']:checked"); if(checkboxs.length == 0) { - $("#choose_courses_notice").text("请先选择班级"); + $("#choose_courses_notice").text("请选择单位"); } else{ $("#choose_courses_notice").text(""); $("#schools_list_form").submit(); diff --git a/app/views/admin/_courselist_detail_tr.html.erb b/app/views/admin/_courselist_detail_tr.html.erb index 83b7904ce..6bec90845 100644 --- a/app/views/admin/_courselist_detail_tr.html.erb +++ b/app/views/admin/_courselist_detail_tr.html.erb @@ -7,7 +7,7 @@ - <%= link_to(course.teacher.show_name.truncate(6, omission: '...'), user_path(course.teacher)) %> + <%= link_to(course.teacher.show_name, user_path(course.teacher)) %> <%= course.class_period %> diff --git a/app/views/admin/applied_schools.html.erb b/app/views/admin/applied_schools.html.erb index 4f48897ce..2f139ca72 100644 --- a/app/views/admin/applied_schools.html.erb +++ b/app/views/admin/applied_schools.html.erb @@ -23,8 +23,11 @@ 序号 - - 单位名称 + + <%= link_to '单位名称', apply_shcool_sort_path(:sort=> @sort == "desc" ? 'asc' : 'desc', :order => 'name', :tip=>'unapplied') %> + + + 申请者 地区 @@ -46,18 +49,66 @@ <% @apply_status.each do |apply| %> <% if apply.status == 0 %> - "> + "> <%= apply.id %> - - <%= apply.name %> + + <%= apply.name %> + + + + <% user = User.where("id=?", apply.user_id).first %> + <% unless user.nil? %> + <%=link_to user.show_name, user_path(user),:target => '_blank' %> + <% end %> - <%= apply.province + apply.city %> + + <%= (apply.province.nil? ? "" : apply.province) + (apply.city.nil? ? "" : apply.city) %> + + + - - <%= apply.address %> + + <%= apply.address %> + <% count = UserExtensions.where("school_id = #{apply.school_id}").count %> @@ -67,13 +118,16 @@ <%= format_date(apply.created_at) %> - <%= link_to( l(:label_approve), { :controller => 'admin', :action => 'approve_applied_schools', :id => apply.id }, :class => 'icon-del') %> - <%= link_to( l(:button_delete), { :controller => 'admin', :action => 'delete_applied_schools', :id => apply.id },:method => :delete, :confirm => l(:text_are_you_sure), :class => 'icon-del') %> - <%=link_to '更改', admin_all_schools_path(:school_id =>apply.id), :remote => true %> + <%= link_to( l(:label_approve), { :controller => 'admin', :action => 'approve_applied_schools', :id => apply.id }, :class => "application-default-link" ) %> + <%= link_to( l(:button_delete), { :controller => 'admin', :action => 'delete_applied_schools', :id => apply.id, :tip => 'unapplied' },:method => :delete, :confirm => l(:text_are_you_sure), :class => "application-default-link") %> + <%=link_to '更改', admin_all_schools_path(:school_id =>apply.id), :remote => true, :class => "application-default-link" %> - <% unless apply.remarks.empty? %> + + <% unless apply.remarks.blank? %> @@ -87,4 +141,7 @@ <% end %> -
\ No newline at end of file + + \ No newline at end of file diff --git a/app/views/admin/has_applied_schools.html.erb b/app/views/admin/has_applied_schools.html.erb index 07459fa0f..5be3517c8 100644 --- a/app/views/admin/has_applied_schools.html.erb +++ b/app/views/admin/has_applied_schools.html.erb @@ -23,10 +23,13 @@ 序号 - + 单位名称 - + + 申请者 + + 地区 @@ -35,7 +38,10 @@ 原名 - + + 用户 + + 创建时间 @@ -50,37 +56,88 @@ <%= apply.id %> - - <%= (School.find apply.school_id).name %> + + <% unless apply.school_id.nil? %> + <% school_name = School.where("id=?", apply.school_id).first %> + <%= school_name %> + + <% end %> - <%= (School.find apply.school_id).province %> + <% user = User.where("id=?", apply.user_id).first%> + <% unless user.nil? %> + <%=link_to user.show_name, user_path(user), :target => '_blank'%> + <% end %> - - <%= apply.address %> + + + <%= (apply.province.nil? ? "" : apply.province) + (apply.city.nil? ? "" : apply.city) %> + + + + + + <%= apply.address %> + <%= apply.name %> + + <% count = UserExtensions.where("school_id = #{apply.school_id}").count %> + <%= count %> + <%= format_date(apply.created_at) %> - <%= link_to( l(:button_delete), { :controller => 'admin', :action => 'delete_applied_schools', :id => apply.id },:method => :delete, :confirm => l(:text_are_you_sure), :class => 'icon-del') %> + <%= link_to( l(:button_delete), { :controller => 'admin', :action => 'delete_applied_schools', :id => apply.id, :tip => 'applied' },:method => :delete, :confirm => l(:text_are_you_sure) ) %> - <% unless apply.remarks.empty? %> - - - - - - <%= apply.remarks %> - - + <% end %> <% end %> - <% end %> - \ No newline at end of file + + \ No newline at end of file diff --git a/app/views/admin/non_syllabus_courses.html.erb b/app/views/admin/non_syllabus_courses.html.erb index 1be979eeb..c5a2c81ec 100644 --- a/app/views/admin/non_syllabus_courses.html.erb +++ b/app/views/admin/non_syllabus_courses.html.erb @@ -72,7 +72,7 @@ - <%= link_to(course.teacher.show_name.truncate(6, omission: '...'), user_path(course.teacher)) %> + <%= link_to(course.teacher.show_name, user_path(course.teacher)) %> <%= course.class_period %> diff --git a/app/views/admin/syllabuses.html.erb b/app/views/admin/syllabuses.html.erb index 194091abc..5098131da 100644 --- a/app/views/admin/syllabuses.html.erb +++ b/app/views/admin/syllabuses.html.erb @@ -52,7 +52,7 @@ - <%= link_to(syllabus.try(:user).try(:realname).truncate(6, omission: '...'), user_path(syllabus.user)) %> + <%= link_to syllabus.user.show_name, user_path(syllabus.user) %> <%= format_date(syllabus.created_at) %> @@ -70,7 +70,7 @@ <%= render :partial => 'admin/rename_course_name', :locals => {:course => course} %> - <%= link_to(course.try(:teacher).try(:realname).truncate(6, omission: '...'), user_path(course.teacher)) %> + <%= link_to(course.teacher.show_name, user_path(course.teacher)) %> <%= format_date(course.created_at) %> diff --git a/app/views/applied_project/_applied_join_project.html.erb b/app/views/applied_project/_applied_join_project.html.erb index 457cdf9cc..e2c447992 100644 --- a/app/views/applied_project/_applied_join_project.html.erb +++ b/app/views/applied_project/_applied_join_project.html.erb @@ -19,8 +19,8 @@
  • - -
    确  定
    + + 确  定 取  消
  • diff --git a/app/views/applied_project/_applied_project_tip.js.erb b/app/views/applied_project/_applied_project_tip.js.erb index 56e5270d6..c2bc555db 100644 --- a/app/views/applied_project/_applied_project_tip.js.erb +++ b/app/views/applied_project/_applied_project_tip.js.erb @@ -15,6 +15,8 @@

    请选择一个角色

    <% elsif @flag == 4 %>

    您的申请已提交,请等待项目管理员审批

    + <% elsif @flag == 5 %> +

    您已经申请加入该项目了,请耐心等待

    <% end %>
  • diff --git a/app/views/layouts/_course_base_info.html.erb b/app/views/layouts/_course_base_info.html.erb index 1a14d904c..1c01ecf53 100644 --- a/app/views/layouts/_course_base_info.html.erb +++ b/app/views/layouts/_course_base_info.html.erb @@ -3,8 +3,10 @@ <% student_num = studentCount(@course) %> <% course_file_num = visable_attachemnts_incourse(@course).count %>

    - <%=link_to @course.syllabus.title, syllabus_path(@course.syllabus_id), :class => 'sy_cgrey' %> -  >  + <% if @course.syllabus %> + <%=link_to @course.syllabus.title, syllabus_path(@course.syllabus_id), :class => 'sy_cgrey' %> +  >  + <% end %> <%=link_to @course.name, course_path(@course), :class => 'sy_cgrey' %>

    @@ -61,9 +63,9 @@ <% is_TE = get_user_member_roles_course @course, User.current, 9 %> <% is_ST = get_user_member_roles_course @course, User.current, 10 %> <% if !is_teacher && (is_TA || is_TE) %> - <%= link_to '教师身份', switch_role_course_path(@course, :user_id => User.current.id, :curr_role => 10, :tar_role => (is_TA ? 7 : 9)), :class => "sy_btn_orange mr10 fl" %> + <%= link_to '教师身份', switch_role_course_path(@course, :user_id => User.current.id, :curr_role => 10, :tar_role => (is_TA ? 7 : 9)), :class => "sy_btn_orange mr10 fl", :title => "由学生身份切换至教师身份" %> <% elsif is_teacher && is_ST %> - <%= link_to '学生身份', switch_role_course_path(@course, :user_id => User.current.id, :curr_role => (is_TA ? 7 : 9), :tar_role => 10), :class => "sy_btn_orange mr10 fl" %> + <%= link_to '学生身份', switch_role_course_path(@course, :user_id => User.current.id, :curr_role => (is_TA ? 7 : 9), :tar_role => 10), :class => "sy_btn_orange mr10 fl", :title => "由教师身份切换至学生身份" %> <% end %> <% unless (is_teacher || is_TA || is_TE) %>
    <%= join_in_course_header(@course, User.current) %>
    diff --git a/app/views/layouts/base_admin.html.erb b/app/views/layouts/base_admin.html.erb index 81cc2df9d..7f62da514 100644 --- a/app/views/layouts/base_admin.html.erb +++ b/app/views/layouts/base_admin.html.erb @@ -62,3 +62,10 @@ <%= call_hook :view_layouts_base_body_bottom %> + + diff --git a/app/views/my/account.html.erb b/app/views/my/account.html.erb index f35d47079..46e8e015a 100644 --- a/app/views/my/account.html.erb +++ b/app/views/my/account.html.erb @@ -369,7 +369,7 @@ function apply_add_school(){ var htmlvalue = "<%= escape_javascript( render :partial => 'my/apply_add_school' )%>"; pop_up_box(htmlvalue,580,20,48); - + $("#schoolname").val($("input[name='province']").val()); } function add_school(name){ $.ajax({ diff --git a/app/views/users/_courses_list.html.erb b/app/views/users/_courses_list.html.erb index 1abe77b81..83b9ab56b 100644 --- a/app/views/users/_courses_list.html.erb +++ b/app/views/users/_courses_list.html.erb @@ -13,7 +13,7 @@

    更新:<%=format_date Time.at(course.updatetime) %>学期:<%=current_time_and_term(course) %>

    -

    <%=studentCount course %>学生|<%=visable_course_homework course %>作业|<%=visable_attachemnts_incourse(@course).count %>资源

    +

    <%=studentCount course %>学生|<%=visable_course_homework course %>作业|<%=visable_attachemnts_incourse(course).count %>资源

    diff --git a/app/views/users/_join_course_course_message.html.erb b/app/views/users/_join_course_course_message.html.erb index cecbe2755..79f1f6e67 100644 --- a/app/views/users/_join_course_course_message.html.erb +++ b/app/views/users/_join_course_course_message.html.erb @@ -5,7 +5,7 @@
  • - <%= link_to User.find(ma.course_message_id).name+"申请成为课程\""+"#{Course.find(ma.course_id).name}"+"\"的"+"#{ma.content.include?('9') ? "教师" : "教辅"}", user_path(User.find(ma.course_message_id), :course_id => ma.course_id), + <%= link_to User.find(ma.course_message_id).name+"申请成为课程\""+"#{Course.find(ma.course_id).name}"+"\"的"+"#{ma.content && ma.content.include?('9') ? "教师" : "教辅"}", user_path(User.find(ma.course_message_id), :course_id => ma.course_id), :class => "#{ma.viewed==0 ? "newsBlack" : "newsGrey"}", :target => '_blank' %> @@ -18,14 +18,14 @@

    真实姓名:<%= User.find(ma.course_message_id).realname %>

    申请课程:<%= Course.find(ma.course_id).name%>

    课程描述:
    -
    <%= Course.find(ma.course_id).description.html_safe if Course.find(ma.course_id).description %>

    申请职位:<%= ma.content.include?('9') ? "教师" : "教辅"%>

    +
    <%= Course.find(ma.course_id).description.html_safe if Course.find(ma.course_id).description %>

    申请职位:<%=ma.content && ma.content.include?('9') ? "教师" : "教辅"%>

  • <% if ma.status == 0 || ma.status.nil?%> - <%= link_to '同意',dealwith_apply_request_user_path(User.current,:agree=>'Y',:msg_id=>ma.id),:remote=>'true'%> + <%= link_to '同意',dealwith_apply_request_user_path(User.current,:agree=>'Y',:msg_id=>ma.id),:remote=>'true',:class=>'linkBlue'%> | - <%= link_to '拒绝',dealwith_apply_request_user_path(User.current,:agree=>'N',:msg_id=>ma.id),:remote=>'true'%> + <%= link_to '拒绝',dealwith_apply_request_user_path(User.current,:agree=>'N',:msg_id=>ma.id),:remote=>'true',:class=>'linkBlue'%> <% elsif ma.status == 1%> 您已经同意了该申请 <% elsif ma.status == 2%> diff --git a/app/views/users/_user_message_applide_action.html.erb b/app/views/users/_user_message_applide_action.html.erb index fc56b9f22..48e479b22 100644 --- a/app/views/users/_user_message_applide_action.html.erb +++ b/app/views/users/_user_message_applide_action.html.erb @@ -1,5 +1,5 @@ <% if allow_to_show(ma) %> - :<%= link_to "同意", allow_to_join_project_project_memberships_path(:project_id => ma.project_id, :applied_message_id => ma.id), :remote => true, :method => :post, :class => "link-blue"%> | + <%= link_to "同意", allow_to_join_project_project_memberships_path(:project_id => ma.project_id, :applied_message_id => ma.id), :remote => true, :method => :post, :class => "link-blue"%> | <%= link_to "拒绝", refused_allow_to_join_project_project_memberships_path(:project_id => ma.project_id, :applied_message_id => ma.id), :remote => true, :method => :get, :class => "link-blue" %> <% elsif ma.status == 4 %> 被拒绝 diff --git a/app/views/users/_user_message_applied.html.erb b/app/views/users/_user_message_applied.html.erb index 6befe300e..e543f6cee 100644 --- a/app/views/users/_user_message_applied.html.erb +++ b/app/views/users/_user_message_applied.html.erb @@ -1,35 +1,51 @@ <% if ma.class == AppliedMessage %> <% if ma.applied_type == "ApplyAddSchools" %> + <% if ma.status == 1 || ma.status == 2 || ma.status == 3 || ma.status == 4 %> + <% end %> <% elsif ma && ma.applied_type == "AppliedProject" %>