news fix
This commit is contained in:
parent
93f103094e
commit
c9bf5c7ca5
|
@ -62,11 +62,12 @@ class NewsController < ApplicationController
|
|||
end
|
||||
|
||||
anns = news.collect do |a|
|
||||
if a.image_description.nil?
|
||||
if a.image_description.blank?
|
||||
image_description = "裝飾性圖片"
|
||||
else
|
||||
image_description = a.image_description
|
||||
end
|
||||
|
||||
statuses = a.statuses_with_classname.collect do |status|
|
||||
{
|
||||
"status" => status["name"],
|
||||
|
@ -121,7 +122,7 @@ class NewsController < ApplicationController
|
|||
categories.unshift({"name" => t("news.all"), "category-link" => "/#{I18n.locale.to_s + page.url}/"})
|
||||
|
||||
anns = news.collect do |a|
|
||||
if a.image_description.nil?
|
||||
if a.image_description.blank?
|
||||
image_description = "裝飾性圖片"
|
||||
else
|
||||
image_description = a.image_description
|
||||
|
@ -200,7 +201,7 @@ class NewsController < ApplicationController
|
|||
"news_bulletin_links" => links,
|
||||
"categories" => categories,
|
||||
"data" => {
|
||||
"categories-title" => t("news.categories"),
|
||||
"categories-title" => t("news.category"),
|
||||
"title" => HTMLEntities.new.encode(news.title),
|
||||
"category" => news.category.title,
|
||||
"category-link" => "/#{I18n.locale.to_s + page.url}/?category=#{news.category.to_param}",
|
||||
|
@ -212,7 +213,9 @@ class NewsController < ApplicationController
|
|||
"updated_at" => news.postdate.strftime('%Y-%m-%d %H:%M'),
|
||||
"body" => news.text == "" ? "Content unavailable for this language." : news.text,
|
||||
"image" => news.image.url,
|
||||
"view_count" =>news.view_count
|
||||
"view_count" =>news.view_count,
|
||||
"unit-title" => t("news.unit"),
|
||||
"view-count-title" => t("news.view_count")
|
||||
},
|
||||
"impressionist" => (news.is_preview ? nil : news),
|
||||
"url_to_edit"=>url_to_edit
|
||||
|
|
|
@ -25,6 +25,7 @@ class NewsBulletin
|
|||
field :rejection_reason
|
||||
field :is_preview, :type => Boolean, :default => false
|
||||
field :image_description, localize: true
|
||||
field :expirable_created_at, type: DateTime
|
||||
|
||||
field :email_id
|
||||
field :email_sent, :type => Boolean, :default => false
|
||||
|
@ -45,8 +46,14 @@ class NewsBulletin
|
|||
|
||||
before_destroy :destroy_email
|
||||
|
||||
before_create :set_expire
|
||||
def set_expire
|
||||
self.expirable_created_at = Time.now if self.is_preview
|
||||
return true
|
||||
end
|
||||
|
||||
scope :can_display, ->{where(:is_hidden=>false).any_of({:postdate.lt=>Time.now, :deadline.gt=>Time.now},{:postdate.lt=>Time.now, :deadline=>nil}).order_by([:is_top, :desc])}
|
||||
scope :can_display_postdate, ->{where(:is_hidden=>false).any_of({:postdate.lt=>Time.now},{:postdate.lt=>Time.now, :deadline=>nil}).order_by([:is_top, :desc])}
|
||||
scope :can_display_postdate, ->{where(:is_hidden=>false,:postdate.lt=>Time.now).order_by([:is_top, :desc])}
|
||||
scope :is_approved, ->{where(:approved => true)}
|
||||
|
||||
def update_user
|
||||
|
|
|
@ -84,14 +84,14 @@
|
|||
<div class="control-group">
|
||||
<label class="control-label muted"><%= t(:start_date) %></label>
|
||||
<div class="controls">
|
||||
<%= f.datetime_picker :postdate, :no_label => true %>
|
||||
<%= f.datetime_picker :postdate, :no_label => true, :new_record => @news_bulletin.new_record? %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="control-group">
|
||||
<label class="control-label muted"><%= t(:end_date) %></label>
|
||||
<div class="controls">
|
||||
<%= f.datetime_picker :deadline, :no_label => true %>
|
||||
<%= f.datetime_picker :deadline, :no_label => true, :new_record => @news_bulletin.new_record? %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
@ -334,6 +334,10 @@
|
|||
var fileupload_size_limit = fileupload_size_limit_mb*1000*1000; // 1MB
|
||||
|
||||
$(function() {
|
||||
var getDate = new Date();
|
||||
var toDay = getDate.getFullYear()+"/"+ (getDate.getMonth()+1)+"/"+getDate.getDate()+" "+getDate.getHours()+":"+getDate.getMinutes();
|
||||
$('input[name="news_bulletin[postdate]"]').val(toDay);
|
||||
|
||||
$("#main-wrap").after("");
|
||||
|
||||
$(document).on('click', '#add_link', function(){
|
||||
|
@ -401,10 +405,10 @@
|
|||
});
|
||||
|
||||
var slug = data.split('/')[(data.split('/').length-1)];
|
||||
$('#preview-iframe').on('load', function(){
|
||||
$.get('/admin/news/destroy_preview/'+slug,function(data){
|
||||
});
|
||||
});
|
||||
// $('#preview-iframe').on('load', function(){
|
||||
// $.get('/admin/news/destroy_preview/'+slug,function(data){
|
||||
// });
|
||||
// });
|
||||
});
|
||||
$('.main-forms input[name="_method"]').val(method);
|
||||
return false;
|
||||
|
|
|
@ -154,12 +154,20 @@
|
|||
}
|
||||
</style>
|
||||
<% end %>
|
||||
<% content_for :page_specific_javascript do %>
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function() {
|
||||
$('.img-peview').popover({
|
||||
html: true
|
||||
});
|
||||
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function() {
|
||||
$('.img-peview').popover({
|
||||
html: true
|
||||
});
|
||||
</script>
|
||||
<% end %>
|
||||
});
|
||||
|
||||
$(".appoval_button").on("click",function(){
|
||||
var url = $(this).data("approve-link"),
|
||||
modal = $("#approvalModal");
|
||||
modal.find("iframe").attr("src", url);
|
||||
modal.find("#object_id").val($(this).data("id"));
|
||||
modal.modal("show");
|
||||
return false;
|
||||
})
|
||||
</script>
|
||||
|
|
|
@ -7,13 +7,3 @@
|
|||
|
||||
<%= render :partial=> "approval_modal" %>
|
||||
|
||||
<script type="text/javascript">
|
||||
$(".appoval_button").on("click",function(){
|
||||
var url = $(this).data("approve-link"),
|
||||
modal = $("#approvalModal");
|
||||
modal.find("iframe").attr("src", url);
|
||||
modal.find("#object_id").val($(this).data("id"));
|
||||
modal.modal("show");
|
||||
return false;
|
||||
})
|
||||
</script>
|
|
@ -2,8 +2,10 @@ en:
|
|||
|
||||
news:
|
||||
admins: Unit Setting
|
||||
unit: Unit
|
||||
unit: Department
|
||||
category: Category
|
||||
department: Department
|
||||
view_count: View Count
|
||||
all: All
|
||||
table:
|
||||
title : Title
|
||||
|
|
|
@ -24,7 +24,9 @@ zh_tw:
|
|||
ut_prompt: 請選擇單位
|
||||
news:
|
||||
unit: 單位
|
||||
category: 分類
|
||||
department: 系所
|
||||
view_count: 查看次數
|
||||
add_new: 新建
|
||||
all_articles: 文章列表
|
||||
all: 全部類別
|
||||
|
|
|
@ -6,6 +6,7 @@ Rails.application.routes.draw do
|
|||
namespace :admin do
|
||||
post 'news/preview', to: 'news#preview'
|
||||
get 'news/destroy_preview/:slug_title-:uid', to: 'news#destroy_preview'
|
||||
get 'newsbulletins.json', to: 'newsbulletins#get_bulletins'
|
||||
post 'news/approve_news_bulletin', to: 'news#approve_news_bulletin'
|
||||
get 'news_admins/get_departments' => "news_admins#get_departments"
|
||||
resources :news
|
||||
|
|
Loading…
Reference in New Issue