管理员修改学校的功能
This commit is contained in:
parent
39d347d5c2
commit
1f1a8e0770
|
@ -5,14 +5,18 @@ class SchoolController < ApplicationController
|
|||
def upload
|
||||
uploaded_io = params[:logo]
|
||||
school_id ||= params[:id]
|
||||
s1 = School.find(school_id)
|
||||
unless uploaded_io.nil?
|
||||
File.open(Rails.root.join('public', 'images', 'school', school_id.to_s+'.png'), 'wb') do |file|
|
||||
file.write(uploaded_io.read)
|
||||
end
|
||||
s1 = School.find(school_id)
|
||||
|
||||
s1.logo_link = '/images/school/'+school_id.to_s+'.png'
|
||||
s1.save
|
||||
|
||||
end
|
||||
s1.name = params[:name] unless params[:name].blank?
|
||||
s1.province = params[:province] unless params[:province].blank?
|
||||
s1.save
|
||||
redirect_to admin_schools_url(:school_name => params[:school_name])
|
||||
end
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ function showPreview(source) {
|
|||
}
|
||||
</script>
|
||||
|
||||
<%= form_tag(upload_school_path(@school.id),method: "post", multipart: true) do %>
|
||||
<%= form_tag(upload_school_path(@school.id),method: "post", multipart: true,:id => "school_form") do %>
|
||||
<%#= text_field_tag 'school'%>
|
||||
<div style="padding:15px; border: 1px solid #dddddd;">
|
||||
<input type="hidden" value="<%= @school_name%>" name="school_name">
|
||||
|
@ -19,16 +19,58 @@ function showPreview(source) {
|
|||
<a type="button" onclick="$('#file').click();" style="margin: 86px 0 0 15px;float: left;padding: 2px 5px;border: 1px solid #eaeaea;cursor: pointer;text-decoration: none;width: 55px;">上传图片</a>
|
||||
<%= file_field_tag 'logo',:style => "display:none;", :id => "file", :onchange => "showPreview(this)"%>
|
||||
<div style="clear: both;"></div>
|
||||
<div class="mt15">学校名称:<input type="text" placeholder="现在对应的学校名称" class="schoolName ml4"/></div>
|
||||
<div class="mt15">学校名称:<input type="text" name="name" placeholder="现在对应的学校名称" value="<%= @school.name%>" class="schoolName ml4"/></div>
|
||||
<div class="mt10">学校省份:
|
||||
<select class="provinceSelect"><option value="0" selected="true" style="display: none;"></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 class="provinceSelect" name="province">
|
||||
<option value="">--请选择省份--</option>
|
||||
<option value="北京市" <%= @school.province == '北京市' ? 'selected':'' %>>北京</option>
|
||||
<option value="上海市" <%= @school.province == '上海市' ? 'selected':'' %>>上海</option>
|
||||
<option value="广东省" <%= @school.province == '广东省' ? 'selected':'' %>>广东</option>
|
||||
<option value="江苏省" <%= @school.province == '江苏省' ? 'selected':'' %>>江苏</option>
|
||||
<option value="浙江省" <%= @school.province == '浙江省' ? 'selected':'' %>>浙江</option>
|
||||
<option value="重庆市" <%= @school.province == '重庆市' ? 'selected':'' %>>重庆</option>
|
||||
<option value="安徽省" <%= @school.province == '安徽省' ? 'selected':'' %>>安徽</option>
|
||||
<option value="福建省" <%= @school.province == '福建省' ? 'selected':'' %>>福建</option>
|
||||
<option value="甘肃省" <%= @school.province == '甘肃省' ? 'selected':'' %>>甘肃</option>
|
||||
<option value="广西省" <%= @school.province == '广西省' ? 'selected':'' %>>广西</option>
|
||||
<option value="贵州省" <%= @school.province == '贵州省' ? 'selected':'' %>>贵州</option>
|
||||
<option value="海南省" <%= @school.province == '海南省' ? 'selected':'' %>>海南</option>
|
||||
<option value="河北省" <%= @school.province == '河北省' ? 'selected':'' %>>河北</option>
|
||||
<option value="黑龙江省" <%= @school.province == '黑龙江省' ? 'selected':'' %>>黑龙江</option>
|
||||
<option value="河南省" <%= @school.province == '河南省' ? 'selected':'' %>>河南</option>
|
||||
<option value="湖北省" <%= @school.province == '湖北省' ? 'selected':'' %>>湖北</option>
|
||||
<option value="湖南省" <%= @school.province == '湖南省' ? 'selected':'' %>>湖南</option>
|
||||
<option value="江西省" <%= @school.province == '江西省' ? 'selected':'' %>>江西</option>
|
||||
<option value="吉林省" <%= @school.province == '吉林省' ? 'selected':'' %>>吉林</option>
|
||||
<option value="辽宁省" <%= @school.province == '辽宁省' ? 'selected':'' %>>辽宁</option>
|
||||
<option value=" 内蒙古自治区" <%= @school.province == ' 内蒙古自治区' ? 'selected':'' %>>内蒙古</option>
|
||||
<option value="宁夏回族自治区" <%= @school.province == '宁夏回族自治区' ? 'selected':'' %>>宁夏</option>
|
||||
<option value="青海省" <%= @school.province == '青海省' ? 'selected':'' %>>青海</option>
|
||||
<option value="山东省" <%= @school.province == '山东省' ? 'selected':'' %>>山东</option>
|
||||
<option value="山西省" <%= @school.province == '山西省' ? 'selected':'' %>>山西</option>
|
||||
<option value="陕西省" <%= @school.province == '陕西省' ? 'selected':'' %>>陕西</option>
|
||||
<option value="四川省" <%= @school.province == '四川省' ? 'selected':'' %>>四川</option>
|
||||
<option value="天津市" <%= @school.province == '天津市' ? 'selected':'' %>>天津</option>
|
||||
<option value=" 新疆维吾尔自治区" <%= @school.province == ' 新疆维吾尔自治区' ? 'selected':'' %>>新疆</option>
|
||||
<option value="西藏自治区" <%= @school.province == '西藏自治区' ? 'selected':'' %>>西藏</option>
|
||||
<option value="云南省" <%= @school.province == '云南省' ? 'selected':'' %>>云南</option>
|
||||
<option value="香港" <%= @school.province == '香港' ? 'selected':'' %>>香港特别行政区</option>
|
||||
<option value="澳门" <%= @school.province == '澳门' ? 'selected':'' %>>澳门特别行政区</option>
|
||||
<option value="台湾" <%= @school.province == '台湾' ? 'selected':'' %>>台湾</option>
|
||||
<option value="海外" <%= @school.province == '海外' ? 'selected':'' %>>海外</option>
|
||||
</select>
|
||||
</div>
|
||||
<div style="margin-top: 10px;">
|
||||
<input type="button" value="提交" class="mr5 submit_btn" />
|
||||
<input type="button" value="取消" class="cancel_btn" />
|
||||
<input type="button" value="提交" onclick="submit_edit_school($(this));" class="mr5 submit_btn" />
|
||||
<input type="button" value="取消" onclick="history.go(-1);" class="cancel_btn" />
|
||||
<%#= submit_tag('提交',:class=>'mr5') %>
|
||||
<%#= submit_tag('取消') %>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
<script>
|
||||
function submit_edit_school(dom){
|
||||
$("#school_form").submit();
|
||||
}
|
||||
</script>
|
||||
|
||||
|
|
Loading…
Reference in New Issue