FIX 完善 网站合作单位的相关功能
This commit is contained in:
parent
d479e21221
commit
3877d6e29d
|
@ -8,15 +8,15 @@ class HomesController < ApplicationController
|
|||
@dynamic_news = DynamicNew.desc.limit(4)
|
||||
|
||||
@companies = WebFooterCompany.dedicators
|
||||
# @partners = WebFooterCompany.partners
|
||||
|
||||
@partners = WebFooterCompany.opensources
|
||||
|
||||
@first_companies_group = Array(@companies.slice(0, 5))
|
||||
@second_companies_group = Array(@companies.slice(5, 8))
|
||||
@third_companies_group = Array(@companies.slice(13, 5))
|
||||
end
|
||||
|
||||
def partners
|
||||
@companies = WebFooterCompany.all.group_by {|company| company.key }
|
||||
@companies = WebFooterCompany.where(key: ['opensource', 'dedicator']).group_by(&:key).sort { |a, b| b[0]<=>a[0] }
|
||||
end
|
||||
|
||||
def news
|
||||
|
|
|
@ -4,18 +4,27 @@ class WebFooterCompaniesController < ApplicationController
|
|||
menu_item :plugins, :only => :plugins
|
||||
menu_item :info, :only => :info
|
||||
before_filter :require_admin
|
||||
before_filter :get_type
|
||||
before_filter :find_company, :except => [:index, :new, :create]
|
||||
|
||||
def index
|
||||
@key = params[:key] || 'opensource'
|
||||
scope =
|
||||
if @type == WebFooterCompany::RELATION_TYPE[1]
|
||||
WebFooterCompany.dedicators
|
||||
else
|
||||
case @key
|
||||
when 'partner'
|
||||
WebFooterCompany.partners
|
||||
when 'dedicator'
|
||||
WebFooterCompany.dedicators
|
||||
when 'opensource'
|
||||
WebFooterCompany.opensources
|
||||
end
|
||||
|
||||
@pages, @companies = paginate scope, :per_page => 25
|
||||
@companies = paginateHelper scope, 25
|
||||
@page = (params['page'] || 1).to_i - 1
|
||||
|
||||
respond_to do |format|
|
||||
format.js
|
||||
format.html
|
||||
end
|
||||
end
|
||||
|
||||
def new
|
||||
|
@ -23,19 +32,17 @@ class WebFooterCompaniesController < ApplicationController
|
|||
end
|
||||
|
||||
def create
|
||||
logger.info ""
|
||||
@company = WebFooterCompany.new(params[:web_footer_company])
|
||||
@company.key = (@type == WebFooterCompany::RELATION_TYPE[1]) ? WebFooterCompany::RELATION_TYPE[1] : WebFooterCompany::RELATION_TYPE[0]
|
||||
if @company.save
|
||||
@key = params[:web_footer_company][:key]
|
||||
if @company.save!
|
||||
flash[:notice] = l(:notice_successful_create)
|
||||
redirect_to web_footer_companies_url(type: @type)
|
||||
redirect_to web_footer_companies_url(key: @key)
|
||||
else
|
||||
flash[:error] = "#{l :web_footer_company_create_fail}: #{@company.errors.full_messages[0]}"
|
||||
respond_to do |format|
|
||||
format.html { redirect_to new_web_footer_company_path(type: @type) }
|
||||
format.html { redirect_to new_web_footer_company_path(key: @key) }
|
||||
format.api { render_validation_errors(@company) }
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -72,8 +79,4 @@ class WebFooterCompaniesController < ApplicationController
|
|||
@company = WebFooterCompany.find(params[:id])
|
||||
end
|
||||
|
||||
def get_type
|
||||
@type = params[:type].to_s.strip
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -23,9 +23,9 @@ module HomesHelper
|
|||
|
||||
def render_pool_name poll
|
||||
case poll
|
||||
when 'opensource' then '合作共建开源'
|
||||
when 'partner' then '合作机构'
|
||||
when 'dedicator' then '合作共建平台'
|
||||
else '合作机构'
|
||||
when 'dedicator' then '技术合作单位'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -14,4 +14,8 @@ module WebFooterCompaniesHelper
|
|||
def label_edit_button_name type
|
||||
(@type == WebFooterCompany::RELATION_TYPE[1]) ? l(:label_new_open_source_company) : l(:label_edit_company)
|
||||
end
|
||||
|
||||
def hash_company_types
|
||||
{ "首页合作共建开源" => "opensource", "首页技术合作单位" => "dedicator", "网站页脚合作单位" => "partner" }
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,16 +1,19 @@
|
|||
class WebFooterCompany < ActiveRecord::Base
|
||||
# dedicator: 首页技术合作单位; partner:与平台的合作单位, opensource: 首页共建开源单位
|
||||
# key字段说明:
|
||||
# partner:网站页脚合作单位(管理员页面页脚), dedicator: 首页技术合作单位; opensource: 首页共建开源单位
|
||||
RELATION_TYPE = %w(partner dedicator opensource)
|
||||
acts_as_list
|
||||
attr_accessible :logo_size, :name, :url, :position, :move_to
|
||||
attr_accessible :logo_size, :name, :url, :position, :move_to, :key
|
||||
validates :name, presence: true, length: { maximum: 500 }
|
||||
validates :key, inclusion: { in: %w(partner dedicator opensource), message: "%{value} is not a valid value." }
|
||||
validates :url, length: { maximum: 500 },
|
||||
format: { with: /(http|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:\/~\+#]*[\w\-\@?^=%&\/~\+#])?/,
|
||||
message: :invalid
|
||||
}
|
||||
|
||||
scope :partners, -> { desc.where(:key => WebFooterCompany::RELATION_TYPE[0]) }
|
||||
scope :dedicators, -> { desc.where(:key => WebFooterCompany::RELATION_TYPE[1]) }
|
||||
scope :desc, -> { order('position ASC') }
|
||||
scope :desc, -> { order('position ASC') }
|
||||
scope :partners, -> { desc.where(:key => 'partner') }
|
||||
scope :dedicators, -> { desc.where(:key => 'dedicator') }
|
||||
scope :opensources, -> { desc.where(:key => 'opensource') }
|
||||
|
||||
end
|
||||
|
|
|
@ -6,8 +6,7 @@
|
|||
<%= text_field_tag 'web_title', params[:wbe_title],:value => @first_page.web_title, :size => 30,:style => "font-size:small;width:490px;margin-left:10px;" %>
|
||||
</p>
|
||||
<%= render 'tab_partial' %>
|
||||
<div style="float:right"><%= link_to l(:label_cooperation_compnay), web_footer_companies_path %></div>
|
||||
<div style="float:right; margin-right: 10px"><%= link_to l(:label_open_source_compnay), web_footer_companies_path(type: WebFooterCompany::RELATION_TYPE[1]) %></div>
|
||||
<div style="float:right;"><%= link_to l(:label_cooperation_compnay), web_footer_companies_path %></div>
|
||||
<h4><%=l(:label_web_footer_page)%></h4>
|
||||
|
||||
<p style="margin-left:60px;padding-right: 20px;">
|
||||
|
|
|
@ -1,8 +1,3 @@
|
|||
<%# <% partners.each do |partner| %>
|
||||
<%#= link_to image_tag(url_to_avatar(partner),:alt=> partner.name ), partner.url, :target => "_blank" %>
|
||||
<%# end %>
|
||||
<a href="https://www.openi.org.cn/" target="_blank"><img src="/images/partner/main/p_5.png"></a>
|
||||
<a href="https://www.ihub.org.cn/" target="_blank"><img src="/images/partner/main/p_2.png"></a>
|
||||
<a href="http://opengcc.org/" target="_blank"><img src="/images/partner/main/p_1.png"></a>
|
||||
<a href="http://111.186.57.55/" target="_blank"><img src="/images/partner/main/p_3.png"></a>
|
||||
<a href="http://111.186.57.55/" target="_blank"><img src="/images/partner/main/p_6.png"></a>
|
||||
<% partners.each do |partner| %>
|
||||
<%= link_to image_tag(url_to_avatar(partner),:alt=> partner.name ), partner.url, :target => "_blank" %>
|
||||
<% end %>
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
<a href="<%= homes_path %>" class="c_grey02">首页</a><span class="c_grey02 ml3 mr3">></span>
|
||||
<span>开源生态</span>
|
||||
</p>
|
||||
|
||||
<% @companies.each do |pool, coms| %>
|
||||
<p class="f28 lh24 mb20"><%= render_pool_name(pool) %></p>
|
||||
<ul class="partnerList clearfix mb30">
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
<% companies.each do |company| %>
|
||||
<tr class="<%= cycle("odd", "even")%>" align="center">
|
||||
<td> <%= link_to image_tag(url_to_avatar(company),:size=>"30x30",:alt=>company.name),company.url, :target => "_blank" %> </td>
|
||||
<td style="vertical-align: middle;"><%= company.name %></td>
|
||||
<td style="width:15%; vertical-align: middle;">
|
||||
<%= reorder_links('company', {:action => 'move', :id => company, type: @type}, :put) %>
|
||||
</td>
|
||||
<td class="buttons" style="vertical-align: middle;">
|
||||
<%= link_to l(:button_edit),edit_web_footer_company_path(company, type: @type) %>
|
||||
<%= delete_link web_footer_company_path(company, type: @type) %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
|
@ -4,6 +4,7 @@
|
|||
<input type="hidden" name="type" value="<%= @type %>" />
|
||||
<div>
|
||||
<div class="box tabular">
|
||||
<p><%= f.select :key, options_for_select(hash_company_types, @company.key), :required => true %></p>
|
||||
<p><%= f.text_field :name, :required => true %></p>
|
||||
<p><%= f.text_field :url, :required => true %></p>
|
||||
<p><%= l(:label_url_prompt) %></p>
|
||||
|
|
|
@ -1,6 +1,16 @@
|
|||
<div class="contextual"><%= link_to label_new_button_name(@type), new_web_footer_company_path(type: @type),:class => "icon icon-add" %></div>
|
||||
<div class="contextual"><%= link_to label_new_button_name(@type), new_web_footer_company_path,:class => "icon icon-add" %></div>
|
||||
<h3><%= label_title_name(@type) %></h3>
|
||||
|
||||
<%= form_tag({}, :method => :get, :remote => true) do %>
|
||||
<fieldset>
|
||||
<label for='status'>
|
||||
类别 :
|
||||
</label>
|
||||
<%= select_tag 'key', options_for_select(hash_company_types), :class => "small", :onchange => "remote_search();", :id => "company_type" %>
|
||||
</fieldset>
|
||||
<% end %>
|
||||
|
||||
|
||||
<table class="list">
|
||||
<thead><tr>
|
||||
<th>LOGO</th>
|
||||
|
@ -8,23 +18,25 @@
|
|||
<th>排序</th>
|
||||
<th></th>
|
||||
</tr></thead>
|
||||
<tbody>
|
||||
<% @companies.each do |company| %>
|
||||
<tr class="<%= cycle("odd", "even")%>" align="center">
|
||||
<td> <%= link_to image_tag(url_to_avatar(company),:size=>"30x30",:alt=>company.name),company.url, :target => "_blank" %> </td>
|
||||
<td style="vertical-align: middle;"><%= company.name %></td>
|
||||
<td style="width:15%; vertical-align: middle;">
|
||||
<%= reorder_links('company', {:action => 'move', :id => company, type: @type}, :put) %>
|
||||
</td>
|
||||
<td class="buttons" style="vertical-align: middle;">
|
||||
<%= link_to l(:button_edit),edit_web_footer_company_path(company, type: @type) %>
|
||||
<%= delete_link web_footer_company_path(company, type: @type) %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
<tbody id="web_footer_companies_list">
|
||||
<%= render :partial => 'list', :locals => {:companies => @companies} %>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<div class="pagination"><%= pagination_links_full @pages %></div>
|
||||
<div class="pagination">
|
||||
<%= pagination_links_full @obj_pages, @obj_count ,:per_page_links => false, :remote => true, :flag => true, :is_new => true %>
|
||||
</div>
|
||||
|
||||
<% html_title(l(:label_role_plural)) -%>
|
||||
|
||||
<script type="text/javascript">
|
||||
function remote_search(){
|
||||
var options=$("#company_type option:selected");
|
||||
$.ajax({
|
||||
type: "get",
|
||||
url: "<%= web_footer_companies_path %>",
|
||||
data: {key: options.val()},
|
||||
success: function (data) {
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
$("#web_footer_companies_list").html("<%=escape_javascript(render :partial => 'list', :locals => {:companies => @companies}) %>")
|
||||
$(".pagination").html('<%= pagination_links_full @obj_pages, @obj_count ,:per_page_links => false, :remote => true, :flag => true, :is_new => true %>');
|
|
@ -4,6 +4,7 @@
|
|||
<input type="hidden" name="type" value="<%= @type %>" />
|
||||
<div>
|
||||
<div class="box tabular">
|
||||
<p><%= f.select :key, options_for_select(hash_company_types), :required => true %></p>
|
||||
<p><%= f.text_field :name, :required => true %></p>
|
||||
<p><%= f.text_field :url, :required => true %></p>
|
||||
<p><%= l(:label_url_prompt) %></p>
|
||||
|
|
|
@ -178,6 +178,7 @@ zh:
|
|||
field_hide_mail: 隐藏我的邮件地址
|
||||
field_comments: 注释
|
||||
field_url: 路径
|
||||
field_key: 类别
|
||||
field_logo_size: logo大小
|
||||
field_start_page: 起始页
|
||||
field_subproject: 子项目
|
||||
|
|
|
@ -2876,3 +2876,9 @@ a:hover.Blue-btn{ background:#3598db; color:#fff;}
|
|||
|
||||
.lab_left{width: 80px;text-align: center;line-height: 30px;display: block;float: left}
|
||||
.input_center{height: 30px;line-height: 30px;border-radius: 3px;margin:0px 20px;border:1px solid #ddd;padding-left: 5px ;box-sizing: border-box;width: 200px; }
|
||||
|
||||
.pagination .active {
|
||||
background-color: #3b94d6;
|
||||
border: 1px solid #3b94d6;
|
||||
color: #fff;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue