fix announcement links & files

This commit is contained in:
unknown committed 2012-03-16 16:49:25 +08:00
commit a755eb184b
84 files changed
+2009 -1672

No files matched your search

+1 -1
View File
@@ -1,5 +1,5 @@
{
"title": "Announcement",
"title": "announcement",
"version": "0.1",
"organization": "Rulingcom",
"author": "RD dep",
@@ -1,5 +1,4 @@
class Panel::Announcement::BackEnd::BulletinsController < ApplicationController
class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
layout 'new_admin'
before_filter :authenticate_user!
@@ -15,7 +14,7 @@ class Panel::Announcement::BackEnd::BulletinsController < ApplicationController
# @bulletins = Bulletin.search(params[:search], params[:category_id])
# @bulletins = Bulletin.all.order_by([params[:sort], params[:direction]])
@bulletins = params[:sort] ? get_sorted_bulletins : Bulletin.limit(1).desc("postdate")
@bulletins = params[:sort] ? get_sorted_bulletins : Bulletin.all
@bulletin_categories = BulletinCategory.all
respond_to do |format|
@@ -137,7 +136,7 @@ class Panel::Announcement::BackEnd::BulletinsController < ApplicationController
# end
respond_to do |format|
if @bulletin.update_attributes(params[:bulletin])
if @bulletin.update_attributes(params[:bulletin]) && @bulletin.save
# format.html { redirect_to(panel_announcement_back_end_bulletin_url(@bulletin), :notice => t('bulletin.update_bulletin_success')) }
format.html { redirect_to(panel_announcement_back_end_bulletins_url, :notice => t('bulletin.update_bulletin_success')) }
format.js { render 'toggle_enable' }
@@ -177,7 +176,17 @@ class Panel::Announcement::BackEnd::BulletinsController < ApplicationController
protected
def get_categorys(id = nil)
@bulletin_categorys = (id ? BulletinCategory.find(id).to_a : BulletinCategory.excludes('disabled' => true))
@bulletin_categorys = []
if(is_manager? || is_admin?)
@bulletin_categorys = (id ? BulletinCategory.find(id).to_a : BulletinCategory.excludes('disabled' => true))
elsif is_sub_manager?
@bulletin_categorys = BulletinCategory.authed_for_user(current_user,'submit_new')
end
end
def get_tags
module_app = ModuleApp.first(:conditions => {:key => 'announcement'})
@tags = Tag.all(:conditions => {:module_app_id => module_app.id}).order_by(I18n.locale, :asc)
end
def get_tags
@@ -0,0 +1,76 @@
class Panel::Announcement::BackEnd::FactChecksController < OrbitBackendController
before_filter :authenticate_user!
include AdminHelper
# layout 'admin'
layout 'new_admin'
def setting
@bulletin_categorys = BulletinCategory.all
if params.has_key?(:category_id)
first_category = BulletinCategory.find params[:category_id]
if params[:commit] == 'Update'
privilege_users = params[:users].collect{|key,value| User.find key } rescue []
preload_object_auth_ary = first_category.object_auths.where(title: 'fact_check') || (first_category.object_auths.create :title=> 'fact_check')
preload_object_auth = preload_object_auth_ary.first
preload_object_auth.privilege_users = privilege_users
preload_object_auth.save!
end
else
first_category = @bulletin_categorys.first
end
preload_object_auth = first_category.object_auths.where(title: 'fact_check') || (first_category.object_auths.create :title=> 'fact_check')
@users_array = preload_object_auth.first.privilege_users rescue []
respond_to do |format|
format.html
format.js
end
end
def update_setting
end
# def index
# get_categorys(params[:bulletin_category_id])
#
# @bulletins = params[:sort] ? get_sorted_bulletins : Bulletin.all
# @bulletin_categories = BulletinCategory.all
#
# module_app = ModuleApp.first(:conditions => {:key => 'announcement'})
# @tags = Tag.all(:conditions => {:module_app_id => module_app.id}).order_by(I18n.locale, :asc)
#
# respond_to do |format|
# format.html # index.html.erb
# format.js
# format.xml { render :xml => @bulletins }
# end
# end
#
# def new
#
# end
#
# def create
#
# end
#
# def update
#
# end
#
# def edit
#
# end
#
# def destroy
#
# end
protected
def get_categorys(id = nil)
@bulletin_categorys = []
if(is_manager? || is_admin?)
@bulletin_categorys = (id ? BulletinCategory.find(id).to_a : BulletinCategory.excludes('disabled' => true))
elsif is_sub_manager?
@bulletin_categorys = BulletinCategory.authed_for_user(current_user,'submit_new')
end
end
end
@@ -1,4 +1,4 @@
class Panel::Announcement::FrontEnd::BulletinsController < ObitWidgetController
class Panel::Announcement::FrontEnd::BulletinsController < OrbitWidgetController
def initialize
super
@@ -11,13 +11,15 @@ class Panel::Announcement::FrontEnd::BulletinsController < ObitWidgetController
def index
date_now = Time.now
if params[:bulletin_category_id]
@bulletins = Bulletin.where(:bulletin_category_id => params[:bulletin_category_id]).any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page]).per(10)
if params[:category_id]
@bulletins = Bulletin.where(:bulletin_category_id => params[:category_id]).any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page]).per(10)
else
@bulletins = Bulletin.any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page]).per(10)
end
get_categorys
get_categorys
@current_category = BulletinCategory.from_id(params[:category_id]) rescue nil
end
def show
@@ -1,4 +1,4 @@
class Panel::Announcement::Widget::BulletinsController < ObitWidgetController
class Panel::Announcement::Widget::BulletinsController < OrbitWidgetController
def initialize
super
@@ -28,6 +28,7 @@ class Panel::Announcement::Widget::BulletinsController < ObitWidgetController
@selected_tag = AnnouncementTag.find(params[:id]) rescue @tags[0]
@bulletins = @selected_tag.get_visible_bulletins.page(params[:page]).per(5) rescue nil
@web_links = WebResourceTag.first(:conditions => {:en => @selected_tag[:en]}).get_visible_links.page(params[:page]).per(5) rescue nil
render :layout => 'module_widget'
end
def reload_bulletins
@@ -4,7 +4,7 @@ class Bulletin
include Mongoid::Document
include Mongoid::Timestamps
include Mongoid::MultiParameterAttributes
has_one :title, :class_name => "I18nVariable", :as => :language_value, :autosave => true, :dependent => :destroy
has_one :subtitle, :class_name => "I18nVariable", :as => :language_value, :autosave => true, :dependent => :destroy
has_one :text, :class_name => "I18nVariable", :as => :language_value, :autosave => true, :dependent => :destroy
@@ -19,6 +19,9 @@ class Bulletin
field :is_top, :type => Boolean, :default => false
field :is_hot, :type => Boolean, :default => false
field :is_hidden, :type => Boolean, :default => false
field :is_checked, :type => Boolean, :default => false
field :not_checked_reason
field :public, :type => Boolean, :default => true
@@ -3,6 +3,10 @@
class BulletinCategory
include Mongoid::Document
include Mongoid::Timestamps
include OrbitCoreLib::ObjectAuthable
ObjectAuthTitlesOptions = %W{submit_new fact_check}
AfterObjectAuthUrl = '/panel/announcement/back_end/bulletin_categorys'
# include Mongoid::MultiParameterAttributes
PAYMENT_TYPES = [ "List", "Picture" ]
@@ -14,4 +18,8 @@ class BulletinCategory
has_many :bulletins
def self.from_id(id)
BulletinCategory.find(id) rescue nil
end
end
@@ -14,4 +14,4 @@
<td><%= bulletin_category.i18n_variable[locale] rescue nil %></td>
<% end %>
<td><%= bulletin_category.display %></td>
</tr>
</tr>
@@ -1,35 +0,0 @@
<% # encoding: utf-8 %>
<div class="field">
<%= f.label :key %><br />
<%= f.text_field :key %>
</div>
<div class="field">
<%= f.label :name %><br />
<%= f.fields_for :i18n_variable, (@bulletin_category.new_record? ? @bulletin_category.build_i18n_variable : @bulletin_category.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 %>
</div>
<div class="field">
<%= f.label :display %> <br />
<%#= f.select :display, BulletinCategory::PAYMENT_TYPES, :prompt => 'Select a display method' %>
<%= f.radio_button :display, "List" %>List
<%#= f.label :display, 'list', :value => '1', :checked => @a %>
<%= f.radio_button :display, "Picture" %>Picture
<%#= f.label :display, 'picture', :value => '2', :checked => @b %>
<br />顯示方式是設定在前台頁面時,資訊所呈現的樣式
</div>
<div class="actions">
<%= f.submit %>
</div>
@@ -1,15 +1,15 @@
<br />
<br />
<br />
<br />
<% content_for :secondary do %>
<ul class="list">
<li><%= link_to t('bulletin_category.index'), panel_announcement_back_end_bulletin_categorys_path, :class => 'seclink2' %></li>
</ul>
<%= render :partial => '/panel/announcement/back_end/announcement_secondary' %>
<% end -%>
<%= flash_messages %>
<br />
<br />
<br />
<br />
<br />
<h1><%= t('bulletin_category.new_announcement_class') %></h1>
<%= form_for @bulletin_category, :url => panel_announcement_back_end_bulletin_categorys_path do |f| %>
<%= render :partial => 'form', :locals => {:f => f} %>
@@ -24,11 +24,12 @@
</ul>
</li>
<li class="dropdown"><%= link_to t('bulletin.delete'), panel_announcement_back_end_bulletin_path(bulletin), :confirm => t('announcement.sure?'), :method => :delete, :remote => true %></li>
<li><%= link_to t('bulletin.fact_check'), edit_panel_announcement_back_end_bulletin_path(bulletin) %></li><%#= #TODO add ancher so user can quick access into that part %>
</ul>
</div>
</td>
<td><%= bulletin.bulletin_category.i18n_variable[I18n.locale] %></td>
<td><%= link_to bulletin.title[I18n.locale], panel_announcement_back_end_bulletin_path(bulletin) %></td>
<td><%= link_to bulletin.title[I18n.locale], panel_announcement_back_end_bulletin_path(bulletin) rescue ''%></td>
<td><%= bulletin.postdate %></td>
<td><%= (bulletin.deadline) ? bulletin.deadline : t('bulletin.no_deadline') %></td>
<td>
@@ -36,7 +37,7 @@
<span class="label label-tags"><%= tag[I18n.locale] %></span>
<% end %>
</td>
<td><%= User.from_id(bulletin.update_user_id).name %></td>
<td><%= User.from_id(bulletin.update_user_id).name rescue ''%></td>
</tr>
<%= render :partial => 'quick_edit', :locals => {:bulletin => bulletin} %>
@@ -36,4 +36,4 @@
</thead>
<tbody class="sort-holder">
<%= render :partial => 'bulletin', :collection => @bulletins %>
</tbody>
</tbody>
@@ -1,6 +1,25 @@
<% # encoding: utf-8 %>
<%= f.error_messages %>
<%= f.select :bulletin_category_id, @bulletin_categorys.collect{|t| [ t.i18n_variable[I18n.locale], t.id ]}, {}, :class => "input-medium" %>
<div class="field">
<%= label :fact_check_stat, t('announcement.bulletin.fact_check_stat') %>
<%= f.radio_button :is_checked, true%>
<%= label :is_checked_true, t('announcement.bulletin.fact_check_pass') %>
<%= f.radio_button :is_checked, false, (@bulletin.is_checked.nil?? {:checked => true} : {}) %>
<%= label :is_checked_false, t('announcement.bulletin.fact_check_not_pass') %>
<%= label :is_checked_false, t('announcement.bulletin.fact_check_not_pass_reason') %>
<%= f.text_field :not_checked_reason %>
</div>
<div class="field">
<%= f.label :image, t('announcement.image') %><br />
<%= f.file_field :image %>
<% if @bulletin.image.file %>
<%= check_box_tag 'bulletin[image_del]' %>
<%= t('announcement.刪除已上傳檔案') %>
<% end %>
</div>
<!--Widget start-->
@@ -83,7 +102,7 @@
</div>
<!--Wiget End-->
<!--Post Start-->
@@ -194,49 +213,6 @@
</div>
<div class="main-wiget">
<div id="widget-link" class="widget-box">
<div class="widget-action clear">
<a class="action"><i title="Add a reference link" class="icon-exclamation-sign icon-white tip"></i></a>
</div>
<h3 class="widget-title"><i class="icons-link icons-white"></i>Link</h3>
<div class="widget-content">
<table class="table table-condensed">
<thead>
<tr>
<th>Chinese</th>
<th>English</th>
<th class="span1"></th>
</tr>
</thead>
<tfoot>
<tr>
<td style="text-align:center" colspan="3">
<a class="btn btn-primary btn-small" href="#modal-link" data-toggle="modal"><i class="icon-plus icon-white"></i> ADD/新增</a>
</td>
</tr>
</tfoot>
<tbody>
<%#= render :partial => 'bulletin_link2', :collection => @bulletin.bulletin_links %>
<% @bulletin.bulletin_links.each_with_index do |bulletin_link2, i| %>
<%= f.fields_for :bulletin_links, bulletin_link2 do |f| %>
<%= render :partial => 'bulletin_link2', :object => bulletin_link2, :locals => {:f => f, :i => i} %>
<% end %>
<% end %>
</tbody>
</table>
</div>
<div id="bulletin_link_qe"><%#= render :partial => "bulletin_link_qe" %></div>
</div>
</div>
<div class="main-wiget">
<div id="widget-file" class="widget-box">
<div class="widget-action clear">
@@ -3,11 +3,11 @@
<td colspan="8">
<legend><%= t(:quick_edit) %> - <span class='qe_title'></span>Basic / Picture / Tags / Link / File</legend>
<%= form_for bulletin, :url => panel_announcement_back_end_bulletin_path(bulletin), :html => {:class => 'form-horizontal'} do |f| %>
<%= render :partial => "quick_edit_basic", :locals => { :f => f, :bulletin => bulletin } %>
<%= render :partial => "quick_edit_picture", :locals => { :f => f, :bulletin => bulletin } %>
<%= render :partial => "quick_edit_tags", :locals => { :f => f, :bulletin => bulletin } %>
<%= render :partial => "quick_edit_links", :locals => { :f => f, :bulletin => bulletin } %>
<%= render :partial => "quick_edit_files", :locals => { :f => f, :bulletin => bulletin } %>
<%= render :partial => "panel/announcement/back_end/bulletins/quick_edit_basic", :locals => { :f => f, :bulletin => bulletin } %>
<%= render :partial => "panel/announcement/back_end/bulletins/quick_edit_picture", :locals => { :f => f, :bulletin => bulletin } %>
<%= render :partial => "panel/announcement/back_end/bulletins/quick_edit_tags", :locals => { :f => f, :bulletin => bulletin } %>
<%= render :partial => "panel/announcement/back_end/bulletins/quick_edit_links", :locals => { :f => f, :bulletin => bulletin } %>
<%= render :partial => "panel/announcement/back_end/bulletins/quick_edit_files", :locals => { :f => f, :bulletin => bulletin } %>
<div class="form-actions">
<%= f.submit t(:submit), :class => 'btn btn-primary' %>
<%= f.submit t(:cancel), :class => 'btn', :type => 'reset' %>
@@ -4,4 +4,4 @@
<%= render :partial => 'form', :locals => {:f => f} %>
<% end %>
<%= link_back %>
<%= link_back %>
@@ -2,11 +2,10 @@
<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>
<% content_for :page_specific_javascript do %>
<%= javascript_include_tag "bulletin_form" %>
<% end %>
<% end %>
@@ -1,6 +1,5 @@
<%= form_for @bulletin, :url => panel_announcement_back_end_bulletins_path do |f| %>
<%= render :partial => 'form', :locals => {:f => f} %>
<% end %>
<%= link_back %>
<%= link_back %>
@@ -1,10 +1,14 @@
<% # encoding: utf-8 %>
<% content_for :secondary do %>
<%= render :partial => '/panel/announcement/back_end/announcement_secondary' %>
<% end -%>
<%= flash_messages %>
<br />
<br />
<br />
<p id="notice"><%= flash_messages %></p>
<br />
<br />
<ul>
<li>
@@ -2,7 +2,11 @@
<%= flash_messages %>
<h1 class="h1"><%= t('announcement.list_announcement') %></h1>
<% if @current_category %>
<h1 class="h1"><%= @current_category.i18n_variable[I18n.locale] + t('announcement.bulletin.list_lower') %></h1>
<% else %>
<h1 class="h1"><%= t('announcement.list_announcement') %></h1>
<% end %>
<table class="table table-bordered">
@@ -24,6 +28,6 @@
<% end %>
</table>
<%= paginate @bulletins %>
<%= paginate @bulletins, :params => {:inner => 'false'} %>
@@ -1,6 +1,6 @@
<% @web_links.each do |web_link| %>
<li>
<a><%= web_link.name[I18n.locale] %></a>
<%= link_to web_link.name[I18n.locale], web_link.url %>
</li>
<% end %>
@@ -35,6 +35,12 @@ en:
list_lower: " list"
title: Title
postdate: Postdate
fact_check: Fact Check
fact_check_setting: Fact Check Setting
fact_check_stat: Fact Check Status
fact_check_not_pass: 'Not Pass'
fact_check_not_pass_reason: 'Reason'
fact_check_pass: 'Pass'
# admin:
# action: Action
# add_language: Add language
@@ -30,6 +30,13 @@ zh_tw:
list_lower: 列表
title: 標題
postdate: 張貼日期
fact_check: 公告審核
fact_check_setting: 審核設定
fact_check_stat: 審核狀況
fact_check_not_pass: '不通過'
fact_check_pass: '通過'
fact_check_not_pass_reason: '不通過原因'
# admin:
# action: 行動
# add_language: 新增語言
+5 -3
View File
@@ -2,6 +2,10 @@ Rails.application.routes.draw do
namespace :panel do
namespace :announcement do
namespace :back_end do
match 'public' => "announcements#public",:as => :public
match 'fact_check_setting' => "fact_checks#setting" ,:as => :fact_checks_setting
match 'update_setting' => "fact_checks#update_setting" ,:as => :fact_checks_update_setting
root :to => "bulletins#index"
resources :bulletins do
match "link_quick_add/:bulletin_id" => "bulletins#link_quick_add" ,:as => :link_quick_add
@@ -10,11 +14,9 @@ Rails.application.routes.draw do
resources :bulletin_categorys, :controller => 'bulletin_categorys' do
match "quick_edit/:bulletin_category_id" => "bulletin_categorys#quick_edit" ,:as => :quick_edit
end
resources :bulletin_links
resources :tags
end
namespace :front_end do
root :to => "bulletins#index"
resources :bulletins
end
namespace :widget do
@@ -25,4 +27,4 @@ Rails.application.routes.draw do
end
end
end
end
end
@@ -1,4 +0,0 @@
# desc "Explaining what the task does"
# task :announcement do
# # Task goes here
# end
@@ -1,4 +1,4 @@
class Panel::NewBlog::FrontEnd::CommentsController < ObitFrontendController
class Panel::NewBlog::FrontEnd::CommentsController < OrbitFrontendController
def create
@post = Post.find(params[:post_id])
@comment = @post.comments.create!(params[:comment])
@@ -1,4 +1,4 @@
class Panel::NewBlog::FrontEnd::PostsController < ObitFrontendController
class Panel::NewBlog::FrontEnd::PostsController < OrbitFrontendController
# GET /posts
# GET /posts.xml
def index
@@ -1,4 +1,4 @@
class Panel::NewBlog::Widget::PostsController < ObitWidgetController
class Panel::NewBlog::Widget::PostsController < OrbitWidgetController
# GET /posts
# GET /posts.xml
def index
@@ -3,7 +3,7 @@
# # Add a load path for this specific Engine
# # config.autoload_paths << File.expand_path("../lib/some/path", __FILE__)
# put "ABC"
# PrototypeR4::Application::Orbit_Apps << "NewBlog"
# Orbit::Application::Orbit_Apps << "NewBlog"
#
# # initializer "my_engine.add_middleware" do |app|
# # app.middleware.use MyEngine::Middleware
@@ -15,4 +15,4 @@ module NewBlog
VERSION = "0.0.1"
MOUDLEAPP_TITLE = "NewBlog"
end
# PrototypeR4::Application::Orbit_Apps << "NewBlog"
# Orbit::Application::Orbit_Apps << "NewBlog"
@@ -1,4 +1,4 @@
class Panel::PageContent::FrontEnd::PageContextsController < ObitWidgetController
class Panel::PageContent::FrontEnd::PageContextsController < OrbitWidgetController
def initialize
super
@@ -1,4 +1,4 @@
class Panel::WebResource::FrontEnd::WebLinksController < ObitWidgetController
class Panel::WebResource::FrontEnd::WebLinksController < OrbitWidgetController
def initialize
super
@@ -1,4 +1,4 @@
class Panel::WebResource::Widget::WebLinksController < ObitWidgetController
class Panel::WebResource::Widget::WebLinksController < OrbitWidgetController
def initialize
super
@@ -14,7 +14,7 @@ class Panel::WebResource::Widget::WebLinksController < ObitWidgetController
# @web_link = WebLink.where( :is_hidden => false ).desc(:is_top, :name).first
@web_links = WebLink.widget_datas.page(params[:page]).per(9)
@web_links = WebLink.widget_datas.page(params[:page]).per(5)
# get_categorys
@@ -24,7 +24,7 @@ class Panel::WebResource::Widget::WebLinksController < ObitWidgetController
end
def reload_web_links
@web_links = WebLink.widget_datas.page(params[:page]).per(9)
@web_links = WebLink.widget_datas.page(params[:page]).per(5)
end