From 430a93e4b2f6c19224c2c2f23051bd540c36cd0b Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Fri, 29 Jul 2016 20:48:36 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E5=8D=95=E4=BD=8D=E5=90=8D=E7=A7=B0?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E5=8A=9F=E8=83=BD=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/admin_controller.rb | 2 +- app/controllers/school_controller.rb | 6 ++++++ app/views/admin/_all_schools.html.erb | 1 - app/views/admin/applied_schools.html.erb | 10 ++++----- app/views/admin/has_applied_schools.html.erb | 21 ++++++++----------- app/views/layouts/base_admin.html.erb | 7 +++++++ .../users/_user_message_applied.html.erb | 10 ++++++++- config/locales/zh.yml | 2 +- public/stylesheets/application.css | 3 +++ 9 files changed, 41 insertions(+), 21 deletions(-) diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb index 1b95ef895..7602b10a5 100644 --- a/app/controllers/admin_controller.rb +++ b/app/controllers/admin_controller.rb @@ -160,7 +160,7 @@ class AdminController < ApplicationController @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' GROUP BY CONVERT(name USING gbk) #{params[:sort]}, aas.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 diff --git a/app/controllers/school_controller.rb b/app/controllers/school_controller.rb index ec585e2b2..b927b1108 100644 --- a/app/controllers/school_controller.rb +++ b/app/controllers/school_controller.rb @@ -187,6 +187,12 @@ class SchoolController < ApplicationController 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, :viewed => true, :applied_id => school.id, :applied_type => "ApplyAddSchools", :name => school.name ) + end else data[:result] = 3 end diff --git a/app/views/admin/_all_schools.html.erb b/app/views/admin/_all_schools.html.erb index af59d7687..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' %> -
更改为
diff --git a/app/views/admin/applied_schools.html.erb b/app/views/admin/applied_schools.html.erb index 32e67914f..507cb7c49 100644 --- a/app/views/admin/applied_schools.html.erb +++ b/app/views/admin/applied_schools.html.erb @@ -53,7 +53,7 @@ <%= apply.id %> - + <%= apply.name %> @@ -65,7 +65,7 @@ <%= (apply.province.nil? ? "" : apply.province) + (apply.city.nil? ? "" : apply.city) %> - + <%= apply.address %> @@ -76,9 +76,9 @@ <%= format_date(apply.created_at) %> - <%= link_to( l(:label_approve), { :controller => 'admin', :action => 'approve_applied_schools', :id => apply.id }) %> - <%= link_to( l(:button_delete), { :controller => 'admin', :action => 'delete_applied_schools', :id => apply.id, :tip => 'unapplied' },:method => :delete, :confirm => l(:text_are_you_sure)) %> - <%=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" %> diff --git a/app/views/admin/has_applied_schools.html.erb b/app/views/admin/has_applied_schools.html.erb index 11361dbac..555dce689 100644 --- a/app/views/admin/has_applied_schools.html.erb +++ b/app/views/admin/has_applied_schools.html.erb @@ -38,6 +38,9 @@ 原名 + + 用户 + 创建时间 @@ -53,7 +56,7 @@ <%= apply.id %> - + <% unless apply.school_id.nil? %> <% school_name = School.where("id=?", apply.school_id).first %> <%= school_name.name %> @@ -71,12 +74,16 @@ <%= school_province.province %> <% end %> - + <%= apply.address %> <%= apply.name %> + + <% count = UserExtensions.where("school_id = #{apply.school_id}").count %> + <%= count %> + <%= format_date(apply.created_at) %> @@ -84,16 +91,6 @@ <%= 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.blank? %> - - - - - - <%= apply.remarks %> - - - <% end %> <% end %> <% end %> 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/users/_user_message_applied.html.erb b/app/views/users/_user_message_applied.html.erb index 0a4924c27..d6815e988 100644 --- a/app/views/users/_user_message_applied.html.erb +++ b/app/views/users/_user_message_applied.html.erb @@ -27,7 +27,15 @@ <%= link_to ma.name + "的申请,因名称不合法,已被拒绝,请重新编辑您的基本资料", { :controller=> "my",:action => "account" } %>
  • <%= time_tag(ma.created_at).html_safe %>
  • - <% end %> + <% elsif ma.status == 4 %> + <%=link_to ma.user, user_path(ma.user), :class => "newsBlue homepageNewsPublisher", :target => '_blank' %> + "> +
  • + + <%= User.where("id=?", ma.user_id).first.login %>提交了申请:添加新的单位“<%= ma.name %>” +
  • +
  • <%= time_tag(ma.created_at).html_safe %>
  • + <% end %> <% end %> diff --git a/config/locales/zh.yml b/config/locales/zh.yml index df9c26895..1340e7aa6 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -388,7 +388,7 @@ zh: label_organization_name: 组织名称 label_organization_list: 组织列表 label_school_plural: 学校列表 - label_applied_shcools: 单位名称列表 + label_applied_shcools: 单位审核 label_organization_new: 新建组织 label_edit_organization: 编辑组织 label_organization_edit: 修改组织 diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css index 112f8224b..9031ed9d8 100644 --- a/public/stylesheets/application.css +++ b/public/stylesheets/application.css @@ -1281,6 +1281,9 @@ a, a:link, a:visited{ color: #169; text-decoration: none; } a:hover, a:active{ color: #c61a1a; text-decoration: underline;} a img{ border: 0; } +a.application-default-link {color: #169 !important; text-decoration: none;} +a.application-default-link:hover {color: #c61a1a !important; text-decoration: underline;} + a.issue.closed, a.issue.closed:link, a.issue.closed:visited { color: #999; text-decoration: line-through; } a.project.closed, a.project.closed:link, a.project.closed:visited { color: #999; } a.user.locked, a.user.locked:link, a.user.locked:visited {color: #999;} From 1f47eb5ea87cf162e24a5ef812a84f9ce3b46c3f Mon Sep 17 00:00:00 2001 From: yuanke <249218296@qq.com> Date: Fri, 29 Jul 2016 21:19:09 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E5=8D=95=E4=BD=8D=E7=94=B3=E8=AF=B7?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/school_controller.rb | 57 +++++++++ app/views/admin/applied_schools.html.erb | 51 +++++++- app/views/admin/has_applied_schools.html.erb | 2 +- config/routes.rb | 3 + public/javascripts/application.js | 121 +++++++++++++++++++ 5 files changed, 230 insertions(+), 4 deletions(-) diff --git a/app/controllers/school_controller.rb b/app/controllers/school_controller.rb index ec585e2b2..264f0ae1f 100644 --- a/app/controllers/school_controller.rb +++ b/app/controllers/school_controller.rb @@ -210,4 +210,61 @@ 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],:address=>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! + status = 0 + end + + render :json=>{:status=>status,:id=>params[:id],:province=>province,:city=>city} + end end diff --git a/app/views/admin/applied_schools.html.erb b/app/views/admin/applied_schools.html.erb index 32e67914f..319051d78 100644 --- a/app/views/admin/applied_schools.html.erb +++ b/app/views/admin/applied_schools.html.erb @@ -53,8 +53,9 @@ <%= apply.id %> - - <%= apply.name %> + + <%= apply.name %> + <% user = User.where("id=?", apply.user_id).first %> @@ -63,10 +64,51 @@ <% end %> + <%= (apply.province.nil? ? "" : apply.province) + (apply.city.nil? ? "" : apply.city) %> + + + - <%= apply.address %> + <%= apply.address %> + <% count = UserExtensions.where("school_id = #{apply.school_id}").count %> @@ -82,6 +124,9 @@ + <% unless apply.remarks.blank? %> diff --git a/app/views/admin/has_applied_schools.html.erb b/app/views/admin/has_applied_schools.html.erb index 11361dbac..2f6fc1f23 100644 --- a/app/views/admin/has_applied_schools.html.erb +++ b/app/views/admin/has_applied_schools.html.erb @@ -53,7 +53,7 @@ <%= apply.id %> - + <% unless apply.school_id.nil? %> <% school_name = School.where("id=?", apply.school_id).first %> <%= school_name.name %> diff --git a/config/routes.rb b/config/routes.rb index b07600400..77e6c2791 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -226,6 +226,9 @@ RedmineApp::Application.routes.draw do member do get 'upload_logo' post 'upload' + get 'edit_apply_name' + get 'edit_apply_address' + get 'edit_apply_province' end end diff --git a/public/javascripts/application.js b/public/javascripts/application.js index b7468366a..c31bc0f3e 100644 --- a/public/javascripts/application.js +++ b/public/javascripts/application.js @@ -1880,3 +1880,124 @@ function updateCourseName(){ } } } + +function edit_school_name(url,id){ + if($("#school_name_edit_"+id).val() == ""){ + $("#apply_title_"+id).show(); + $("#school_name_edit_"+id).hide(); + return; + } + $.get( + url, + {id: id ,name: $("#school_name_edit_"+id).val() }, + function (data) { + if(data.status == 0){ + $("#apply_title_"+data.id).show(); + $("#school_name_edit_"+data.id).hide(); + $("#apply_title_"+data.id).text(data.name); + } + else{ + $("#apply_title_"+data.id).show(); + $("#school_name_edit_"+data.id).hide(); + } + + } + ); +} + +function show_edit_school_name(id){ + $("#apply_title_"+id).hide(); + $("#school_name_edit_"+id).val($("#apply_title_"+id).text()); + $("#school_name_edit_"+id).show(); + $("#school_name_edit_"+id).focus(); + + +} + +function edit_school_address(url,id){ + if($("#school_address_edit_"+id).val() == ""){ + $("#apply_address_"+id).show(); + $("#school_address_edit_"+id).hide(); + return; + } + $.get( + url, + {id: id ,address: $("#school_address_edit_"+id).val() }, + function (data) { + if(data.status == 0){ + $("#apply_address_"+data.id).show(); + $("#school_address_edit_"+data.id).hide(); + $("#apply_address_"+data.id).text(data.address); + } + else{ + $("#apply_address_"+data.id).show(); + $("#school_address_edit_"+data.id).hide(); + } + + + } + ); +} + +function show_edit_school_address(id){ + $("#apply_address_"+id).hide(); + $("#school_address_edit_"+id).val($("#apply_address_"+id).text()); + $("#school_address_edit_"+id).show(); + $("#school_address_edit_"+id).focus(); +} + +function edit_school_province(url,id){ + + var province = $("#school_province_edit_"+id).val(); + var city = $("#schoolCity_"+id).val(); + + if((province == "")||(city == "")){ + $("#apply_province_"+id).show(); + $("#school_province_edit_"+id).hide(); + $("#schoolCity_"+id).hide(); + return; + } + + $.get( + url, + {id: id ,province: province,city:city }, + function (data) { + if(data.status == 0){ + $("#apply_province_"+data.id).show(); + $("#school_province_edit_"+data.id).hide(); + $("#schoolCity_"+data.id).hide(); + init_province_and_city(document.getElementById('school_province_edit_'+data.id), data.province, document.getElementById('schoolCity_'+data.id), data.city); + $("#apply_province_"+data.id).text(data.province+data.city); + + } + else{ + $("#apply_province_"+data.id).show(); + $("#school_province_edit_"+data.id).hide(); + $("#schoolCity_"+data.id).hide(); + } + + } + ); +} + +function init_province_and_city(pField, province, cField, city) { + for (var i = 0; i < pField.options.length; i++) { + if (pField.options[i].value == province) { + pField.selectedIndex = i; + } + } + showcity(province, cField); + for (var i = 0; i < cField.options.length; i++) { + if (cField.options[i].value == city) { + cField.selectedIndex = i; + } + } +} + +function show_edit_school_province(id){ + $("#apply_province_"+id).hide(); + $("#school_province_edit_"+id).show(); + $("#schoolCity_"+id).show(); + +} + From 17044629869e944de71a7cd9c7f9309e8cf99775 Mon Sep 17 00:00:00 2001 From: yuanke <249218296@qq.com> Date: Fri, 29 Jul 2016 21:45:32 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E7=AE=A1=E7=90=86=E5=91=98=E7=95=8C?= =?UTF-8?q?=E9=9D=A2=E5=8D=95=E4=BD=8D=E7=94=B3=E8=AF=B7=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/school_controller.rb | 2 +- app/views/admin/applied_schools.html.erb | 2 +- app/views/admin/has_applied_schools.html.erb | 56 +++++++++++++++++--- 3 files changed, 51 insertions(+), 9 deletions(-) diff --git a/app/controllers/school_controller.rb b/app/controllers/school_controller.rb index 264f0ae1f..4553d6ea9 100644 --- a/app/controllers/school_controller.rb +++ b/app/controllers/school_controller.rb @@ -229,7 +229,7 @@ class SchoolController < ApplicationController status = 0 end - render :json=>{:status=>status,:id=>params[:id],:address=>name} + render :json=>{:status=>status,:id=>params[:id],:name=>name} end def edit_apply_address diff --git a/app/views/admin/applied_schools.html.erb b/app/views/admin/applied_schools.html.erb index 319051d78..61db6769f 100644 --- a/app/views/admin/applied_schools.html.erb +++ b/app/views/admin/applied_schools.html.erb @@ -54,7 +54,7 @@ <%= apply.id %> - <%= apply.name %> + <%= apply.name %> diff --git a/app/views/admin/has_applied_schools.html.erb b/app/views/admin/has_applied_schools.html.erb index 2f6fc1f23..cbb0e70e5 100644 --- a/app/views/admin/has_applied_schools.html.erb +++ b/app/views/admin/has_applied_schools.html.erb @@ -53,10 +53,11 @@ <%= apply.id %> - + <% unless apply.school_id.nil? %> <% school_name = School.where("id=?", apply.school_id).first %> - <%= school_name.name %> + <%= school_name %> + <% end %> @@ -66,13 +67,51 @@ <% end %> - <% unless apply.school_id.nil? %> - <% school_province = School.where("id=?", apply.school_id).first %> - <%= school_province.province %> - <% end %> + + <%= (apply.province.nil? ? "" : apply.province) + (apply.city.nil? ? "" : apply.city) %> + + + - <%= apply.address %> + <%= apply.address %> + <%= apply.name %> @@ -84,6 +123,9 @@ <%= 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.blank? %> From d6178ec7dd2a1be954ddf9b2380274d858cc4eb6 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Fri, 29 Jul 2016 21:45:52 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E7=AE=A1=E7=90=86=E5=91=98=E7=95=8C?= =?UTF-8?q?=E9=9D=A2=E5=8D=95=E4=BD=8D=E7=94=B3=E8=AF=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/school_controller.rb | 2 +- app/models/applied_message.rb | 3 ++- app/views/admin/applied_schools.html.erb | 2 +- app/views/admin/has_applied_schools.html.erb | 2 +- app/views/users/_user_message_applied.html.erb | 10 ++++++---- 5 files changed, 11 insertions(+), 8 deletions(-) diff --git a/app/controllers/school_controller.rb b/app/controllers/school_controller.rb index b927b1108..037fdd411 100644 --- a/app/controllers/school_controller.rb +++ b/app/controllers/school_controller.rb @@ -191,7 +191,7 @@ class SchoolController < ApplicationController # status=4 向管理员发送信息 users = User.where(:admin => 1) users.each do |user| - AppliedMessage.create(:user_id => user.id, :status => 4, :viewed => true, :applied_id => school.id, :applied_type => "ApplyAddSchools", :name => school.name ) + 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 diff --git a/app/models/applied_message.rb b/app/models/applied_message.rb index c008a2284..2e8891fcd 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, :name belongs_to :applied ,:polymorphic => true + 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 has_many :message_alls, :class_name => 'MessageAll', :as =>:message, :dependent => :destroy diff --git a/app/views/admin/applied_schools.html.erb b/app/views/admin/applied_schools.html.erb index 507cb7c49..518624b5f 100644 --- a/app/views/admin/applied_schools.html.erb +++ b/app/views/admin/applied_schools.html.erb @@ -59,7 +59,7 @@ <% user = User.where("id=?", apply.user_id).first %> <% unless user.nil? %> - <%= user.login %> + <%=link_to user.show_name, user_path(user) %> <% end %> diff --git a/app/views/admin/has_applied_schools.html.erb b/app/views/admin/has_applied_schools.html.erb index 555dce689..286edbd19 100644 --- a/app/views/admin/has_applied_schools.html.erb +++ b/app/views/admin/has_applied_schools.html.erb @@ -65,7 +65,7 @@ <% user = User.where("id=?", apply.user_id).first %> <% unless user.nil? %> - <%= user.login %> + <%=link_to user.show_name, user_path(user) %> <% end %> diff --git a/app/views/users/_user_message_applied.html.erb b/app/views/users/_user_message_applied.html.erb index b2735f32a..d52e4c2c8 100644 --- a/app/views/users/_user_message_applied.html.erb +++ b/app/views/users/_user_message_applied.html.erb @@ -1,6 +1,7 @@ <% 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" %>