Delete files with Chinese characters in name

This commit is contained in:
Christophe Vilayphiou 2012-03-27 14:17:48 +08:00
parent 42519d9f78
commit 7765f0d2e1
6 changed files with 0 additions and 209 deletions

View File

@ -1,14 +0,0 @@
class Panel::Announcement::BackEnd::BulletinLinksController < ApplicationController
layout 'new_admin'
def index
@bulletin_links = BulletinLink.all
respond_to do |format|
format.html # index.html.erb
# format.xml { render :xml => @bulletins }
format.js
end
end

View File

@ -1,101 +0,0 @@
# encoding: utf-8
class Bulletin
include Mongoid::Document
include Mongoid::Timestamps
include Mongoid::MultiParameterAttributes
# field :category_id, :type => Integer
field :title
# has_one :title_variable, :class_name => "I18nVariable", :as => :language_value, :autosave => true, :dependent => :destroy
# has_one :subtitle_variable, :class_name => "I18nVariable", :as => :language_value, :autosave => true, :dependent => :destroy
# has_one :text_variable, :class_name => "I18nVariable", :as => :language_value, :autosave => true, :dependent => :destroy
field :subtitle
field :text
field :postdate , :type => Date
field :deadline , :type => Date
# field :url
field :create_user_id
field :update_user_id
field :is_top, :type => Boolean, :default => false
mount_uploader :image, ImageUploader
belongs_to :bulletin_category
embeds_many :bulletin_links, :cascade_callbacks => true
embeds_many :bulletin_files, :cascade_callbacks => true
# has_many :bulletin_files, :autosave => true, :dependent => :destroy
accepts_nested_attributes_for :bulletin_files, :allow_destroy => true
accepts_nested_attributes_for :bulletin_links, :allow_destroy => true
# validates_presence_of :title_variable
validates_presence_of :title
after_save :save_bulletin_links
after_save :save_bulletin_files
def self.search( search = nil, category_id = nil )
if category_id.to_s.size > 0 and search.to_s.size > 0
key = /#{search}/
find(:all, :conditions => {title: key, bulletin_category_id: category_id}).desc( :is_top, :postdate )
elsif category_id.to_s.size > 0 and search.to_s.size < 1
find(:all, :conditions => {bulletin_category_id: category_id}).desc( :is_top, :postdate )
elsif search.to_s.size > 0 and category_id.to_s.size < 1
key = /#{search}/
find(:all, :conditions => {title: key}).desc( :is_top, :postdate )
else
find(:all).desc( :is_top, :postdate)
end
end
def self.widget_datas
date_now = Time.now
# find(:all, :conditions => {:postdate => {"$lte" => Date.today}, deadline: nil} ).desc( :is_top, :postdate)
# where( :postdate.lte => date_now ).where( :deadline => nil ).desc(:is_top, :postdate)
# any_of({ :title => "test" },{:deadline => nil, :title => "123"})
any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).limit(5)
end
def is_top?
self.is_top
end
def save_bulletin_links
self.bulletin_links.each do |t|
if t.should_destroy
t.destroy
end
end
end
def save_bulletin_files
self.bulletin_files.each do |t|
if t.should_destroy
t.destroy
end
end
end
end

View File

@ -1,27 +0,0 @@
<div id="<%= "bulletin_#{bulletin_link.id}" if !bulletin_link.new_record? %>" class='list_item'>
<div class="field">
<%= f.label :link_url %>
<%= f.text_field :url %>
<%= f.label :link_name %>
<%#= f.text_field :name %>
<%= f.fields_for :i18n_variable, (bulletin_link.new_record? ? bulletin_link.build_i18n_variable : bulletin_link.i18n_variable) do |f| %>
<% @site_valid_locales.each do |locale| %>
<%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %>
<%= f.text_field locale, :style => "width:130px" %>
<% end %>
<% end %>
<span class="action">
<% if bulletin_link.new_record? %>
<a href="#" class="delete"><%= t(:delete) %></a>
<% else %>
<%= f.hidden_field :id %>
<a href="#" class="remove_existing_record"><%= t(:delete) %></a>
<%= f.hidden_field :should_destroy, :value => nil, :class => 'should_destroy' %>
<% end %>
</span>
</div>
</div>

View File

@ -1,16 +0,0 @@
<tr id="<%= "bulletin_#{bulletin_link2.id}" %>">
<td><%= link_to bulletin_link2.i18n_variable.zh_tw, bulletin_link2.url, :target => '_blank' %></td>
<td><%= link_to bulletin_link2.i18n_variable.en, bulletin_link2.url, :target => '_blank' %></td>
<td><a href="#modal-link" data-toggle="modal" class="action"><i class="icon-pencil"></i></a>
<span class="action">
<%= f.hidden_field :id %>
<a href class="remove_existing_record"><i class="icon-remove"></i></a>
<%= f.hidden_field :should_destroy, :value => nil, :class => 'should_destroy' %>
</span>
</td>
</tr>

View File

@ -1,9 +0,0 @@
<%= render 'filter' %>
<table id="bulettin_sort_list" class="table main-list">
<%= render 'bulletins' %>
</table>
<div class="form-actions">
<%= link_to content_tag(:i, nil, :class => 'icon-plus icon-white') + t('admin.add'), new_panel_announcement_back_end_bulletin_path, :class => 'btn btn-primary' %>
</div>

View File

@ -1,42 +0,0 @@
<% if @bulletin and !@bulletin.nil? %>
<div id="col1" class="col">
<h1 class="h1 ini_heading col_title"><%= @bulletin.title %></h1>
<p class="ini_txt"><%= @bulletin.subtitle %></p>
<%= link_to "read more >",panel_announcement_front_end_bulletin_path(@bulletin.id) %>
<a class="btn" href="">read more &gt;</a>
</div>
<% end %>
<% if @bulletins and !@bulletins.nil? %>
<div id="col2" class="col">
<h1 class="h1 ini_heading col_title">news</h1>
<ul class="ini_list">
<% @bulletins.each do |post| %>
<li><span class="time"><%= post.postdate.to_s.gsub("-", "") %></span><%= link_to post.title,panel_announcement_front_end_bulletin_path(post) %></li>
<% end %>
</ul>
<%= link_to "read more >",panel_announcement_front_end_bulletins_path(), :class => "btn" %>
<a class="btn" href="announcement">read more &gt;</a>
</div>
<div id="col2" class="col">
<h1 class="h1 ini_heading col_title">news</h1>
<ul class="ini_list">
<% @bulletins.each do |post| %>
<li>
<%= image_tag(post.image.url, :size => "160x140") if post.image.file %>
<h4><%= post.title %></h4>
<%= post.subtitle %>
</li>
<% end %>
</ul>
<%= link_to "read more >",panel_announcement_front_end_bulletins_path(), :class => "btn" %>
<a class="btn" href="announcement">read more &gt;</a>
</div>
<% end %>