Merge commit '7c55f6fb8850ef426978dd422fa782358f9ec2fe' into ldap

Conflicts:
	config/environments/development.rb
This commit is contained in:
Matt Fu 2012-03-01 10:13:49 +08:00
commit 7f05f21930
63 changed files with 1358 additions and 985 deletions

View File

@ -22,7 +22,7 @@ gem 'rubyzip'
gem 'sinatra'
gem 'sprockets'
gem 'tinymce-rails'
# gem 'therubyracer'
gem 'therubyracer'

View File

@ -84,6 +84,7 @@ GEM
railties (~> 3.0)
thor (~> 0.14)
json (1.6.5)
libv8 (3.3.10.4)
linecache19 (0.5.12)
ruby_core_source (>= 0.1.4)
mail (2.3.0)
@ -182,6 +183,8 @@ GEM
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
subexec (0.2.1)
therubyracer (0.9.9)
libv8 (~> 3.3.10)
thor (0.14.6)
tilt (1.3.3)
tinymce-rails (3.4.8)
@ -239,6 +242,7 @@ DEPENDENCIES
sinatra
spork
sprockets
therubyracer
tinymce-rails
uglifier
watchr

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

View File

@ -1,77 +1,97 @@
var viewportwidth,
viewportheight;
function resize() {
viewportheight=$(window).height();
viewportwidth=$(window).width();
if(window.navigator.userAgent.indexOf("MSIE")>0){
windH=document.clientHeight;
windW=document.clientWidht;
}
}
$(document).ready(function(){
$(document).on('click', '.orbit-bar-member', function(){
$(this).hasClass('open') ? $(this).removeClass('open') : $(this).addClass('open');
$('.bar-login .dropdown-menu').toggle();
return false;
});
$(document).click(function() {
$('.orbit-bar-member').removeClass("open");
$('.bar-login .dropdown-menu').hide();
});
$(document).on('click', '.bar-login .dropdown-menu', function(e) {
e.stopPropagation();
$('.bar-login .dropdown-menu').show();
});
$('.tip').tooltip({
placement: "left"
});
$(document).on('click', '.privacy', function() {
switch ($(this).val()) {
case 'true':
$(this).parents('.controls').children('.select-role').slideUp(300);
break;
case 'false':
$(this).parents('.controls').children('.select-role').slideDown(300);
break;
}
});
$(document).on('click', '.toggle-tr-edit', function() {
$(this).parents('tr').next('.qe-block').removeClass('hide');
$(this).parents('tr').next('.qe-block').find('.qe-edit-div').addClass('hide');
$(this).parents('tr').next('.qe-block').find('#qe-' + $(this).attr('rel')).toggleClass('hide');
});
$(document).on('click', '.sort-header > .sort', function() {
$.getScript($(this).attr('rel'));
});
/*tinyscrollbar&windows-Size*/
resize();
$('#main-sidebar').css("height", viewportheight-40);
$('#main-sidebar .viewport').css("height", viewportheight-40);
$('.post-title').css("width", viewportwidth-495);
$('#main-sidebar').tinyscrollbar();
$('.detal-list').tinyscrollbar();
$('#main-sidebar').tinyscrollbar({size:(viewportheight-44)});
/*isotope*/
var $container = $('#isotope');
$container.isotope({
itemSelector : '.item',
layoutMode : 'masonry',
});
});
$(window).resize(function(){
resize();
$('#main-sidebar').css("height", viewportheight-40);
$('#main-sidebar .viewport').css("height", viewportheight-40);
$('.post-title').css("width", viewportwidth-495);
$('#main-sidebar').tinyscrollbar({ size:(viewportheight-44)});
});
var viewportwidth,
viewportheight;
function resize() {
viewportheight=$(window).height();
viewportwidth=$(window).width();
if(window.navigator.userAgent.indexOf("MSIE")>0){
windH=document.clientHeight;
windW=document.clientWidht;
}
}
$(document).ready(function(){
$(document).on('click', '.orbit-bar-member', function(){
$(this).hasClass('open') ? $(this).removeClass('open') : $(this).addClass('open');
$('.bar-login .dropdown-menu').toggle();
return false;
});
$(document).click(function() {
$('.orbit-bar-member').removeClass("open");
$('.bar-login .dropdown-menu').hide();
});
$(document).on('click', '.bar-login .dropdown-menu', function(e) {
e.stopPropagation();
$('.bar-login .dropdown-menu').show();
});
$('.tip').tooltip({
placement: "left"
});
$(document).on('click', '.privacy', function() {
switch ($(this).val()) {
case 'true':
$(this).parents('.controls').children('.select-role').slideUp(300);
break;
case 'false':
$(this).parents('.controls').children('.select-role').slideDown(300);
break;
}
});
$(document).on('click', '.toggle-tr-edit', function() {
$(this).parents('tr').next('.qe-block').removeClass('hide');
$(this).parents('tr').next('.qe-block').find('.qe-edit-div').addClass('hide');
$(this).parents('tr').next('.qe-block').find('#qe-' + $(this).attr('rel')).toggleClass('hide');
});
$(document).on('click', '.sort-header > .sort', function() {
$.getScript($(this).attr('rel'));
});
/*tinyscrollbar&windows-Size*/
resize();
$('#main-sidebar').css("height", viewportheight-40);
$('#main-sidebar .viewport').css("height", viewportheight-40);
$('.post-title').css("width", viewportwidth-495);
$('#main-sidebar').tinyscrollbar();
$('.detal-list').tinyscrollbar();
$('#main-sidebar').tinyscrollbar({size:(viewportheight-44)});
/*isotope*/
var $container = $('#isotope');
$container.isotope({
itemSelector : '.item',
layoutMode : 'masonry',
});
});
$(window).resize(function(){
resize();
var $mainWrapMarginLeft = parseInt($('#main-wrap').css("margin-left"))-2;
$('#main-sidebar').css("height", viewportheight-30);
$('#main-sidebar .viewport').css("height", viewportheight-30);
$('.post-title').css("width", viewportwidth-495);
$('#main-wrap > .subnav').css("width", viewportwidth-$mainWrapMarginLeft)
$('#main-sidebar').tinyscrollbar({size:(viewportheight-34)});
mainTablePosition()
});
/*main-table position*/
function mainTablePosition() {
var $height = $('#main-wrap > .subnav').height()
var $table = $('#main-wrap > .table')
//alert ($table.height())
$table.stop().animate({marginTop:$height},500)
//$table.css({marginTop : $height})
}
$(window).scroll(function () {
//var $mainWrapMarginLeft = parseInt($('#main-wrap').css("margin-left"))-1;
//var $subnavWidth = parseInt($('#main-wrap > .subnav').css("width"));
var $winLeft = $(window).scrollLeft()
$(".table-label").css({left:$winLeft*-1} );
//$(".table-label").css({left:$mainWrapMarginLeft+($winLeft*-1)} );
//$("#main-wrap > .subnav").css({width:$subnavWidth+($winLeft)} );
//console.log($mainWrapMarginLeft+($winLeft*-1)+5);
});

View File

@ -2642,8 +2642,8 @@ button.btn.small, input[type="submit"].btn.small {
color: #333333;
}
.pagination {
height: 36px;
margin: 18px 0;
height: 36px;
margin: 18px 0;
}
.pagination ul {
display: inline-block;
@ -2663,7 +2663,8 @@ button.btn.small, input[type="submit"].btn.small {
.pagination li {
display: inline;
}
.pagination a {
.pagination .page{
float: left;
padding: 0 14px;
line-height: 34px;
@ -2671,6 +2672,28 @@ button.btn.small, input[type="submit"].btn.small {
border: 1px solid #ddd;
border-left-width: 0;
}
.pagination a {
float: left;
}
.pagination .next{
float: left;
padding: 0 14px;
line-height: 34px;
text-decoration: none;
border: 1px solid #ddd;
border-left-width: 0;
}
.pagination .last{
float: left;
padding: 0 14px;
line-height: 34px;
text-decoration: none;
border: 1px solid #ddd;
border-left-width: 0;
}
.pagination .current{
border-left-width: 1px;
}
.pagination a:hover, .pagination .active a {
background-color: #f5f5f5;
}

File diff suppressed because it is too large Load Diff

View File

@ -21,7 +21,10 @@ class Admin::AppAuthsController < ApplicationController
def create
app_auth = AppAuth.find_or_create_by(module_app_id: params[:module_app_id])
params[:new].each do |item|
auth_all = params[:auth_all] || false
app_auth.update_attribute(:all,auth_all)
new_array = params[:new] || []
new_array.each do |item|
field = item[0]
field_value = item[1]
if field_value!=''
@ -66,6 +69,8 @@ class Admin::AppAuthsController < ApplicationController
@module_app = ModuleApp.find(params[:id])
end
def show
@module_app = ModuleApp.find(params[:id])
end
end

View File

@ -21,6 +21,10 @@ class Admin::ModuleAppsController < ApplicationController
@module_app = ModuleApp.find(params[:id])
end
def show
@module_app = ModuleApp.find(params[:id])
end
def update
@module_app = ModuleApp.find(params[:id])
@ -97,7 +101,7 @@ class Admin::ModuleAppsController < ApplicationController
end
#user is not permited to do that
flash[:notice] = t('admin.app_auth.operation_not_permitted')
redirect_to :action => "edit" # [TODO] maybe need to redirect to some other page
render :nothing => true, :status => 403
end
@ -109,7 +113,7 @@ class Admin::ModuleAppsController < ApplicationController
end
#user is not permited to do that
flash[:notice] = t('admin.app_auth.operation_not_permitted')
redirect_to :action => "edit" # [TODO] maybe need to redirect to some other page
render :nothing => true, :status => 403
end
end

View File

@ -1,8 +1,12 @@
class Admin::ObjectAuthsController < ApplicationController
include OrbitCoreLib::PermissionUnility
layout "admin"
before_filter :authenticate_user!
before_filter :check_if_user_can_do_object_auth
# before_filter :is_admin? ,:only => :index
def index
# if current_user.admin?
@object_auths = ObjectAuth.all
@ -14,6 +18,7 @@ class Admin::ObjectAuthsController < ApplicationController
def new
obj = eval(params[:type]).find params[:obj_id]
@object_auth=obj.object_auths.build
@object_auth_title_option = eval(params[:type]+"::ObjectAuthTitlesOptions")
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @post }
@ -22,13 +27,21 @@ class Admin::ObjectAuthsController < ApplicationController
def create
obj = eval(params[:object_auth][:type]).find params[:object_auth][:obj_id]
@object_auth=obj.object_auths.create :title=> params[:object_auth][:title]
redirect_to edit_admin_object_auth_path(@object_auth)
@object_auth=obj.object_auths.build :title=> params[:object_auth][:title]
if @object_auth.save
redirect_to edit_admin_object_auth_path(@object_auth)
else
flash[:error] = t('admin.object.a_object_must_have_only_one_object_auth_profile_for_each_action')
redirect_to (:back)
end
end
def create_role
object_auth = ObjectAuth.find(params[:id])
params[:new].each do |item|
auth_all = params[:auth_all] || false
object_auth.update_attribute(:all,auth_all)
new_array = params[:new] || []
new_array.each do |item|
field = item[0]
field_value = item[1]
if field_value!=''
@ -69,7 +82,11 @@ class Admin::ObjectAuthsController < ApplicationController
def edit
@object_auth = ObjectAuth.find(params[:id])
end
private
def check_if_user_can_do_object_auth
unless check_permission(:manager)
render :nothing => true, :status => 403
end
end
end

View File

@ -1,3 +0,0 @@
class ObitFrontendController< ObitFrontendComponentController
end

View File

@ -1,3 +0,0 @@
class ObitWidgetController< ObitFrontendComponentController
end

View File

@ -0,0 +1,23 @@
class OrbitBackendController< ApplicationController
before_filter :authenticate_user!
before_filter :setup_vars
# before_filter {|c| c.front_end_available(@app_title)}
before_filter :check_user_can_use,:except => [:public]
include OrbitCoreLib::PermissionUnility
layout 'admin'
def setup_vars
@app_title = request.fullpath.split('/')[2]
@module_app = ModuleApp.first(conditions: {:key => @app_title} )
end
private
def check_user_can_use
unless check_permission
redirect_to polymorphic_path(['panel',@app_title,'back_end','public'])
end
end
end

View File

@ -1,4 +1,4 @@
class ObitFrontendComponentController< ApplicationController
class OrbitFrontendComponentController< ApplicationController
before_filter :setup_vars
before_filter {|c| c.front_end_available(@app_title)}
layout 'module_widget'

View File

@ -0,0 +1,3 @@
class OrbitFrontendController< OrbitFrontendComponentController
end

View File

@ -0,0 +1,3 @@
class ObitWidgetController< OrbitFrontendComponentController
end

View File

@ -3,4 +3,9 @@ module Admin::AppAuthHelper
link_to t(:enable), eval("admin_#{attribute_type}_path(attribute, :authenticity_token => form_authenticity_token, :#{attribute_type} => {:disabled => true})"), :remote => true, :method => :put, :id => "disable_#{attribute.id}", :style => "display:#{attribute.is_disabled? ? 'none' : ''}", :class => 'switch'
link_to t(:disable), eval("admin_#{attribute_type}_path(attribute, :authenticity_token => form_authenticity_token, :#{attribute_type} => {:disabled => false})"), :remote => true, :method => :put, :id => "enable_#{attribute.id}", :style => "display:#{attribute.is_disabled? ? '' : 'none'}", :class => 'switch'
end
def if_permitted_to(user,role)
end
end

View File

@ -5,4 +5,17 @@ module AdminHelper
link_to('/' , admin_items_path) + ( @parent_items.map{ |i| link_to(i.name, admin_items_path(:parent_id=>i.id) ) } << @parent_item.name ).join("/").html_safe
end
# Check if the current_user is manager in current module app
def is_manager?
@module_app.is_manager?(current_user) || is_admin?
end
# Check if the current_user is sub manager in current module app
def is_sub_manager?
@module_app.is_sub_manager?(current_user)|| is_admin?
end
def is_admin?
current_user.admin?
end
end

View File

@ -2,4 +2,5 @@ class AppAuth < PrototypeAuth
belongs_to :module_app
end

View File

@ -1,6 +1,7 @@
class ModuleApp
include Mongoid::Document
include Mongoid::Timestamps
include OrbitCoreLib::ObjectTokenUnility
field :key
field :title
@ -14,7 +15,7 @@ class ModuleApp
field :app_pages ,type: Array
field :widgets ,type: Array
has_many :managers,as: :managing_app ,:class_name => "AppManager" #,:dependent => :destroy,:foreign_key => "managing_app_id",:inverse_of => :managing_app
has_many :sub_managers,as: :sub_managing_app ,:class_name => "AppManager"#, :dependent => :destroy,:foreign_key => "sub_managing_app_id",:inverse_of => :sub_managing_app
@ -26,6 +27,14 @@ class ModuleApp
before_save :set_key
def is_manager?(user)
managing_users.include?(user)
end
def is_sub_manager?(user)
sub_managing_users.include?(user) || is_manager?(user)
end
def managing_users
self.managers.collect{ |t| t.user }
end
@ -73,5 +82,6 @@ class ModuleApp
def set_key
self.key = self.title.underscore if self.title
end
end

View File

@ -1,5 +1,6 @@
class ObjectAuth < PrototypeAuth
include OrbitCoreLib::ObjectTokenUnility
validates_uniqueness_of :obj_authable_type,:scope => :title #{ |c| }
belongs_to :obj_authable, polymorphic: true
# > - Something.find_with_auth(query)
# > - or Something.find(query).auth

View File

@ -4,7 +4,6 @@ class PrototypeAuth
# after_save :update_block_list,:update_privilage_list
field :title
field :token
field :all ,type: Boolean,default: false
belongs_to :users
@ -12,11 +11,12 @@ class PrototypeAuth
has_and_belongs_to_many :blocked_users, :inverse_of => nil, :class_name => "User"
has_and_belongs_to_many :privilege_users, :inverse_of => nil, :class_name => "User"
has_and_belongs_to_many :roles
has_and_belongs_to_many :sub_roles
attr_protected :roles,:sub_roles,:privilege_users,:blocked_users,:users
attr_protected :roles,:sub_roles,:privilege_users,:blocked_users
def add_role role
add_operation(:roles,role)
@ -68,7 +68,7 @@ class PrototypeAuth
end
end
def auth_users
def auth_users_before_block_list
if self.all?
User.all.entries
else
@ -83,11 +83,10 @@ class PrototypeAuth
end
end
def auth_users_after_block_list
auth_users - self.blocked_users
def auth_users
auth_users_before_block_list - self.blocked_users
end
# protected
end

View File

@ -0,0 +1 @@
<%= f.select :module_app_id, @apps.collect { |t| [t.title.capitalize, t.id] }, {:include_blank => true} ,{:rel => admin_module_apps_path } %>

View File

@ -1,3 +1,10 @@
<div id="open_for_all_user">
<h1>All User</h1>
<%= form_tag(submit_url) do %>
<%= check_box_tag 'auth_all',true,(auth.all rescue true) %><%= submit_tag 'Add Role' %><br/>
<% end %>
</div>
<div id="user_role_management">
<h1>User Role</h1>
<%= form_tag(submit_url) do %>
@ -10,7 +17,6 @@
<%= collection_select(:new,:blocked_user, User.all, :id, :name, :prompt => true) %>
<%= submit_tag 'Add BlockedList' %><br/>
<% end %>
<ul>Roles </ul>
<% unless auth.nil? %>
<% auth.roles.each do |role| %>
<li> <%= role.key %> Build in:<%= role.built_in ? 'Yes' : 'No' %>

View File

@ -1 +0,0 @@
<%= f.select :module_app_id, @apps.collect { |t| [t.title.capitalize, t.id] }, {}, {:rel => admin_module_apps_path } %>

View File

@ -0,0 +1,37 @@
<br /><br /><br /><br />
<%=@module_app.key %><br />
<%=@module_app.title %><br />
<%=@module_app.version %><br />
<%=@module_app.organization %><br />
<%=@module_app.author %><br />
<%=@module_app.intro %><br />
<%=@module_app.update_info %><br />
<%=@module_app.create_date %><br />
<%=@module_app.enable_frontend%><br />
<%=@module_app.app_pages%><br />
<%=@module_app.widgets%><br />
Mangers:
<ul>
<% @module_app.managers.each do |manager|%>
<li><%= manager.user.name %></li>
<%end%>
</ul>
SubManagers:
<div>
<% @module_app.sub_managers.each do |manager|%>
<%= manager.user.name %>
<%end%>
</div>
<br />
All User?:<%= @module_app.app_auth.all %><br />
Blocked Users:<%= @module_app.app_auth.blocked_users.collect{|t| t.name} %><br />
Privilege Users:<%= @module_app.app_auth.privilege_users.collect{|t| t.name}%><br />
User Roles:<%= @module_app.app_auth.roles.collect{|t| t.key} %><br />
User Sub Roles:<%= @module_app.app_auth.sub_roles.collect{|t| t.key} %><br />
Available users after calculation:
<%= @module_app.app_auth.auth_users.collect{|user| user.name}.join(',') %>

View File

@ -11,4 +11,4 @@
<%= render :partial => "admin/components/user_role_management", :locals => {
:object => @object_auth.auth_obj ,:auth=>@object_auth,:submit_url=>create_role_admin_object_auth_path(@object_auth),:ploy_route_ary=>['remove',:admin,@object_auth] } %>
<%= link_to 'Back to object',eval(@object_auth.obj_authable.class.to_s+"::AfterObjectAuthUrl") %>

View File

@ -12,7 +12,8 @@
<h1><%= t('object_auth.new_object_auth') %></h1>
<%= form_for @object_auth, :url => admin_object_auths_path do |f| %>
<%= f.label :title %>
<%= f.text_field :title, :class => 'text' %>
<%= f.select :title,@object_auth_title_option %>
<%= f.hidden_field :obj_id, :value => params[:obj_id] %>
<%= f.hidden_field :type, :value => params[:type] %>

View File

@ -26,10 +26,10 @@
</ul>
</li>
<% if user_signed_in? %>
<li class="dropdown active clear">
<li class="dropdown active">
<a class="orbit-bar-account" href="#" data-toggle="dropdown">
<!-- <img src="images/menber-pic.png" /> -->
<%= image_tag current_user.avatar.thumb.url, :class => 'member-img' %>
<img class="member-img" src="/assets/menber-pic.png" />
<%#= image_tag current_user.avatar.thumb.url, :class => 'member-img' %>
<span class="member-name"><%= current_user.name %></span>
</a>
<ul class="dropdown-menu account-menu">
@ -45,7 +45,7 @@
<%= t(:desktop) %>
</a>
</li>
<li><%= link_to content_tag(:i, nil, :class => 'icons-out') + t(:logout), destroy_user_session_path %></li>
<li><%= link_to content_tag(:i, nil, :class => 'icons-out') + ' ' + t(:logout), destroy_user_session_path %></li>
<li class="divider"></li>
<li>
@ -95,7 +95,7 @@
<% end %>
</ul>
<form class="navbar-search span6" action="">
<input class="search-query span4" type="text" placeholder="Search NCCU">
<input class="search-query span4" type="text" placeholder="<%= t(:search_nccu) %>">
</form>
</div>
</div>

View File

@ -13,7 +13,7 @@
<% end -%>
<%= content_tag :li, :class => active_for_controllers('users') do -%>
<%= link_to content_tag(:i, nil, :class => 'icons-member') + t('admin.member'), panel_web_resource_back_end_web_links_path %>
<%= link_to content_tag(:i, nil, :class => 'icons-member') + t('admin.member'), admin_users_path %>
<% end -%>
<%= content_tag :li, :class => active_for_controllers(nil) do -%>
@ -25,7 +25,7 @@
<% end -%>
<%= content_tag :li, :class => active_for_controllers(nil) do -%>
<%= link_to content_tag(:i, nil, :class => 'icons-link') + t('admin.link'), nil %>
<%= link_to content_tag(:i, nil, :class => 'icons-link') + t('admin.link'), panel_web_resource_back_end_web_links_path %>
<% end -%>
<%= content_tag :li, :class => active_for_controllers(nil) do -%>

View File

@ -47,7 +47,7 @@ module PrototypeR4
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
# config.i18n.default_locale = :de
config.i18n.default_locale = :en
config.i18n.default_locale = :zh_tw
# JavaScript files you want as :defaults (application.js is always included).
# config.action_view.javascript_expansions[:defaults] = %w(jquery rails)

View File

@ -28,7 +28,7 @@ PrototypeR4::Application.configure do
# :email_prefix => "[R4_error]",
# :sender_address => %{"notifier" <redmine@rulingcom.com>},
# :exception_recipients => %w{chris@rulingcom.com}
#
# config.action_mailer.delivery_method = :smtp
# config.action_mailer.smtp_settings = {
# :tls => true,

View File

@ -32,6 +32,7 @@ en:
password: Password
register: Register
remember_me: Remember me
search_nccu: Search NCCU
show: Show
submit: Submit
sure?: Are you sure?

View File

@ -17,7 +17,7 @@ zh_tw:
edit: 編輯
email: 電子郵件
enable: 啟用
forget_password: 忘記密碼?
forgot_password: 忘記密碼?
help: 協助
hide: 隱藏
homepage: 首頁
@ -25,10 +25,11 @@ zh_tw:
logout: 登出
no_: "No"
nothing:
or_lower:
or_lower:
password: 密碼
register: 註冊
remember_me: 記住我
search_nccu: 搜尋政大
show: 顯示
submit: 送出
sure?: 您肯定嗎?

View File

@ -31,4 +31,44 @@ module OrbitCoreLib
end
end
module ObjectTokenUnility
def self.included(base)
base.instance_eval("field :s_token")
base.instance_eval("after_create :generate_token")
end
def token
return self.s_token
end
protected
def generate_token
self.s_token = ActiveSupport::SecureRandom.hex(16)
self.save!
end
end
module PermissionUnility
private
def check_permission(type = :use)
permission_grant = current_user.admin?? true : false
module_app = @module_app.nil?? find_module_app_by_token(params[:token]) : @module_app
unless permission_grant
permission_grant = case type
when :use
users_ary = module_app.app_auth.auth_users rescue nil
users_ary = [] if users_ary.nil?
(users_ary.include?(current_user) || module_app.is_manager?(current_user) || module_app.is_sub_manager?(current_user))
when :manager
module_app.is_manager?(current_user)
when :sub_manager
module_app.is_manager?(current_user) || module_app.is_sub_manager?(current_user)
end
end
permission_grant
end
def find_module_app_by_token(token)
ModuleApp.first(conditions: {s_token: token})
end
end
end

View File

@ -81,7 +81,7 @@ module ParserFrontEnd
res << "<script type='text/javascript' src='/assets/orbit_bar.js'></script>"
res << "<script type='text/javascript' src='/assets/event.js'></script>"
page.design.javascripts.each do |js|
res << "<script type='text/javascript' src='#{js.file.url}'></script>"
# res << "<script type='text/javascript' src='#{js.file.url}'></script>"
end
res
end

22
lib/tasks/anc_tasks.rake Normal file
View File

@ -0,0 +1,22 @@
# encoding: utf-8
namespace :anc do
task :build => :environment do
bulletin_category_1 = BulletinCategory.create(:key => "C1ChrisCheckANDPreivew",:display => "List" )
bulletin_category_1.create_i18n_variable(:en => "ChrisCheckANDPreivew", :zh_tw => 'ChrisCheckANDPreivew')
bulletin_category_2 = BulletinCategory.create(:key => "C2MattCheckANDPreivew",:display => "List" )
bulletin_category_2.create_i18n_variable(:en => "MattCheckANDPreivew", :zh_tw => 'MattCheckANDPreivew')
bulletin_category_3 = BulletinCategory.create(:key => "C3MattCheckChrisPreview",:display => "List" )
bulletin_category_3.create_i18n_variable(:en => "MattCheckChrisPreview", :zh_tw => 'MattCheckChrisPreview')
bulletin_1 = Bulletin.create(:title => "C1P1",:status => nil,:subtitle => "",:text => "value",:postadate => Time.now,:deadline => nil,:bulletin_category => bulletin_category_1 )
bulletin_2 = Bulletin.create(:title => "C1P2",:status => nil,:subtitle => "",:text => "value",:postadate => Time.now,:deadline => nil,:bulletin_category => bulletin_category_1 )
bulletin_3 = Bulletin.create(:title => "C2P1",:status => nil,:subtitle => "",:text => "value",:postadate => Time.now,:deadline => nil,:bulletin_category => bulletin_category_2 )
bulletin_4 = Bulletin.create(:title => "C2P2",:status => nil,:subtitle => "",:text => "value",:postadate => Time.now,:deadline => nil,:bulletin_category => bulletin_category_2 )
bulletin_5 = Bulletin.create(:title => "C3P1",:status => nil,:subtitle => "",:text => "value",:postadate => Time.now,:deadline => nil,:bulletin_category => bulletin_category_3 )
bulletin_6 = Bulletin.create(:title => "C3P2",:status => nil,:subtitle => "",:text => "value",:postadate => Time.now,:deadline => nil,:bulletin_category => bulletin_category_3 )
end
end

View File

@ -125,6 +125,12 @@ namespace :dev do
AttributeValue.create( :user_id => user.id, :attribute_field_id => i_1.attribute_fields[1].id, :key => 'last_name', :en => 'Fu', :zh_tw => '傅' )
AttributeValue.create( :user_id => user.id, :attribute_field_id => sr_2_1.attribute_fields[0].id, :key => 'major', :en => 'Information management', :zh_tw => '信息化管理' )
AttributeValue.create( :user_id => user.id, :attribute_field_id => sr_2_1.attribute_fields[1].id, :key => 'department', :en => 'Computer Science', :zh_tw => '計算機科學' )
user = User.create( :email => 'manager@rulingcom.com', :password => 'password', :password_confirmation => 'password', :admin => false, :role_id => r_2.id, :sub_role_ids => [sr_2_1.id ] )
AttributeValue.create( :user_id => user.id, :attribute_field_id => i_1.attribute_fields[0].id, :key => 'first_name', :en => 'Manager', :zh_tw => '管理員' )
AttributeValue.create( :user_id => user.id, :attribute_field_id => i_1.attribute_fields[1].id, :key => 'last_name', :en => 'Chen', :zh_tw => '陳' )
AttributeValue.create( :user_id => user.id, :attribute_field_id => sr_2_1.attribute_fields[0].id, :key => 'major', :en => 'Information management', :zh_tw => '信息化管理' )
AttributeValue.create( :user_id => user.id, :attribute_field_id => sr_2_1.attribute_fields[1].id, :key => 'department', :en => 'Computer Science', :zh_tw => '計算機科學' )
ad_banner = AdBanner.new(:title => 'banner_1',:post_date => Date.today,:context=> "context",:ad_fx=>'zoom',:direct_to_after_click=>true)

View File

@ -5,7 +5,7 @@ namespace :user do
User.all(conditions: {email: /nor/}).destroy_all
username_list = %w{nor1 nor2 nor3 nor4 nor5 nor6 nor7}
userfirstname_list_en = %w{ One Two Thre For Fiv Six Sen }
userfirstname_list_en = %w{ UserOne UserTwo Thre For Fiv Six Sen }
userlastname_list_en = %w{ Aa Bb Cc Dd Ee Ff Gg }
userfirstname_list_ct = %w{ 一一 二二 三三 四四 五五 六六 七七 }

View File

@ -1,5 +1,5 @@
{
"title": "Announcement",
"title": "announcement",
"version": "0.1",
"organization": "Rulingcom",
"author": "RD dep",

View File

@ -105,7 +105,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' }
@ -145,7 +145,13 @@ 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
<<<<<<< HEAD
end
def get_sorted_bulletins
@ -190,6 +196,8 @@ class Panel::Announcement::BackEnd::BulletinsController < ApplicationController
a.flatten!
a.uniq
end
=======
>>>>>>> 26cd6951dba43b1f6eaf5056160309c5c77a8716
end

View File

@ -0,0 +1,38 @@
class Panel::Announcement::BackEnd::FactChecksController < OrbitBackendController
before_filter :authenticate_user!
include AdminHelper
layout 'admin'
def index
@bulletin_categorys_submit_new = []
@bulletin_categorys_check =[]
if is_admin? || is_manager?
#@bulletin_categorys_submit_new = BulletinCategory.all
@bulletin_categorys_check = BulletinCategory.all
# elsif is_sub_manager?
# @bulletin_categorys_submit_new = BulletinCategory.authed_for_user(current_user,'submit_new')
# @bulletin_categorys_check = BulletinCategory.authed_for_user(current_user,'fact_check')
end
end
def new
end
def create
end
def update
end
def edit
end
def destroy
end
end

View File

@ -17,7 +17,9 @@ class Panel::Announcement::FrontEnd::BulletinsController < ObitWidgetController
@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[:bulletin_category_id]) rescue nil
end
def show

View File

@ -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

View File

@ -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

View File

@ -5,7 +5,15 @@
<td><%= bulletin_category.i18n_variable[locale] rescue nil %></td>
<% end %>
<td><%= bulletin_category.display %></td>
<td>
<% if is_manager? %>
<td>
<%= link_to t('blog.new_auth'), init_admin_object_auths_path("BulletinCategory",bulletin_category,:token => @module_app.token) %> <br/ >
<% bulletin_category.object_auths.each do |obj_auth| %>
<%= link_to obj_auth.title,edit_admin_object_auth_url(obj_auth,:token => @module_app.token) %><br />
<% end %>
</td>
<td>
<% end %>
<%= link_to t('bulletin_category.edit'), edit_panel_announcement_back_end_bulletin_category_path(bulletin_category), :remote => true %> |
<%= link_to t('bulletin_category.quick_edit'), panel_announcement_back_end_bulletin_category_quick_edit_path(bulletin_category), :remote => true %> |
<%= link_to t('bulletin_category.delete'), panel_announcement_back_end_bulletin_category_path(bulletin_category), :confirm => t('announcement.sure?'), :method => :delete, :remote => true %>

View File

@ -1,22 +1,17 @@
<% content_for :secondary do %>
<br />
<br />
<br />
<br />
<br />
<ul class="list">
<li><%#= link_to t('bulletin_category.new_announcement_class'), new_panel_announcement_back_end_bulletin_category_path, :class => 'seclink1' %></li>
</ul>
<%= render :partial => '/panel/announcement/back_end/announcement_secondary' %>
<% end -%>
<%= flash_messages %>
<br />
<br />
<br />
<br />
<br />
<h1><%= t('bulletin_category.list_announcement_class') %></h1>
<br />
<br />
<br />
<br />
<br />
<table id="bulletin_categorys">
<tr>
<th><%= t('bulletin_category.key') %></th>

View File

@ -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} %>

View File

@ -36,4 +36,4 @@
</thead>
<tbody class="sort-holder">
<%= render :partial => 'bulletin', :collection => @bulletins %>
</tbody>
</tbody>

View File

@ -4,4 +4,4 @@
<%= render :partial => 'form', :locals => {:f => f} %>
<% end %>
<%= link_back %>
<%= link_back %>

View File

@ -6,4 +6,3 @@
<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,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 %>

View File

@ -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>

View File

@ -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>

View File

@ -0,0 +1,40 @@
<% 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 />

View File

@ -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">

View File

@ -11,7 +11,7 @@
<li>
<div class="news_img"><%= image_tag(post.image.url, :size => "290x130") if post.image.file %></div>
<h3 class="h3 news_title"><%= link_to post.title[I18n.locale], panel_announcement_front_end_bulletin_path(post, :category_id => post.bulletin_category_id) %></h3>
<p class="news_wrap"><%= post.subtitle[I18n.locale] %></p>
<p class="news_wrap"><%= post.subtitle[I18n.locale].html_safe %></p>
</li>
<% end %>
</ul>

View File

@ -32,6 +32,7 @@ en:
list_announcement: List Announcement
bulletin:
category: Category
list_lower: " list"
title: Title
postdate: Postdate
# admin:

View File

@ -27,6 +27,7 @@ zh_tw:
list_announcement: 公告列表
bulletin:
category: 分類
list_lower: 列表
title: 標題
postdate: 張貼日期
# admin:

View File

@ -2,6 +2,9 @@ Rails.application.routes.draw do
namespace :panel do
namespace :announcement do
namespace :back_end do
match 'public' => "announcements#public",:as => :public
resources :fact_checks
match 'list_mine' => "announcements#list_mine"
root :to => "bulletins#index"
resources :bulletins
resources :bulletin_categorys, :controller => 'bulletin_categorys' do
@ -21,4 +24,4 @@ Rails.application.routes.draw do
end
end
end
end
end

View File

@ -1,4 +0,0 @@
# desc "Explaining what the task does"
# task :announcement do
# # Task goes here
# end

View File

@ -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])

View File

@ -1,4 +1,4 @@
class Panel::NewBlog::FrontEnd::PostsController < ObitFrontendController
class Panel::NewBlog::FrontEnd::PostsController < OrbitFrontendController
# GET /posts
# GET /posts.xml
def index

View File

@ -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