add new files
This commit is contained in:
parent
a755eb184b
commit
9c8b0235b0
|
@ -0,0 +1,101 @@
|
|||
# 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
|
|
@ -0,0 +1,15 @@
|
|||
<h1><%= bulletin_category.key %></h1>
|
||||
<table>
|
||||
<tr>
|
||||
<th><%= t('bulletin.status') %></th>
|
||||
<th><%= t('bulletin.category') %></th>
|
||||
<th><%= t('bulletin.title') %></th>
|
||||
<th><%= t('bulletin.postdate') %></th>
|
||||
<th><%= t('bulletin.deadline') %></th>
|
||||
<th><%= t('bulletin.action') %></th>
|
||||
</tr>
|
||||
|
||||
<% bulletin_category.bulletins.each do |post| %>
|
||||
<%= render :partial => 'panel/announcement/back_end/bulletins/bulletins', :locals => {:post => post,:fact_check_allow=>true} %>
|
||||
<% end %>
|
||||
</table>
|
|
@ -0,0 +1,7 @@
|
|||
<%= content_tag :div ,:id => "users_checkbox_ary", do -%>
|
||||
<% sys_users = User.all -%>
|
||||
<% sys_users.each do |user| -%>
|
||||
<%= label_tag "lab-user-#{user.id}", user.name rescue '' -%>
|
||||
<%= check_box_tag "[users][#{user.id}]", 'true',users.include?(user) -%>
|
||||
<% end -%>
|
||||
<% end -%>
|
|
@ -0,0 +1,50 @@
|
|||
<%= render 'panel/announcement/back_end/bulletins/filter' %>
|
||||
<table id="bulettin_sort_list" class="table main-list">
|
||||
<%= render 'panel/announcement/back_end/bulletins/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>
|
||||
|
||||
<!--
|
||||
<% content_for :secondary do %>
|
||||
<%#= render :partial => '/panel/announcement/back_end/announcement_secondary' %>
|
||||
<% end -%>
|
||||
|
||||
<%= flash_messages %>
|
||||
|
||||
<br />
|
||||
<br />
|
||||
<br />
|
||||
<br />
|
||||
<br />
|
||||
|
||||
<fieldset><legend><%= t('bulletin.search') %></legend>
|
||||
|
||||
<%= form_for :bulletin, :action => 'search', :method => 'get', :url => panel_announcement_back_end_bulletins_path do |f| %>
|
||||
|
||||
<%#= f.select :bulletin_category_id, @bulletin_categorys.collect {|t| [ t.i18n_variable[I18n.locale], t.id ] },{ :include_blank => t('bulletin.select') }%>
|
||||
|
||||
Category <%#= select_tag "category_id", options_for_select(@bulletin_categorys.collect{|t| [t.i18n_variable[I18n.locale], t.id]}), :prompt => t('bulletin.select') %>
|
||||
|
||||
KeyWord <%#= text_field_tag :search, params[:search], :id => 'search_field' %>
|
||||
|
||||
<%= submit_tag "Search", :name => nil %>
|
||||
|
||||
<% end %>
|
||||
|
||||
|
||||
</fieldset>
|
||||
|
||||
<br />
|
||||
<br />
|
||||
|
||||
<h1><%= t('bulletin.list_announcement') %></h1>
|
||||
|
||||
<div id="check_block">
|
||||
<h1>Check Please</h1>
|
||||
<%#= render :partial => "list_table", :collection => @bulletin_categorys_check,:as => :bulletin_category%>
|
||||
</div>
|
||||
<br />
|
||||
|
||||
-->
|
|
@ -0,0 +1,20 @@
|
|||
<%= label_tag :fact_check_setting, t("announcement.bulletin.fact_check_setting") %>
|
||||
<br/>
|
||||
<%= form_tag('', :remote => true) %>
|
||||
<%= label_tag :category, t("announcement.bulletin.category") %>
|
||||
<%= select_tag "category_id", options_from_collection_for_select(@bulletin_categorys, "id", "key") %>
|
||||
|
||||
<br/>
|
||||
<%= label_tag :role, t("admin.roles") %>
|
||||
<%= content_tag :div do -%>
|
||||
<% form_tag :action => "update_setting" do %>
|
||||
<%= render :partial => "privilege_user", :locals => {:users => @users_array} %>
|
||||
<%= submit_tag "Update" %>
|
||||
<% end -%>
|
||||
<% end -%>
|
||||
|
||||
<script type="text/javascript" charset="utf-8">
|
||||
$('#category_id').change(function() {
|
||||
$(this).parents('form').submit();
|
||||
});
|
||||
</script>
|
|
@ -0,0 +1 @@
|
|||
$("#users_checkbox_ary").replaceWith('<%= (render :partial => 'privilege_user', :locals => {:users => @users_array}).html_safe%>');
|
|
@ -0,0 +1,42 @@
|
|||
|
||||
|
||||
<% 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 ></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 ></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 ></a>
|
||||
</div>
|
||||
|
||||
<% end %>
|
Loading…
Reference in New Issue