From 4d8701220bfa50e6baa44dbbb379456e64bce3a7 Mon Sep 17 00:00:00 2001 From: yanxd Date: Fri, 9 May 2014 17:08:42 +0800 Subject: [PATCH] =?UTF-8?q?-=E3=80=82-=20acoount.html=E5=AF=B9=E9=BD=90?= =?UTF-8?q?=E4=BA=86=E4=B8=80=E4=B8=8B=20=E5=AD=A6=E6=A0=A1=E5=88=97?= =?UTF-8?q?=E8=A1=A8school/index.html=E9=BB=98=E8=AE=A4=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E5=85=A8=E9=83=A8=E5=AD=A6=E6=A0=A1=20=E6=B2=A1=E6=9C=89?= =?UTF-8?q?=E5=A1=AB=E5=86=99=E5=B7=A5=E4=BD=9C=E5=8D=95=E4=BD=8D=E7=9A=84?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E5=BC=BA=E8=A1=8C=E8=B7=B3=E8=BD=AC=E5=88=B0?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=B5=84=E6=96=99=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/account_controller.rb | 13 +- app/controllers/school_controller.rb | 24 +- app/controllers/users_controller.rb | 8 + app/views/my/account.html.erb | 1122 +++++++++--------- app/views/school/index.html.erb | 11 +- app/views/users/_mail_notifications.html.erb | 2 +- app/views/users/show.html.erb | 2 +- config/locales/zh.yml | 2 + 8 files changed, 578 insertions(+), 606 deletions(-) diff --git a/app/controllers/account_controller.rb b/app/controllers/account_controller.rb index 769214d65..d3d426857 100644 --- a/app/controllers/account_controller.rb +++ b/app/controllers/account_controller.rb @@ -111,8 +111,7 @@ class AccountController < ApplicationController user_params = params[:user] || {} @user = User.new @user.safe_attributes = user_params - #这里判断 - if params[:identity] == "2" + if params[:identity] == "2" # 2 企业 @user.firstname = params[:enterprise_name] @user.lastname = l(:field_enterprise) end @@ -132,16 +131,6 @@ class AccountController < ApplicationController @user.login = params[:user][:login] unless user_params[:identity_url].present? && user_params[:password].blank? && user_params[:password_confirmation].blank? @user.password, @user.password_confirmation = user_params[:password], user_params[:password_confirmation] - # system "htpasswd -mb "+@root_path+"user.passwd "+params[:user][:login]+" "+user_params[:password] - # system "echo -e '\n"+params[:user][:login]+"-write:"+ - # " "+params[:user][:login]+"' >> "+@root_path+"group.passwd" - # system "mkdir "+@root_path+"htdocs/"+params[:user][:login] -# - # system "echo -e 'Allow from all \n Order Deny,Allow \n "+ - # " \n"+ - # "Require group "+params[:user][:login]+"-write \n "+ - # " \n ' >>"+ - # @root_path+"htdocs/"+params[:user][:login]+"/.htaccess" end case Setting.self_registration diff --git a/app/controllers/school_controller.rb b/app/controllers/school_controller.rb index 5b405a27a..00faa51c5 100644 --- a/app/controllers/school_controller.rb +++ b/app/controllers/school_controller.rb @@ -41,9 +41,22 @@ class SchoolController < ApplicationController @provinces.each do |p| options << "" end - - render :text => options + @school = School.all + + options_s = "" + + @school.each do |s| + #options << "" + options_s << "
  • #{s.name}
  • " + end + res = Hash.new + res[:text] = options + res[:text_s] = options_s + + render :json => res + + end def get_options @@ -74,8 +87,11 @@ class SchoolController < ApplicationController end def search_school - @school = School.where("province = ? AND name LIKE '%"+params[:key_word]+"%'", params[:province]); - + if params[:province].nil? or params[:province] == "0" + @school = School.where("name LIKE '%"+params[:key_word]+"%'"); + else + @school = School.where("province = ? AND name LIKE '%"+params[:key_word]+"%'", params[:province]); + end options = "" @school.each do |s| options << "
  • #{s.name}
  • " diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index d4248e3cc..f68555055 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -38,6 +38,7 @@ class UsersController < ApplicationController :user_homeworks, :destroy_membership, :user_activities, :user_projects, :user_newfeedback, :user_comments, :watch_bids, :watch_contests, :info, :watch_projects, :show_score, :topic_score_index, :project_score_index, :activity_score_index, :influence_score_index, :score_index] + before_filter :auth_user_extension, only: :show accept_api_auth :index, :show, :create, :update, :destroy,:tag_save #william @@ -735,4 +736,11 @@ class UsersController < ApplicationController def setting_layout(default_base='base_users') User.current.admin? ? 'base_admin' : default_base end + + def auth_user_extension + if @user.user_extensions.school.nil? + flash[:error] = l(:error_complete_occupation) + redirect_to my_account_path + end + end end diff --git a/app/views/my/account.html.erb b/app/views/my/account.html.erb index 58f684009..7158037eb 100644 --- a/app/views/my/account.html.erb +++ b/app/views/my/account.html.erb @@ -1,604 +1,556 @@ - - - - - - -
    - <%= link_to(l(:button_change_password), {:action => 'password'}, :class => 'icon icon-passwd') if @user.change_password_allowed? %> - <%= call_hook(:view_my_account_contextual, :user => @user)%> +
    + <%= link_to(l(:button_change_password), {:action => 'password'}, :class => 'icon icon-passwd') if @user.change_password_allowed? %> + <%= call_hook(:view_my_account_contextual, :user => @user) %>
    -

    <%= l(:label_my_account)%>

    +

    <%= l(:label_my_account) %>

    - - <%= labelled_form_for :user, @user, - :url => { :action => "account" }, - :html => { :id => 'my_account_form', - :method => :post } do |f| %> -
    - <% end %> - - <% @user.custom_field_values.select(&:editable?).each do |value| %> -

    - <%= custom_field_tag_with_label :user, value %> -

    - <% end %> - <%= call_hook(:view_my_account, :user => @user, :form => f) %> - - - --> - - - <%= submit_tag l(:button_save) %> - + <% end %> <% html_title(l(:label_my_account)) -%> + + \ No newline at end of file diff --git a/app/views/school/index.html.erb b/app/views/school/index.html.erb index 06b294f89..755bd3151 100644 --- a/app/views/school/index.html.erb +++ b/app/views/school/index.html.erb @@ -4,12 +4,17 @@ $(document).ready(function() { $("#province").html(""); + + + $.ajax({ type :"POST", url :'/school/get_province', - data :'text', - success: function(data){ - $("#province").append(data); + data: "send", + success: function(data, textStatus){ + + $("#province").append(data.text); + $("#schoollist").html(data.text_s); } }) diff --git a/app/views/users/_mail_notifications.html.erb b/app/views/users/_mail_notifications.html.erb index ee6ccb00b..47face839 100644 --- a/app/views/users/_mail_notifications.html.erb +++ b/app/views/users/_mail_notifications.html.erb @@ -1,5 +1,5 @@

    -<%= label_tag "user_mail_notification", l(:description_user_mail_notification), :class => "hidden-for-sighted" %> +<%= label_tag "user_mail_notification", l(:description_user_mail_notification), :class => "hidden-for-sighted_bak" %> <%= select_tag( 'user[mail_notification]', options_for_select( diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb index dd912cfe6..8168060e5 100644 --- a/app/views/users/show.html.erb +++ b/app/views/users/show.html.erb @@ -244,7 +244,7 @@

    <% else %> diff --git a/config/locales/zh.yml b/config/locales/zh.yml index 26d3f6682..b8378c0d7 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -185,6 +185,8 @@ zh: notice_unable_delete_time_entry: 无法删除工时 notice_issue_done_ratios_updated: 问题完成度已更新。 notice_gantt_chart_truncated: "这个表是截断的因为它超过了可以显示的最大数量(%{max})" + + error_complete_occupation: "请您填写工作单位,否则本系统的部分功能将无法正常使用。" error_can_t_load_default_data: "无法载入默认设置:%{value}" error_scm_not_found: "版本库中不存在该条目和(或)其修订版本。"