From 4c0715616283ced7d44dc67218e512f496a978df Mon Sep 17 00:00:00 2001 From: nccu Date: Mon, 9 Mar 2015 11:11:24 +0800 Subject: [PATCH] fix json & postdate --- app/controllers/admin/newsbulletins_controller.rb | 2 ++ app/views/admin/news/_form.html.erb | 8 +++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/app/controllers/admin/newsbulletins_controller.rb b/app/controllers/admin/newsbulletins_controller.rb index c417448..628ad58 100644 --- a/app/controllers/admin/newsbulletins_controller.rb +++ b/app/controllers/admin/newsbulletins_controller.rb @@ -22,6 +22,7 @@ class Admin::NewsbulletinsController < ApplicationController bulletins = bulletins.where(:category_id.in => params[:categories]) if !params[:categories].blank? bulletins = bulletins.where(:tagged_ids.in => params[:tags]) if !params[:tags].blank? bulletins = bulletins.where(:is_preview.in=>[false,nil]) + bulletins = bulletins.where(:approved.ne => false , :rejected.ne => true) bulletins = bulletins.desc( :is_top, :postdate).page(page_num).per(per_page) @@ -82,6 +83,7 @@ class Admin::NewsbulletinsController < ApplicationController bulletin_count = NewsBulletin.all end bulletin_count = bulletin_count.where(:is_preview.in=>[false,nil]) + bulletin_count = bulletin_count.where(:approved.ne => false , :rejected.ne => true) total_pages = bulletin_count.count # End diff --git a/app/views/admin/news/_form.html.erb b/app/views/admin/news/_form.html.erb index 96b2586..08acfb9 100644 --- a/app/views/admin/news/_form.html.erb +++ b/app/views/admin/news/_form.html.erb @@ -334,9 +334,11 @@ 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); + if (location.pathname.substr(-3)=='new'){ + 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("");