acoount.html对齐了一下
学校列表school/index.html默认显示全部学校
没有填写工作单位的用户强行跳转到修改资料页面
This commit is contained in:
yanxd 2014-05-09 17:08:42 +08:00
parent 845186a600
commit 4d8701220b
8 changed files with 578 additions and 606 deletions

View File

@ -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 "+
# "<Limit PUT POST DELETE PROPPATCH MKCOL COPY MOVE LOCK UNLOCK> \n"+
# "Require group "+params[:user][:login]+"-write \n "+
# "</Limit> \n ' >>"+
# @root_path+"htdocs/"+params[:user][:login]+"/.htaccess"
end
case Setting.self_registration

View File

@ -41,8 +41,21 @@ class SchoolController < ApplicationController
@provinces.each do |p|
options << "<option value = '#{p.province}' >#{p.province}</option>"
end
@school = School.all
options_s = ""
@school.each do |s|
#options << "<option value=#{s.id}>#{s.name}</option>"
options_s << "<li style = 'width: 33%; float: left'><a id=#{s.id} onclick='test(this.id, this.text)'>#{s.name}</a></li>"
end
res = Hash.new
res[:text] = options
res[:text_s] = options_s
render :json => res
render :text => options
end
@ -74,8 +87,11 @@ class SchoolController < ApplicationController
end
def search_school
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 << "<li style = 'width: 33%; float: left'><a id=#{s.id} onclick='test(this.id)'>#{s.name}</a></li>"

View File

@ -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

View File

@ -1,5 +1,3 @@
<script type="text/javascript">
$(document).ready(
function () {
@ -19,17 +17,13 @@
data: 'text',
success: function (data) {
$("#province").val(value)
$("#schoollist").html(data);
}
});
}
)
}
</script>
@ -78,60 +72,47 @@
<!-- added by bai 增加账户里的性别-->
<span id='gender' style='display:none'>
<% unless @user.user_extensions.nil? %>
<% if @user.user_extensions.gender == 0 %>
<% if @user.user_extensions.nil? %>
<p style="width:400px;padding-left: 26px;">
<%= l(:label_gender) %>&nbsp;&nbsp;<%= select_tag 'gender', "<option value = '0'>#{l(:label_gender_male)}</option><option value = '1'>#{l(:label_gender_female)}</option>".html_safe ,:class =>'gender' %>
<%= l(:label_gender) %>&nbsp;&nbsp;
<%= select_tag 'gender', "<option value = '0'>#{l(:label_gender_male)}</option><option value = '1'>#{l(:label_gender_female)}</option>".html_safe, :class => 'gender' %>
</p>
<% else %>
<% if @user.user_extensions.gender == 0 %><!-- label_gender_male -->
<p style="width:400px;padding-left: 26px;">
<%= l(:label_gender) %>&nbsp;&nbsp;
<%= select_tag 'gender', "<option value = '0'>#{l(:label_gender_male)}</option><option value = '1'>#{l(:label_gender_female)}</option>".html_safe, :class => 'gender' %>
</p>
<% else %>
<p style="width:400px;padding-left: 26px;">
<%= l(:label_gender) %>&nbsp;&nbsp;<%= select_tag 'gender', "<option value = '0'>#{l(:label_gender_male)}</option><option value = '1' selected='selected'>#{l(:label_gender_female)}</option>".html_safe ,:class =>'gender' %>
</p>
<% end %>
<% else %>
<p style="width:400px;padding-left: 26px;"><%= l(:label_gender) %>&nbsp;&nbsp;<%= select_tag 'gender', "<option value = '0'>#{l(:label_gender_male)}</option><option value = '1'>#{l(:label_gender_female)}</option>".html_safe ,:class =>'gender' %></p>
<%= l(:label_gender) %>&nbsp;&nbsp;
<%= select_tag 'gender', "<option value = '0'>#{l(:label_gender_male)}</option><option value = '1' selected='selected'>#{l(:label_gender_female)}</option>".html_safe, :class => 'gender' %>
</p>
<% end %>
<!-- added by bai 单位-->
<!--<% unless @user.user_extensions.nil?%>
<p style="width:400px;padding-left: 26px;"><%= l(:field_occupation)%>&nbsp;<span class="required">*</span><%= text_field_tag "occupation", @user.user_extensions.occupation, :class => 'occupation' %>
</p>
<%else%>
<p style="width:400px;padding-left: 26px;"><%= l(:field_occupation)%><span class="required">*</span><%= text_field_tag "occupation", nil, :class => 'occupation' %>
</p>
<% end %>
-->
</span>
<!-- added by Wen -->
<p style="padding-left: 26px;">
<% unless User.current.user_extensions.school.nil? %>
<%= l(:field_occupation) %>&nbsp;<span class="required">*</span>
<input id="province" name="province" type="text" value="<%=User.current.user_extensions.school.province%>" readonly />
<input id="occupation" name="occupation" type="hidden" value="<%=User.current.user_extensions.school.id%>" />
<input id="occupation_name" type="text" value="<%=User.current.user_extensions.school.name%>" readonly />
<% else %>
<% if User.current.user_extensions.school.nil? %>
<%= l(:field_occupation) %>&nbsp;<span class="required">*</span>
<input id="province" name="province" type="text" value="请单击选择省份及学校" readonly>
<input id="occupation" name="occupation" type="hidden"/>
<input id="occupation_name" type="text" readonly/>
<% else %>
<%= l(:field_occupation) %>&nbsp;<span class="required">*</span>
<input id="province" name="province" type="text" value="<%= User.current.user_extensions.school.province %>" readonly/>
<input id="occupation" name="occupation" type="hidden" value="<%= User.current.user_extensions.school.id %>"/>
<input id="occupation_name" type="text" value="<%= User.current.user_extensions.school.name %>" readonly/>
<% end %>
<!-- <input id="occupation" readonly />-->
</p>
<div id="WOpenWindow">
<a class="modal_close" href="#"></a>
<h2>学校列表</h2>
<div class="pcontent">
<ul id="provincelist" class="school_list">
<% @ss = School.find_by_sql("select distinct province from schools") %>
@ -149,37 +130,165 @@
</ul>
</div>
</div>
<script type="text/javascript">
function test(id, name) {
//$("#occupation").html("<option value='"+id+"'>"+name+"</option>");
$("#occupation").val(id);
$("#occupation_name").val(name);
$("#lean_overlay").hide();
$("#WOpenWindow").hide();
}
</script>
<!-- added by bai 增加了地区 -->
</span>
<!-- end -->
<p style="width:357px;padding-left: 26px;">
<%= f.text_field :mail, :required => true %>
</p>
<p style="width:426px;padding-left:26px;">
<%= f.select :language, :Chinese简体中文 => :zh, :English => :en%>
<%= f.select :language, :Chinese => :zh, :English => :en %>
</p>
<% province = User.current.user_extensions.location %>
<% city = User.current.user_extensions.location_city %>
<% identity = User.current.user_extensions.identity %>
<% title = User.current.user_extensions.technical_title %>
<script type="text/javascript" language="javascript">
$().ready(function () {
var province = "<%= "#{province}" %>"
var city = "<%= "#{city}" %>"
init_province_and_city(document.getElementById('userProvince'), province, document.getElementById('userCity'), city);
var identity = "<%= "#{identity}" %>"
var title = "<%= "#{title}" %>"
init_identity_and_title(document.getElementById('userIdentity'), identity, document.getElementById('userTechnical_title'), title);
});
</script>
<p style="width:400px;padding-left: 26px;"><%= l(:label_location) %>
<select onchange="showcity(this.value, document.getElementById('userCity'));" name="province" id="userProvince" class="location">
<option value="">--请选择省份--</option>
<option value="北京">北京</option>
<option value="上海">上海</option>
<option value="广东">广东</option>
<option value="江苏">江苏</option>
<option value="浙江">浙江</option>
<option value="重庆">重庆</option>
<option value="安徽">安徽</option>
<option value="福建">福建</option>
<option value="甘肃">甘肃</option>
<option value="广西">广西</option>
<option value="贵州">贵州</option>
<option value="海南">海南</option>
<option value="河北">河北</option>
<option value="黑龙江">黑龙江</option>
<option value="河南">河南</option>
<option value="湖北">湖北</option>
<option value="湖南">湖南</option>
<option value="江西">江西</option>
<option value="吉林">吉林</option>
<option value="辽宁">辽宁</option>
<option value="内蒙古">内蒙古</option>
<option value="宁夏">宁夏</option>
<option value="青海">青海</option>
<option value="山东">山东</option>
<option value="山西">山西</option>
<option value="陕西">陕西</option>
<option value="四川">四川</option>
<option value="天津">天津</option>
<option value="新疆">新疆</option>
<option value="西藏">西藏</option>
<option value="云南">云南</option>
<option value="香港">香港特别行政区</option>
<option value="澳门">澳门特别行政区</option>
<option value="台湾">台湾</option>
<option value="海外">海外</option>
</select>
<select name="city" id="userCity" class="location"></select>
</p>
<% unless @user.user_extensions.identity == 2 %>
<p style="width:400px;padding-left: 26px;">
<%= l(:label_identity) %>
<select onchange="showtechnical_title(this.value, document.getElementById('userTechnical_title'));" name="identity" id="userIdentity" class="location">
<option value=""><%= l(:label_account_identity_choose) %></option>
<option value="0"><%= l(:label_account_identity_teacher) %></option>
<option value="1"><%= l(:label_account_identity_student) %></option>
<option value="3"><%= l(:label_account_identity_developer) %></option>
</select>
</p>
<span id='technical_title' style='display:none'>
<select name="technical_title" id="userTechnical_title"></select>
</span>
<span id='no' style='display:none'>
<!-- modified by fq -->
<% unless User.current.user_extensions.student_id.nil? %>
<%= text_field_tag :no, User.current.user_extensions.student_id, :placeholder => "请输入学号" %>
<% else %>
<%= text_field_tag :no, nil, :placeholder => "请输入学号" %></span>
<% end %>
<!-- end -->
</span>
<% else %>
<span style="display:none">
<select onchange="showtechnical_title(this.value, document.getElementById('userTechnical_title'));" name="identity" id="userIdentity" class="location">
<option value=""><%= l(:label_account_identity_choose) %></option>
<option value="0"><%= l(:label_account_identity_teacher) %></option>
<option value="1"><%= l(:label_account_identity_student) %></option>
<option value="2"><%= l(:label_account_identity_enterprise) %></option>
<option value="3"><%= l(:label_account_identity_developer) %></option>
</select>
</span>
<% end %>
</div>
<% if Setting.openid? %>
<p> <%= f.text_field :identity_url %> </p>
<% end %>
<% @user.custom_field_values.select(&:editable?).each do |value| %>
<p> <%= custom_field_tag_with_label :user, value %> </p>
<% end %>
<%= call_hook(:view_my_account, :user => @user, :form => f) %>
</fieldset>
<fieldset class="collapsible collapsed" style="width:800px;margin-left: 10px;">
<legend onclick="toggleFieldset(this);">
<%= l(:field_mail_notification) %>
</legend>
<div style="padding-left: 26px;"> <!-- modified by ming -->
<p style="width:380px;">
<%= render :partial => 'users/mail_notifications' %>
</p></div>
</fieldset>
<!-- added by william -->
<fieldset class="collapsible collapsed" style="width:800px;margin-left: 10px;display: none">
<legend onclick="toggleFieldset(this);">
<%= l(:label_user_extensions) %>
</legend>
<div>
<%= render :partial => 'users/user_extensions' %></div>
</fieldset>
<!-- end -->
<%= submit_tag l(:button_save) %>
</fieldset>
<% end %>
<% html_title(l(:label_my_account)) -%>
<script type="text/javascript" language="javascript">
function showcity(province, cityField) {
switch (province) {
@ -368,95 +477,30 @@ function showcity(province, cityField) {
}
function init_province_and_city(pField, province, cField, city) {
for (var i = 0; i < pField.options.length; i++) {
if (pField.options[i].value==province)
{
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)
{
if (cField.options[i].value == city) {
cField.selectedIndex = i;
}
}
}
function init_identity_and_title(pField, identity, cField, title) {
for (var i = 0; i < pField.options.length; i++) {
if (pField.options[i].value==identity)
{
if (pField.options[i].value == identity) {
pField.selectedIndex = i;
}
}
showtechnical_title(identity, cField);
for (var i = 0; i < cField.options.length; i++) {
if (cField.options[i].value==title)
{
if (cField.options[i].value == title) {
cField.selectedIndex = i;
}
}
}
</script>
<% province = User.current.user_extensions.location %>
<% city = User.current.user_extensions.location_city %>
<% identity = User.current.user_extensions.identity %>
<% title = User.current.user_extensions.technical_title %>
<script type="text/javascript" language="javascript">
$().ready(function(){
var province = "<%= "#{province}" %>"
var city = "<%= "#{city}" %>"
init_province_and_city(document.getElementById('userProvince'),province, document.getElementById('userCity'),city);
var identity = "<%= "#{identity}" %>"
var title = "<%= "#{title}" %>"
init_identity_and_title(document.getElementById('userIdentity'),identity, document.getElementById('userTechnical_title'),title);
});
</script>
<p style="width:400px;padding-left: 26px;"><%= l(:label_location) %>
<select onchange="showcity(this.value, document.getElementById(&#39;userCity&#39;));" name="province" id="userProvince" class="location">
<option value="">--请选择省份--</option>
<option value="北京">北京</option>
<option value="上海">上海</option>
<option value="广东">广东</option>
<option value="江苏">江苏</option>
<option value="浙江">浙江</option>
<option value="重庆">重庆</option>
<option value="安徽">安徽</option>
<option value="福建">福建</option>
<option value="甘肃">甘肃</option>
<option value="广西">广西</option>
<option value="贵州">贵州</option>
<option value="海南">海南</option>
<option value="河北">河北</option>
<option value="黑龙江">黑龙江</option>
<option value="河南">河南</option>
<option value="湖北">湖北</option>
<option value="湖南">湖南</option>
<option value="江西">江西</option>
<option value="吉林">吉林</option>
<option value="辽宁">辽宁</option>
<option value="内蒙古">内蒙古</option>
<option value="宁夏">宁夏</option>
<option value="青海">青海</option>
<option value="山东">山东</option>
<option value="山西">山西</option>
<option value="陕西">陕西</option>
<option value="四川">四川</option>
<option value="天津">天津</option>
<option value="新疆">新疆</option>
<option value="西藏">西藏</option>
<option value="云南">云南</option>
<option value="香港">香港特别行政区</option>
<option value="澳门">澳门特别行政区</option>
<option value="台湾">台湾</option>
<option value="海外">海外</option>
</select>
<select name="city" id="userCity" class="location"></select></p>
<!-- end -->
<!-- added by bai 增加职称-->
<script type="text/javascript" language="javascript">
function showtechnical_title(identity, technical_titleField) {
switch (identity) {
@ -510,95 +554,3 @@ $().ready(function(){
}
}
</script>
<!-- end -->
<% unless @user.user_extensions.identity == 2 %>
<p style="width:400px;padding-left: 26px;"><%= l(:label_identity) %>
<td class="info" style="width: 10px">
<select onchange="showtechnical_title(this.value, document.getElementById(&#39;userTechnical_title&#39;));" name="identity" id="userIdentity" class="location">
<option value=""><%= l(:label_account_identity_choose) %></option>
<option value="0"><%= l(:label_account_identity_teacher) %></option>
<option value="1"><%= l(:label_account_identity_student) %></option>
<option value="3"><%= l(:label_account_identity_developer) %></option>
</select></td>
<span id = 'technical_title' style = 'display:none'>
<select name="technical_title" id="userTechnical_title"></select></span>
<span id = 'no' style = 'display:none'>
<!-- modified by fq -->
<% unless User.current.user_extensions.student_id.nil? %>
<%= text_field_tag :no, User.current.user_extensions.student_id, :placeholder => "请输入学号" %></span>
<!-- <input name="no" id="no" value=<%= "#{User.current.user_extensions.student_id}" %> placeholder="请输入学号"></span> -->
<% else %>
<%= text_field_tag :no, nil, :placeholder => "请输入学号" %></span>
<!-- <input name="no" id="no" placeholder="请输入学号"></span> -->
<% end %>
<!-- end -->
</td></tr></table></p>
<% else %>
<span style="display:none">
<select onchange="showtechnical_title(this.value, document.getElementById(&#39;userTechnical_title&#39;));" name="identity" id="userIdentity" class="location">
<option value=""><%= l(:label_account_identity_choose) %></option>
<option value="0"><%= l(:label_account_identity_teacher) %></option>
<option value="1"><%= l(:label_account_identity_student) %></option>
<option value="2"><%= l(:label_account_identity_enterprise) %></option>
<option value="3"><%= l(:label_account_identity_developer) %></option>
</select>
</span>
<% end %>
<!-- end -->
</div>
<% if Setting.openid? %>
<p>
<%= f.text_field :identity_url %>
</p></div>
<% end %>
<% @user.custom_field_values.select(&:editable?).each do |value| %>
<p>
<%= custom_field_tag_with_label :user, value %>
</p>
<% end %>
<%= call_hook(:view_my_account, :user => @user, :form => f) %>
</fieldset>
<fieldset class="collapsible collapsed" style="width:800px;margin-left: 10px;">
<legend onclick="toggleFieldset(this);">
<%= l(:field_mail_notification)%>
</legend>
<div style="padding-left: 26px;"> <!-- modified by ming -->
<p style="width:380px;>
<%= render :partial => 'users/mail_notifications' %>
</p></div>
</fieldset>
<!-- <fieldset class="collapsible collapsed" style="width:800px;margin-left: 10px;">
<legend onclick="toggleFieldset(this);">
<%= l(:label_preferences)%>
</legend>
<div style="padding-left: 26px;">
<%= render :partial => 'users/preferences' %></div>
</fieldset> -->
<!-- added by william -->
<fieldset class="collapsible collapsed" style="width:800px;margin-left: 10px;display: none">
<legend onclick="toggleFieldset(this);">
<%= l(:label_user_extensions)%>
</legend>
<div>
<%= render :partial => 'users/user_extensions' %></div>
</fieldset>
<!-- end -->
<%= submit_tag l(:button_save) %>
</fieldset>
<% end %>
<% html_title(l(:label_my_account)) -%>

View File

@ -4,12 +4,17 @@
$(document).ready(function() {
$("#province").html("<option value='0' selected = true style='display: none;'></option>");
$.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);
}
})

View File

@ -1,5 +1,5 @@
<p>
<%= 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(

View File

@ -244,7 +244,7 @@
</div>
<div class="pagination" style="float:left;">
<ul> <%= pagination_links_full @info_pages %> <ul>
<ul> <%= pagination_links_full @info_pages %> </ul>
</div>
<% else %>

View File

@ -186,6 +186,8 @@ zh:
notice_issue_done_ratios_updated: 问题完成度已更新。
notice_gantt_chart_truncated: "这个表是截断的因为它超过了可以显示的最大数量(%{max})"
error_complete_occupation: "请您填写工作单位,否则本系统的部分功能将无法正常使用。"
error_can_t_load_default_data: "无法载入默认设置:%{value}"
error_scm_not_found: "版本库中不存在该条目和(或)其修订版本。"
error_scm_command_failed: "访问版本库时发生错误:%{value}"