Compare commits

..
49 changed files with 299 additions and 853 deletions

No files matched your search

-1
View File
@@ -18,7 +18,6 @@ gem 'kaminari'
gem 'time_difference'
gem "acts_as_unvlogable"
gem 'youtube_it'
gem 'gotcha'
# gem "memcached", "~> 1.4.3"
# gem "memcache-client"
+18 -46
View File
@@ -1,58 +1,30 @@
var banners = [];
var banner_index = 0;
$(document).ready(function() {
$.each($(".dymanic_load"),function(){
if($(this).attr("path")==''){
$(this).html("App setting Failed");
}else{
// Check if this App is AD_Banner
if($(this).attr("path").indexOf("show_banner")>0){
ajax_load_proc($(this),$(this).attr("path"),"true");
}else{
ajax_load_proc($(this),$(this).attr("path"),$(this).attr("path"));
if($(this).attr("path")==''){$(this).html("App setting Failed");}
if($(this).attr("path")!=''){
ajax_load_proc($(this),$(this).attr("path"));
}
}
}
});
);
$("#main_content").addClass("module");
});
});
function ajax_load_proc(wapper,url,isBanner){
function ajax_load_proc(wapper,url){
$.get(encodeURI(url), {}, function(respText,textSta,XML){
if (textSta == 'success') {
if(isBanner=="true"){
wapper.html(respText);
var banner = banners[banner_index];
$(banner.banner_name+" > img").each(function(){
$(this).load(function(){ banner.image_loaded++; });
});
BannerCycle(banner_index);
banner_index++;
}else{
wapper.html(respText);
}
};
if(textSta == 'error')
wapper.html("Loading Failed<br/> <a href='"+$(this).attr('path')+"'>Go See</a>");
if (textSta == 'success') {
wapper.html(respText);
};
if(textSta == 'error')
wapper.html("Loading Failed<br/> <a href='"+$(this).attr('path')+"'>Go See</a>");
});
}
function BannerCycle(banner_index){
var banner = banners[banner_index];
// Wait untill all images are loaded
if (banner.image_loaded==$(banner.banner_name+" img").length){
$(banner.banner_name).cycle({
delay: -1000,
fx: banner.banner_fx,
timeout: banner.time_to_next,
pager: banner.banner_pager,
pagerAnchorBuilder: function(idx, slide) { return "<li><a href='#'></a></li>"; }
});
}else{
setTimeout("BannerCycle("+banner_index+")",500);
}
}
// Ad Banner FX code [start]
function getTimeout() {
return $(this).attr('time_to_next');
}
$(document).ready(function() {
$(document).on('click', '.slideshow img', function()
+1 -1
View File
@@ -4,4 +4,4 @@
//= require basic/bootstrap
//= require kernel
//= require lib/jquery.preload-min.js
//= require lib/jquery.cycle.all.js
//= require lib/jquery.cycle.all.latest.js
@@ -40,7 +40,6 @@ class Admin::AdBannersController < OrbitBackendController
def edit
@ad_banner = AdBanner.find(params[:id])
render layout: false
end
def update
@@ -34,30 +34,38 @@ class Admin::AuthorizationsController < OrbitBackendController
end
def add_roles
roles = Role.find(params[:role_ids]) rescue nil
unless roles.nil?
roles = Role.find(params[:role_ids]) rescue []
users = []
roles.each do |role|
users += role.users.all.entries
end
unless roles.blank?
authorization = get_or_create_authorization
add_roles_to_auth(authorization, roles)
add_roles_to_auth(authorization, roles) unless @error
end
@users = authorization.authorized_users
render 'admin/authorizations/reload_users'
end
def add_sub_roles
sub_roles = SubRole.find(params[:sub_role_ids]) rescue nil
unless sub_roles.nil?
sub_roles = SubRole.find(params[:sub_role_ids]) rescue []
users = []
sub_roles.each do |sub_role|
users += sub_role.users.all.entries
end
unless sub_roles.blank?
authorization = get_or_create_authorization
add_sub_roles_to_auth(authorization, sub_roles)
add_sub_roles_to_auth(authorization, sub_roles) unless @error
end
@users = authorization.authorized_users
render 'admin/authorizations/reload_users'
end
def add_users
users = User.find(params[:user_ids]) rescue nil
unless users.nil?
users = User.find(params[:user_ids]) rescue []
unless users.blank?
authorization = get_or_create_authorization
add_users_to_auth(authorization, users)
add_users_to_auth(authorization, users) unless @error
end
@users = authorization.authorized_users
render 'admin/authorizations/reload_users'
@@ -112,6 +120,10 @@ class Admin::AuthorizationsController < OrbitBackendController
protected
def add_managers_to_auth(users)
@module_app.add_managers(users)
end
def add_roles_to_auth(authorization, roles)
authorization.add_roles(roles)
end
@@ -139,7 +151,7 @@ class Admin::AuthorizationsController < OrbitBackendController
@error = t(:no_data)
end
when nil
@module_app.auth_manager || @module_app.create_auth_manager(module_app_id: @module_app.id, title: @module_app.key)
@module_app.auth_manager || @module_app.create_auth_manager(module_app_id: @module_app.id, title: "#{@type}_#{@module_app.key}")
else
auth = @object.get_authorization_by_title("#{@type}_#{@module_app.key}")
unless auth
@@ -150,6 +162,10 @@ class Admin::AuthorizationsController < OrbitBackendController
end
end
def remove_managers_from_auth(users)
@module_app.remove_manager(users)
end
def remove_roles_form_auth(authorization, roles)
authorization.remove_roles(roles)
end
+1 -1
View File
@@ -60,7 +60,7 @@ class Admin::SitesController < OrbitBackendController
end
def preference
end
@@ -4,7 +4,6 @@ class Admin::UsersNewInterfaceController < OrbitMemberController
helper OrbitBackendHelper
before_filter :set_attribute,:except => [:index,:show]
open_for_user :only => [:setting_account, :edit_user_data, :update]
open_for_visitor :only => [:index, :show]
def index
@@ -183,36 +182,6 @@ class Admin::UsersNewInterfaceController < OrbitMemberController
# @disable_all_field = false
@user = User.find(params[:users_new_interface_id])
end
def edit_user_data
if params[:users_new_interface_id].blank?
redirect_to :action => :index
else
@user = User.find(params[:users_new_interface_id])
if current_user.id != @user.id
redirect_to :action => :index
end
@form_index = 0
get_info_and_roles
end
end
def setting_account
if params[:users_new_interface_id].blank?
redirect_to :action => :index
else
@user = User.find(params[:users_new_interface_id])
if current_user.id != @user.id
redirect_to :action => :index
end
end
end
def update
@@ -234,37 +203,6 @@ class Admin::UsersNewInterfaceController < OrbitMemberController
render :action => :edit_passwd, :notice => flash.now[:error]
end
elsif params[:edit_type] == 'edit_user_data'
if current_user.id != @user.id
redirect_to :action => :index
end
@user.update_attributes(params[:user])
attribute_values_key = params[:user].has_key?('new_attribute_values') ? 'new_attribute_values' : 'attribute_values'
attribute_values = params[:user].delete(attribute_values_key)
@user.save
redirect_to :action => :show
elsif params[:edit_type] == 'setting_account'
if current_user.id != @user.id
redirect_to :action => :index
end
if !@user.valid_password?(params[:old_password])
flash.now[:error] = t("users.valid_old_password")
end
if !flash.now[:error] && @user.update_attributes(params[:user])
redirect_to :action => :show
else
render :action => :setting_account, :notice => flash.now[:error]
end
else
@user.update_attributes(params[:user])
+6 -10
View File
@@ -140,21 +140,17 @@ class ApplicationController < ActionController::Base
# update session if passed
session[:locale] = params[:locale] if params[:locale]
browser_locale = condition = nil
default_locale = condition = nil
# check if locale is valid for non site pages
if LIST[:forbidden_item_names].include?(env['PATH_INFO'].split('/')[1].to_s)
condition = VALID_LOCALES.include?(session[:locale])
#check if the default locale is present or not
elsif @site.default_locale.present?
default_locale = @site.default_locale
condition = @site.in_use_locales.include?(default_locale)
elsif !@site.enable_language_detection
#check enable langauge detection
browser_locale = request.env['HTTP_ACCEPT_LANGUAGE'].scan(/^[a-z]{2}/).first rescue nil
condition = @site.in_use_locales.include?(browser_locale)
elsif session[:locale]
condition = @site.in_use_locales.include?(session[:locale])
elsif @site.default_locale.present?
default_locale = @site.default_locale
condition = @site.valid_locales.include?(default_locale)
else
browser_locale = request.env['HTTP_ACCEPT_LANGUAGE'].scan(/^[a-z]{2}/).first rescue nil
condition = @site.in_use_locales.include?(browser_locale)
end
session[:locale] = condition ? (default_locale || browser_locale || session[:locale]) : I18n.default_locale.to_s
I18n.locale = session[:locale].to_sym
+2 -3
View File
@@ -340,11 +340,10 @@ class DesktopController< ApplicationController
render :json=>b.to_json
end
protected
private
def check_desktop_open
@site = Site.first
if @site.desktop_closed #Need to be change
if Me.desktop_closed && current_user.nil? #Need to be change
redirect_to '/admin/dashboards'
end
end
+1 -1
View File
@@ -180,7 +180,7 @@ module ApplicationHelper
page_title = page.page_title ? page.page_title : page.title
if page.root? && @site.title
res << @site.title
elsif @site.title && !@site.title_always_on
elsif @site.title && @site.title_always_on
res << @site.title + ' - ' + page_title
else
res << page_title
+1 -1
View File
@@ -199,7 +199,7 @@ module OrbitBackendHelper
objects.join(' ')
else
objects = Array(objects).map do |object|
display_value(object.send(field)) rescue ''
display_value(object.send(field))
end
objects.join(', ')
end
+1 -1
View File
@@ -2,8 +2,8 @@ class AdBanner
include Mongoid::Document
include Mongoid::Timestamps
include Mongoid::MultiParameterAttributes
include OrbitCoreLib::ObjectAuthable
include OrbitTag::Taggable
include OrbitModel::Authorizable
field :title
field :transition_msec,type: Integer
+1
View File
@@ -1,3 +1,4 @@
class AuthManager < Authorization
# belongs_to :manager_authorizable, polymorphic: true
has_and_belongs_to_many :authorized_users, class_name: 'User', inverse_of: 'managing_apps'
end
+16 -3
View File
@@ -7,7 +7,6 @@ class ModuleApp
field :auth_approval_users, type: Array, default: nil
field :auth_manager_users, type: Array, default: nil
field :auth_sub_manager_users, type: Array, default: nil
field :has_category, type: Boolean, default: false
field :key
field :title
field :sidebar_order,type: Integer,default: 0
@@ -190,8 +189,7 @@ class ModuleApp
end
def update_auth_manager_users
users = self.auth_manager_authorized_users
self.update_attribute(:auth_manager_users, users.map{|user| user.id}) if users
self.update_attribute(:auth_manager_users, self.auth_manager_authorized_users.map{|user| user.id})
end
def update_auth_sub_manager_users
@@ -209,6 +207,21 @@ class ModuleApp
managers.include?(user)
end
def add_managers(users)
users = Array(users)
if auth_manager = self.auth_manager
auth_manager.update_attribute(:authorized_users, (auth_manager.authorized_users + users).uniq)
else
self.create_auth_manager(authorized_users: users)
end
end
def remove_managers(users)
users = Array(users)
users = users.delete_if{|user| user == current_user || is_admin?}
self.auth_manager.update_attribute(:authorized_users, auth_manager.authorized_users - users)
end
def is_manager?(user)
if user && !auth_manager_users.blank?
auth_manager_users.include?(user.id)
+2 -2
View File
@@ -30,8 +30,8 @@ class ModuleTag
if self.new_record?
self.build_tag(name_translations: self.name_translations, is_default: self.is_default)
else
self.tag.attributes = {:name_translations => self.name_translations}
self.tag.attributes = {:is_default => self.is_default}
self.tag.name_translations = self.name_translations
self.tag.is_default = self.is_default
end
end
+1 -18
View File
@@ -7,7 +7,6 @@ class Site
field :in_use_locales, :type => Array
field :valid_locales, :type => Array
field :enable_locales, :type => Array
field :roaming_id
field :private_key, :type => Binary
@@ -18,11 +17,11 @@ class Site
field :desktop_closed, :type => Boolean, :default => false
field :sitemap_menu_in_header, :type => Boolean, :default => false
field :enable_terms_of_use, :type => Boolean, :default => false
field :enable_language_detection, :type => Boolean, :default => false
field :title_always_on, :type => Boolean, :default => false
field :dashbroad_allow_visitor, :type => Boolean, :default => false
field :mail_settings, :type => Hash
field :enabled_for, :type => Array, :default => nil
field :disk_space, :type => String
field :system_package_info, :type => Hash,:default=>{}
@@ -31,7 +30,6 @@ class Site
field :department
mount_uploader :default_image, ImageUploader
mount_uploader :favicon, ImageUploader
field :search,:type => Hash
field :resque_namespace,:type => String, :default=>APP_CONFIG['orbit']
@@ -46,21 +44,6 @@ class Site
belongs_to :design
has_many :site_metas, :autosave => true, :dependent => :destroy
validate :in_use_locales, :minimum_enabled_locales
def minimum_enabled_locales
size = self.in_use_locales.length
if size < 1
errors.add(:size, "Needs at least one language in use")
end
end
def maximum_enabled_locales
size = self.in_use_locales.length
if size >= 2
errors.add(:size, "Max 2 ")
end
end
def generate_keys
private_key = OpenSSL::PKey::RSA.generate(2048)
+5
View File
@@ -1,3 +1,8 @@
# class Tag < ProtoTag
# belongs_to :module_app
# end
class Tag
include Mongoid::Document
include Mongoid::Timestamps
+25 -31
View File
@@ -1,31 +1,25 @@
<%= form_for @ad_banner, url: admin_ad_banner_path(@ad_banner) do |f| %>
<fieldset>
<legend><%= t("ad_banner.banner") %></legend>
<label><%= t("ad_banner.banner_name") %></label>
<%= f.text_field :title, :class=>"input-large", :placeholder=>"Banner Name" %>
<span class="help-block"><%= t("ad_banner.banner_name_note") %></span>
<label for="timeout"><%= t("ad_banner.ste") %></label>
<%= f.text_field :transition_sec, :class => 'input-large', :placeholder => 'Time' %>
<span class="help-block"><%= t("ad_banner.ste_note") %></span>
<label><%= t("ad_banner.best_size") %></label>
<%= f.text_field :best_size, :class=>"input-large", :placeholder=>"Banner Size" %>
<span class="help-block"><%= t("ad_banner.best_size") %> EX:120x30 </span>
<label><%= t("ad_banner.effect") %></label>
<%= f.select :ad_fx ,AdBanner::FX_TYPES %>
<div class="preview">
<%= image_tag "slideshow_preview_A.png", :width=>220 %>
<%= image_tag "slideshow_preview_B.png", :width=>220 %>
</div>
<span class="help-block"><%= t("ad_banner.effect") %></span>
<a href="javascript:$.pageslide.close()" class="btn btn-small"><%= t(:cancel) %></a>
<%= f.submit t(:update_), class: 'btn btn-primary btn-small' %>
</fieldset>
<% end %>
<script type="text/javascript">
$('select').on('change', function() {
$(".preview").cycle({
delay: -3000,
fx: $(this).val()
});
});
</script>
<div class="content">
<%= form_for(:ad_banner, :url => admin_ad_banner_path(:ad_banner), :remote => true) do |f| %>
<fieldset>
<legend>Ad Banner</legend>
<label>Banner Name</label>
<%= f.text_field :title, :class=>"input-large", :placeholder=>"Banner Name" %>
<span class="help-block">Banner Name only english</span>
<label for="timeout">Ste</label>
<%= f.text_field :transition_sec, :class => 'input-large', :placeholder => 'Time' %>
<span class="help-block">Please enter the number of seconds</span>
<label>Best Size</label>
<%= f.text_field :best_size, :class=>"input-large", :placeholder=>"Banner Size" %>
<span class="help-block">Best Size EX:120x30 </span>
<label>Effect</label>
<%= f.select :ad_fx ,AdBanner::FX_TYPES %>
<div class="preview">
<%= image_tag "slideshow_preview_A.png", :width=>220 %>
<%= image_tag "slideshow_preview_B.png", :width=>220 %>
</div>
<span class="help-block">Effect</span>
<a href="javascript:$.pageslide.close()" class="btn btn-small"><%= t(:cancel) %></a>
<%= f.submit t(:create_), class: 'btn btn-primary btn-small' %>
</fieldset>
<% end %>
</div>
+6 -4
View File
@@ -1,5 +1,3 @@
<%= javascript_include_tag "lib/jquery.cycle.all.js"%>
<table class="table main-list">
<thead>
<tr>
@@ -15,7 +13,7 @@
<div class="quick-edit">
<ul class="nav nav-pills">
<% if is_admin?%>
<li><%= link_to t(:edit), edit_admin_ad_banner_path(ad_banner), :class => "open-slide" %></li>
<li><%= link_to t(:edit), edit_admin_ad_banner_path(ad_banner)%></li>
<li><%= link_to 'Destroy', admin_ad_banner_path(ad_banner), method: :delete , :confirm => t(:sure?) %></li>
<% end %>
@@ -32,8 +30,12 @@
<!-- footer -->
<div class="bottomnav clearfix">
<div class="action pull-right">
<%= link_to content_tag(:i, nil, class: "icons-plus") + " " + t(:add_new), new_admin_ad_banner_path, :class => "btn btn-primary open-slide"%>
<%= link_to content_tag(:i, nil, class: "icons-plus") + " " + t(:add_new), "#add-banner", :class => "btn btn-primary open-slide"%>
</div>
</div>
<div id="add-banner" class="nano" style="display:none">
<%= render 'new' %>
</div>
<% end %>
+25 -31
View File
@@ -1,31 +1,25 @@
<%= form_for(:ad_banner, :url => admin_ad_banners_path) do |f| %>
<fieldset>
<legend><%= t("ad_banner.banner") %></legend>
<label><%= t("ad_banner.banner_name") %></label>
<%= f.text_field :title, :class=>"input-large", :placeholder=>"Banner Name" %>
<span class="help-block"><%= t("ad_banner.banner_name_note") %></span>
<label for="timeout"><%= t("ad_banner.ste") %></label>
<%= f.text_field :transition_sec, :class => 'input-large', :placeholder => 'Time' %>
<span class="help-block"><%= t("ad_banner.ste_note") %></span>
<label><%= t("ad_banner.best_size") %></label>
<%= f.text_field :best_size, :class=>"input-large", :placeholder=>"Banner Size" %>
<span class="help-block"><%= t("ad_banner.best_size") %> EX:120x30 </span>
<label><%= t("ad_banner.effect") %></label>
<%= f.select :ad_fx ,AdBanner::FX_TYPES %>
<div class="preview">
<%= image_tag "slideshow_preview_A.png", :width=>220 %>
<%= image_tag "slideshow_preview_B.png", :width=>220 %>
</div>
<span class="help-block"><%= t("ad_banner.effect") %></span>
<a href="javascript:$.pageslide.close()" class="btn btn-small"><%= t(:cancel) %></a>
<%= f.submit t(:create_), class: 'btn btn-primary btn-small' %>
</fieldset>
<% end %>
<script type="text/javascript">
$('select').on('change', function() {
$(".preview").cycle({
delay: -3000,
fx: $(this).val()
});
});
</script>
<div class="content">
<%= form_for(:ad_banner, :url => admin_ad_banners_path) do |f| %>
<fieldset>
<legend>Ad Banner</legend>
<label>Banner Name</label>
<%= f.text_field :title, :class=>"input-large", :placeholder=>"Banner Name" %>
<span class="help-block">Banner Name only english</span>
<label for="timeout">Ste</label>
<%= f.text_field :transition_sec, :class => 'input-large', :placeholder => 'Time' %>
<span class="help-block">Please enter the number of seconds</span>
<label>Best Size</label>
<%= f.text_field :best_size, :class=>"input-large", :placeholder=>"Banner Size" %>
<span class="help-block">Best Size EX:120x30 </span>
<label>Effect</label>
<%= f.select :ad_fx ,AdBanner::FX_TYPES %>
<div class="preview">
<%= image_tag "slideshow_preview_A.png", :width=>220 %>
<%= image_tag "slideshow_preview_B.png", :width=>220 %>
</div>
<span class="help-block">Effect</span>
<a href="javascript:$.pageslide.close()" class="btn btn-small"><%= t(:cancel) %></a>
<%= f.submit t(:create_), class: 'btn btn-primary btn-small' %>
</fieldset>
<% end %>
</div>
+2 -2
View File
@@ -91,5 +91,5 @@
</div>
</div>
<%=javascript_include_tag "lib/items/update_cates_and_tags.js" %>
<%= javascript_include_tag "lib/items/page_widget_edit_interface.js" %>
<%=javascript_include_tag "inc/update_cates_and_tags.js" %>
<%= javascript_include_tag "inc/page_widget_edit_interface.js" %>
@@ -5,7 +5,7 @@
</h6>
<ul>
<% sitemap_block.children.each_with_index do |child, i| %>
<li class="<%= 'disabled' if !child.show_in_sitemap_for(temp_locale) %>">
<li "clear <%= 'disabled' if !child.show_in_sitemap_for(temp_locale) %>">
<h6>
<input type="checkbox" id="<%= child.id %>" class="toggle-check onoff" temp_locale="<%= temp_locale %>" data-deploy="right">
<span><%= "#{sitemap_block_counter + 1}-#{i + 1}" %> <%= child.title_translations[temp_locale] %></span>
+24 -48
View File
@@ -17,6 +17,7 @@
<fieldset>
<!-- Input Area -->
<div class="input-area">
<div class="nav-name"><strong>Classification</strong></div>
@@ -126,7 +127,7 @@
</div>
</div>
<div class="control-group">
<label class="control-label muted"><%= I18n.t('site.enable_personal_desktop')%></label>
<label class="control-label muted">Disable personal desktop</label>
<div class="controls">
<%= f.check_box :desktop_closed , :class=>"toggle-check" %>
</div>
@@ -142,32 +143,25 @@
<input type="checkbox" class="toggle-check" data-disabled="true">
</div>
</div> -->
<!-- Terms of Use -->
<div class="control-group">
<label class="control-label muted">Enable User Language Detection
</label>
<div class="controls">
<%= f.check_box :enable_language_detection, :class => "toggle-check" %>
</div>
</div>
<div class="control-group">
<label class="control-label muted">Enable Language</label>
<div class="controls">
<% @site_valid_locales.each do |valid_locale| %>
<%= check_box_tag "site[enable_locales][]", locale, @site.valid_locales.include?(locale), :class=>"toggle-check", :data => { :title => "#{I18nVariable.from_locale(locale)}" } %>
<% end %>
</div>
</div>
<div class="control-group">
<label class="control-label muted">Default Language</label>
<div class="controls">
<% @site_in_use_locales.each do |locale| %>
<%= check_box_tag :default_locale, locale, (@site.default_locale.nil?), :class=>"toggle-check", :data => { :title => "#{I18nVariable.from_locale(locale)}" } %>
<%= check_box_tag :default_locale, locale, (@site.enabled_for.nil?), :class=>"toggle-check" %>
<%= I18nVariable.from_locale(locale) %>
<% end %>
</div>
</div>
<div class="control-group">
<label class="control-label muted">Enable Language</label>
<div class="controls">
<% @site_valid_locales.each do |valid_locale| %>
<%= check_box_tag 'site[enabled_for][]', valid_locale, (@site.enabled_for.nil?), :class=>"toggle-check" %>
<%= I18nVariable.from_locale(valid_locale) %>
<% end %>
<%= hidden_field_tag 'site[enabled_for][]', '' %>
</div>
</div>
</div>
@@ -179,7 +173,7 @@
<!-- if this page editing please add class "fileupload-edit" -->
<div class="fileupload fileupload-new clearfix" data-provides="fileupload">
<div class="fileupload-new thumbnail pull-left">
<% if @site.default_image %>
<% if @site.default_image %>
<%= image_tag( @site.default_image, :size=>"120x120") rescue ''%>
<% else %>
<img class="pull-left upload-picture" src="/assets/default-img.png" />
@@ -194,41 +188,23 @@
<%end%>
</span>
<a href="#" class="btn fileupload-exists" data-dismiss="fileupload">Cancel</a>
</div>
</div>
<div class="control-group">
<label class="control-label muted">Orbit Favicon</label>
<div class="controls">
<!-- if this page editing please add class "fileupload-edit" -->
<div class="fileupload fileupload-new clearfix" data-provides="fileupload">
<div class="fileupload-new thumbnail pull-left">
<% if @site.favicon %>
<%= image_tag( @site.favicon, :size=>"120x120") rescue ''%>
<% else %>
<img class="pull-left upload-picture" src="/assets/default-img.png" />
<% end %>
<div class="controls" data-toggle="buttons-checkbox">
<label class="checkbox inline btn btn-danger fileupload-remove">
<% if @site.default_image.file.present? %>
<label class="checkbox">
<%= check_box_tag 'site[remove_default_image]' %>
<%= t(:delete_) %>
</label>
<% end %>
</label>
</div>
<div class="fileupload-preview fileupload-exists thumbnail pull-left"></div>
<span class="btn btn-file">
<% if @site.favicon.file.present?%>
<%= f.file_field :favicon, :id => "input-upload", :class => 'fileupload-new', :onchange => "document.getElementById('fu').innerHTML = this.form.fu.value = this.value;" %>Change
<%else%>
<%= f.file_field :favicon, :id => "input-upload", :class => 'fileupload-new', :onchange => "document.getElementById('fu').innerHTML = this.form.fu.value = this.value;" %>Select Image
<%end%>
</span>
<a href="#" class="btn fileupload-exists" data-dismiss="fileupload">Cancel</a>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- Form Actions -->
<div class="form-actions">
+11 -9
View File
@@ -55,6 +55,7 @@
</div>
<hr>
<!-- CKeditor Site Header -->
<% @site_valid_locales.each do |locale|%>
<%= content_tag :div, :class => "tab-pane fade #{active_when_current_locale_eq locale} #{locale}" do %>
@@ -69,15 +70,6 @@
<%end%>
<%end%>
<!-- Sitemap menu in Header -->
<div class="control-group">
<label class="control-label muted">Sitemap menu in header
</label>
<div class="controls">
<%= f.check_box :sitemap_menu_in_header, :class => "toggle-check" %>
</div>
</div>
<hr>
<!-- CKeditor Site Footer -->
@@ -93,6 +85,16 @@
</div>
<%end%>
<%end%>
<!-- Sitemap menu in Header -->
<div class="control-group">
<label class="control-label muted">Sitemap menu in header
</label>
<div class="controls">
<%= f.check_box :sitemap_menu_in_header, :class => "toggle-check" %>
</div>
</div>
<hr>
<!-- Terms of Use -->
+2
View File
@@ -12,6 +12,8 @@
<% content_for :side_bar do %>
<%= render :partial => 'layouts/side_bar', :locals => {:link_name => t('site.settings'), :link_url => admin_site_site_info_path(@site), :icon => 'icons-cog', :side_bar_content => 'admin/sites/side_bar'} %>
<% end %>
<h3>Sitemap</h3>
<div id="sitemap">
<ul id="map-tree-language" class="nav nav-pills">
<% @site_valid_locales.each_with_index do |locale, i| %>
@@ -1,81 +0,0 @@
<%= render :partial=>"infos"%>
<div id="roles-area" class="input-area">
<%=render :partial=>"user_role_data",:collection=>Role.all.asc("_id")%>
</div>
<% content_for :page_specific_javascript do -%>
<% ( params[:users_new_interface_id].blank? ? @fname = 'new_attribute_values' : @fname = 'attribute_values' ) %>
<!-- Text -->
<script id="template-text" type="text/x-tmpl">
<div class="input-append">
<input type="text" id="${roleType+'_text_'+appendIndex}" name="${'user[<%= @fname %>]['+nameNumber+'][value][]'}" class="input-medium" placeholder="">
<a href="#" class="btn remove-input">
<i class="icon-trash"></i>
</a>
</div>
</script>
<!-- Text Language -->
<script id="template-text-language" type="text/x-tmpl">
<div class="input-append">
<div class="tab-content">
<% VALID_LOCALES.collect do |locale| %>
<% active = (locale == @site_valid_locales.first ? "active" : "") %>
<div class="tab-pane fade <%= active %> in" id="${roleType+'_text_language_<%= locale %>_'+appendIndex}">
<input type="text" name="${'user[<%= @fname %>]['+nameNumber+'][value][][<%= locale %>]'}" placeholder="<%= I18nVariable.from_locale(locale) %>" value="">
</div>
<% end %>
</div>
<div class="btn-group" data-toggle="buttons-radio">
<% VALID_LOCALES.collect do |locale| %>
<% active = (locale == @site_valid_locales.first ? "active" : "") %>
<a class="btn <%= active %>" href="${'#'+roleType+'_text_language_<%= locale %>_'+appendIndex}" data-toggle="tab"><%= I18nVariable.from_locale(locale) %></a>
<% end %>
<a href="#" class="btn remove-input"><i class="icon-trash"></i></a>
</div>
</div>
</script>
<!-- Address -->
<script id="template-address" type="text/x-tmpl">
<div class="input-append">
<div class="tab-content">
<div class="tab-pane fade active in" id="${roleType+'_address_en_'+appendIndex}">
<input type="text" name="${'user[new_attribute_values]['+nameNumber+'][value][en]'}" placeholder="Address" value="">
<input type="hidden" id="${roleType+'_street_address_en_'+appendIndex}" name="${'user[new_attribute_values]['+nameNumber+'][address_ext][en][street_address]'}" value="">
<input type="hidden" id="${roleType+'_cityarea_en_'+appendIndex}" name="${'user[new_attribute_values]['+nameNumber+'][address_ext][en][county]'}" value="">
<input type="hidden" id="${roleType+'_city_en_'+appendIndex}" name="${'user[new_attribute_values]['+nameNumber+'][address_ext][en][city]'}" value="">
<input type="hidden" id="${roleType+'_zip_en_'+appendIndex}" name="${'user[new_attribute_values]['+nameNumber+'][address_ext][en][zip]'}" value="">
<input type="hidden" id="${roleType+'_county_en_'+appendIndex}" name="${'user[new_attribute_values]['+nameNumber+'][address_ext][en][country]'}" value="">
<input type="hidden" id="${roleType+'_indicator_en_'+appendIndex}" name="${'user[new_attribute_values]['+nameNumber+'][address_ext][en][indicator]'}" value="">
</div>
<div class="tab-pane fade" id="${roleType+'_address_zh_tw_'+appendIndex}">
<input type="text" name="${'user[new_attribute_values]['+nameNumber+'][value][zh_tw]'}" placeholder="地址" value="">
<input type="hidden" id="${roleType+'_street_address_zh_tw_'+appendIndex}" name="${'user[new_attribute_values]['+nameNumber+'][address_ext][zh_tw][street_address]'}" value="">
<input type="hidden" id="${roleType+'_cityarea_zh_tw_'+appendIndex}" name="${'user[new_attribute_values]['+nameNumber+'][address_ext][zh_tw][county]'}" value="">
<input type="hidden" id="${roleType+'_city_zh_tw_'+appendIndex}" name="${'user[new_attribute_values]['+nameNumber+'][address_ext][zh_tw][city]'}" value="">
<input type="hidden" id="${roleType+'_zip_zh_tw_'+appendIndex}" name="${'user[new_attribute_values]['+nameNumber+'][address_ext][zh_tw][zip]'}" value="">
<input type="hidden" id="${roleType+'_county_zh_tw_'+appendIndex}" name="${'user[new_attribute_values]['+nameNumber+'][address_ext][zh_tw][country]'}" value="">
<input type="hidden" id="${roleType+'_indicator_zh_tw_'+appendIndex}" name="${'user[new_attribute_values]['+nameNumber+'][address_ext][zh_tw][indicator]'}" value="">
</div>
</div>
<div class="btn-group" data-toggle="buttons-radio">
<a class="btn active" href="${'#'+roleType+'_address_en_'+appendIndex}" data-toggle="tab">English</a>
<a class="btn" href="${'#'+roleType+'_address_zh_tw_'+appendIndex}" data-toggle="tab">Chinese</a>
<a class="btn" href="#address-field" role="button" data-toggle="modal"><i class="icon-edit"></i></a>
<a href="#" class="btn remove-input"><i class="icon-trash"></i></a>
</div>
</div>
</script>
<% end -%>
@@ -1,91 +0,0 @@
<% role_disable = @user.roles.include?(user_role_data) ? false : true %>
<div class="attributes <%= role_disable ? 'disabled hide' : '' %>">
<div class="attributes-header clearfix">
<%= hidden_field_tag("user[disable_role][id][#{user_role_data.id}]",role_disable,:for=>@form_index,:value=>role_disable)%>
<h4><%= user_role_data.title %><%= t(:role_info)%></h4>
</div>
<div class="attributes-body">
<% @form_index = @form_index +1 %>
<div class="control-group">
<%= label_tag t(:status), nil, {:func=>"field_label", :for=>"1", :class=>"control-label muted"} %>
<div class="controls">
<% user_role_data.role_statuses.where(:disable => false).each_with_index do |rrs, i|%>
<%= hidden_field_tag("user[role_status][id][#{rrs.id}]", false,:for=>"#{@form_index}")%>
<%= label_tag(i,check_box_tag( "user[role_status][id][#{rrs.id}]", true, @user.role_statuses.include?(rrs))+rrs.title,:class=>"checkbox inline") %>
<% end %>
</div>
</div>
<% @form_index = @form_index +1 %>
<div class="control-group">
<%= label_tag t(:category), nil, {:func=>"field_label", :for=>"1", :class=>"control-label muted"} %>
<div class="controls">
<% user_role_data.role_categorys.where(:disable => false).each_with_index do |rrcg, i|%>
<%= hidden_field_tag("user[role_category][id][#{rrcg.id}]", false,:for=>"#{@form_index}")%>
<%= label_tag(i,check_box_tag( "user[role_category][id][#{rrcg.id}]", true, @user.role_categorys.include?(rrcg))+rrcg.title,:class=>"checkbox inline") %>
<% end %>
</div>
</div>
<% user_role_data.attribute_fields.asc(:_id).each do |rf|%>
<%= rf.block_helper(@user,@form_index)%>
<% @form_index = @form_index +1 %>
<% end %>
<% @form_index = @form_index +1 %>
<div class="input-area sub-role">
<% user_role_data.sub_roles.where(:disabled=>false).asc("_id").each do |sub_role| %>
<% sub_role_disable = @user.sub_roles.include?(sub_role) ? false : true %>
<div class="attributes <%= sub_role_disable ? 'disabled hide' : '' %>">
<div class="attributes-header clearfix">
<%= hidden_field_tag("user[disable_sub_role][id][#{sub_role.id}]",sub_role_disable,:for=>@form_index,:value=>sub_role_disable)%>
<h4><%= sub_role.title %><%= t(:role_info)%></h4>
</div>
<div class="attributes-body">
<% sub_role.attribute_fields.asc(:_id).each do |af|%>
<%= af.block_helper(@user,@form_index)%>
<% @form_index = @form_index +1 %>
<% end %>
</div>
</div>
<% end %>
</div>
</div>
</div>
@@ -1,53 +0,0 @@
<%#= devise_error_messages! %>
<%= flash_messages %>
<div class="attributes">
<div class="attributes-header clearfix">
<h4><%=t("users.user_basic_id_form")%></h4>
</div>
<div class="attributes-body">
<!-- Account -->
<div class="control-group">
<label class="control-label muted" for="account">
<%= f.label t("users.user_id"),:class=>"control-label" %>
</label>
<div class="controls add-input">
<span><%= @user.user_id %></span>
</div>
</div>
<!-- Old Password -->
<div class="control-group">
<label class="control-label muted" for="password">
<%= f.label t("password_current"),:class=>"control-label" %>
</label>
<div class="controls add-input">
<%= password_field_tag "old_password",nil, :class=>"input-medium", :id=>"password" %>
</div>
</div>
<!-- Password -->
<div class="control-group">
<label class="control-label muted" for="password">
<%= f.label t("users.new_password"),:class=>"control-label" %>
</label>
<div class="controls add-input">
<%= f.password_field :password, :class=>"input-medium", :id=>"password" %>
<span class="help-block"><%= t("users.new_password_note")%></span>
</div>
</div>
<!-- Confirm Password -->
<div class="control-group">
<label class="control-label muted" for="confirm_password">
<%= f.label t("users.new_password_confirmation"),:class=>"control-label" %>
</label>
<div class="controls add-input">
<%= f.password_field :password_confirmation, :class=>"input-medium", :id=>"confirm_password" %>
</div>
</div>
</div>
</div>
@@ -1,43 +0,0 @@
<% content_for :side_bar do %>
<%= render :partial => 'admin/users_new_interface/side_bar' %>
<% end %>
<% content_for :page_specific_css do -%>
<%= stylesheet_link_tag "lib/wrap-nav.css" %>
<%= stylesheet_link_tag "lib/pageslide.css" %>
<%= stylesheet_link_tag "lib/main-forms.css" %>
<%= stylesheet_link_tag "lib/fileupload.css" %>
<%= stylesheet_link_tag "lib/togglebox.css" %>
<% end -%>
<% content_for :page_specific_javascript do -%>
<%= javascript_include_tag "lib/jquery-ui-1.10.3.custom.min.js" %>
<%= javascript_include_tag "lib/jquery.tmpl.min.js" %>
<%= javascript_include_tag "lib/bootstrap-fileupload.js" %>
<%= javascript_include_tag "lib/bootstrap-datetimepicker.js" %>
<%= javascript_include_tag "lib/datetimepicker/date.time.picker.js" %>
<%= javascript_include_tag "lib/member/textarea-lang-btn.js" %>
<%= javascript_include_tag "lib/member/role-forms.js" %>
<% end -%>
<%= form_for @user, :url => admin_users_new_interface_path(@user), :html => { :multipart => true , :class=>"form-horizontal main-forms", :id=>"user-forms"} do |f| %>
<fieldset>
<div id="basic-area" class="input-area">
<%= f.error_messages %>
<%= render :partial => 'user_basic', :locals => {:f => f}%>
<%= render :partial => 'form_user_data', :locals => { :f => f } %>
</div>
<div class="form-actions">
<%= hidden_field_tag 'edit_type', 'edit_user_data' %>
<%= link_to t(:update_), "#", :class=>"btn btn-primary returnDecide", :onclick=>"$('#user-forms').submit()" %>
<%= link_back('btn') %>
</div>
</fieldset>
<% end -%>
@@ -1,39 +0,0 @@
<% content_for :side_bar do %>
<%= render :partial => 'admin/users_new_interface/side_bar' %>
<% end %>
<% content_for :page_specific_css do -%>
<%= stylesheet_link_tag "lib/wrap-nav.css" %>
<%= stylesheet_link_tag "lib/pageslide.css" %>
<%= stylesheet_link_tag "lib/main-forms.css" %>
<%= stylesheet_link_tag "lib/fileupload.css" %>
<%= stylesheet_link_tag "lib/togglebox.css" %>
<% end -%>
<% content_for :page_specific_javascript do -%>
<%= javascript_include_tag "lib/jquery.tmpl.min.js" %>
<%= javascript_include_tag "lib/bootstrap-fileupload.js" %>
<%= javascript_include_tag "lib/member/role-forms.js" %>
<%= javascript_include_tag "lib/member/textarea-lang-btn.js" %>
<% end -%>
<%= form_for @user, :url => admin_users_new_interface_path(@user), :html => { :multipart => true , :class=>"form-horizontal main-forms"} do |f| %>
<fieldset>
<div id="basic-area" class="input-area">
<%= f.error_messages %>
<%= render :partial => 'user_setting_account', :locals => {:f => f}%>
</div>
<div class="form-actions">
<%= link_back('btn') %>
<%= hidden_field_tag 'edit_type', 'setting_account' %>
<%= link_to t(:update_), "#", :class=>"btn btn-primary returnDecide", :onclick=>"$('#edit_user_#{@user.id}').submit()" %>
</div>
</fieldset>
<% end -%>
@@ -20,7 +20,7 @@
<small class="muted"><%= @user.email %></small>
<div class="btn-group">
<%= link_to("<i class='icon-edit'></i> #{t(:edit)}".html_safe,edit_admin_users_new_interface_path(@user),:class=>"btn btn-mini" ) if is_admin?%>
<%= link_to("<i class='icons-cycle'></i> #{t("users.change_passwd")}".html_safe,admin_users_new_interface_edit_passwd_path(@user),:class=>"btn btn-mini" ) if is_admin? and current_user.id != @user.id %>
<%= link_to("<i class='icons-cycle'></i> #{t("users.change_passwd")}".html_safe,admin_users_new_interface_edit_passwd_path(@user),:class=>"btn btn-mini" ) if is_admin?%>
</div>
</div>
+16 -9
View File
@@ -1,3 +1,4 @@
<%= javascript_include_tag "lib/jquery.cycle.all.latest.js"%>
<div style='position:relative'>
<ul id='banner_nav' class='clear banner_nav-<%= @ad_banner.title.dehumanize %>'></ul>
<div id='slideshow-<%= @ad_banner.title.dehumanize %>' class='slideshow'>
@@ -9,12 +10,18 @@
</div>
</div>
<script type='text/javascript'>
var banner = {"banner_name":"#slideshow-<%= @ad_banner.title.dehumanize %>",
"banner_fx":"<%= @ad_banner.ad_fx.nil? ? 'fade': @ad_banner.ad_fx %>",
"banner_pager":".banner_nav-<%= @ad_banner.title.dehumanize %>",
"image_count":"<%= @ad_banner.ad_images.length %>",
"image_loaded":0,
"time_to_next":<%= @ad_banner.transition_msec %>,
};
banners.push(banner);
</script>
$(document).ready(function(){
jQuery(function( $ ){
$('#slideshow-<%= @ad_banner.title.dehumanize %>').cycle({
delay: -1000,
fx: "<%= @ad_banner.ad_fx.nil? ? 'fade': @ad_banner.ad_fx %>",
timeoutFn: getTimeout,
pager: '.banner_nav-<%= @ad_banner.title.dehumanize %>',
pagerAnchorBuilder: function(idx, slide) {
return "<li><a href='#'></a></li>";
}
});
});
});
</script>
+2 -3
View File
@@ -21,16 +21,15 @@
</li>
<!-- Desktop -->
<% if !@site.desktop_closed%>
<li id="orbit-desktop">
<a href="<%= desktop_path %>" role="button">
<i class="icons-screen"></i> <span class="hide"><%= t(:desktop) %></span>
</a>
</li>
<% end %>
</ul>
<% if @site.default_image.present?%>
<% @url_path = "#{request.fullpath}".scan(/admin/)%>
<% if (@site.default_image.present? && (!@url_path.include? "admin"))%>
<style>
#orbit-bar .orbitlogo {
width: 20px;
+1 -4
View File
@@ -31,11 +31,8 @@
<span><%= current_user.name %></span>
</a>
<ul class="dropdown-menu" role="menu" aria-labelledby="orbit-user">
<li><%= link_to content_tag(:i, nil, class: 'icons-tools') + ' ' + t("users.change_passwd"), admin_users_new_interface_setting_account_path(current_user), tabindex: '-1' %></li>
<li><%= link_to content_tag(:i, nil, class: 'icons-vcard') + ' ' + t("users.user_basic_data"), admin_users_new_interface_edit_user_data_path(current_user), tabindex: '-1' %></li>
<% if @site.desktop_closed.blank? %>
<li><%= link_to content_tag(:i, nil, class: 'icons-tools') + ' ' + t(:account_settings), desktop_path + "#settings-account", tabindex: '-1' %></li>
<li><%= link_to content_tag(:i, nil, class: 'icons-screen') + ' ' + t(:desktop), desktop_path, tabindex: '-1' %></li>
<% end %>
<li><%= link_to content_tag(:i, nil, class: 'icons-logout') + ' ' + t(:logout), destroy_user_session_path, tabindex: '-1' %></li>
<li class="divider"></li>
<li><a tabindex="-1" href="#"><i class="icons-lifebuoy"></i> <%= t(:help) %></a></li>
+1 -1
View File
@@ -5,7 +5,7 @@
<%= javascript_include_tag "html5" %>
<![endif]-->
<%#= stylesheet_link_tag "module_widget" %>
<%#= javascript_include_tag "module" %>
<%= javascript_include_tag "module" %>
<%#= javascript_include_tag "#{@app_title}/module_widget" %>
<%= yield :page_specific_javascript %>
<%= csrf_meta_tag %>
+2 -5
View File
@@ -11,6 +11,7 @@ en:
not_sub_manager: Access Denied for you are not SubManager for this app
not_admin: Access Denied for you are not Admin
object: Access Denied for you don't have permission for this object
account_settings: Account settings
academic_info: Academic Info.
action: Action
ad:
@@ -390,7 +391,6 @@ en:
footer_help: Footer Guide
frontend_closed: Frontend Closed
frontend_open: Frontend Open
enable_personal_desktop: Enable Personal Desktop
header: Site header
info: Site information
keywords: Site keywords
@@ -486,13 +486,12 @@ en:
users:
admin_change_password: You cannot change your own password here!
avatar: Profile Picture
change_passwd: Change Password
change_passwd: Change password
email: Email
first_name: First Name
last_name: Last Name
male: Male
name: Name
valid_old_password: Current password doesn't match confirmation
new_password: New password
new_password_note: At least 6 characters
new_password_confirmation: Confirm new password
@@ -508,8 +507,6 @@ en:
user_id_not_null: User account cannot be null
user_id_length: User account should be more than 3 characters
user_id_error: Someone already use that user account
user_basic_id_form: Account Info.
user_basic_data: Personal Profile
version: Version
vertical: Vertical
view: View
+2 -5
View File
@@ -11,6 +11,7 @@ zh_tw:
not_sub_manager: 拒絕存取,因你不是此應用程式次管理員
not_admin: 拒絕存取,因你不是系統管理者
object: 拒絕存取,因你沒有權限
account_settings: 帳號設定
academic_info: 學術資訊
action: 操作
ad:
@@ -384,9 +385,8 @@ zh_tw:
thumbnail: 縮圖
site:
frontend_closed: 前台關閉?
frontend_open: 開啟前台
frontend_open: 前台關閉 ?
backend_openness_on: 開啟開放式後台(訪客可遊覽)
enable_personal_desktop: 開啟個人桌面
default_image: 預設圖像
description: 網站描述
description_help: 網站描述說明
@@ -492,7 +492,6 @@ zh_tw:
first_name: 名字
male: 男性
name: 姓名
valid_old_password: 目前的密碼不符合確認值
new_password: 新密碼
new_password_note: 至少6個字元
new_password_confirmation: 確認新密碼
@@ -509,8 +508,6 @@ zh_tw:
user_id_not_null: 使用者帳號不能是空值
user_id_length: 使用者帳號至少需要3個字元
user_id_error: 該使用者帳號已被使用
user_basic_id_form: 帳號資料
user_basic_data: 個人資料
version: 版本
vertical: 垂直的
view: 檢視
-2
View File
@@ -221,8 +221,6 @@ Orbit::Application.routes.draw do
post 'update_order_list'
end
match "edit_passwd" => "users_new_interface#edit_passwd" ,:as => :edit_passwd
match "edit_user_data" => "users_new_interface#edit_user_data" ,:as => :edit_user_data
match "setting_account" => "users_new_interface#setting_account" ,:as => :setting_account
end
resources :member_selects do
+11 -22
View File
@@ -188,15 +188,6 @@ module OrbitCoreLib
end
end
def open_for_user(arg = nil)
if arg
key = arg.shift
prepend_before_filter key[0] => key[1] {|f| f.open_for :user}
else
prepend_before_filter {|f| f.open_for :user}
end
end
def open_for_visitor(arg = nil)
if arg
key = arg.shift
@@ -223,29 +214,27 @@ module OrbitCoreLib
setup_vars
unless @no_authorization
if @user_type
@open = false
@visitor = false
@user_type.each do |user_type|
open = false
visitor = false
case user_type
when :admin
@open ||= check_admin
open ||= check_admin
when :manager
@open ||= check_manager
open ||= check_manager
when :sub_manager
@open ||= check_sub_manager
open ||= check_sub_manager
when :approver
@open ||= check_sub_manager
when :user
@open ||= true
open ||= check_sub_manager
when :visitor
set_current_user
@open ||= true
@visitor ||= true
open ||= true
visitor ||= true
end
check_backend_openness if visitor
authenticate_user! unless visitor
redirect_to root_url unless open
end
check_backend_openness if @visitor
authenticate_user! unless @visitor
redirect_to root_url unless @open
else
authenticate_user!
check_user_can_use
-1
View File
@@ -7,7 +7,6 @@ module OrbitModel
has_one :auth_approval, as: :approval_authorizable, dependent: :destroy
has_one :auth_sub_manager, as: :sub_manager_authorizable, dependent: :destroy
delegate :authorized_users, to: :auth_approval, prefix: true, allow_nil: true
delegate :authorized_users, to: :auth_manager, prefix: true, allow_nil: true
delegate :authorized_users, to: :auth_sub_manager, prefix: true, allow_nil: true
send :include, InstanceMethods
end
+78 -175
View File
@@ -1,191 +1,94 @@
namespace :new_ui do
MODULE_APPS = [ %w(announcement bulletin),
%w(archive archive_file),
%w(ask ask_question ask_category),
%w(asset asset),
%w(faq qa),
%w(gallery gallery_album gallery_category),
%w(location location),
%w(personal_book writing_book),
%w(personal_conference writing_conference),
%w(personal_experience experience),
%w(personal_honor honor),
%w(personal_journal writing_journal),
%w(personal_patent writing_patent),
%w(personal_project project),
%w(web_resource web_link)
] # app_key, model_name, category_name
task :migrate => :environment do
@db = Mongoid.database
migrate_tags
migrate_categories
migrate_approval_on_object
migrate_managers
end
# :category_name is optional, depends on the naming of the category model: if no conventional, specify it
task :migrate_categories, [:app_key, :model_name, :category_name] => :environment do |t, args|
migrate_categories(args)
@db = Mongoid.database
if args[:app_key] && args[:model_name]
migrate_category(args[:app_key], args[:model_name], args[:category_name])
else
module_apps = [ %w(announcement bulletin),
%w(archive archive_file),
%w(ask ask_question ask),
%w(asset asset),
%w(faq qa),
%w(gallery gallery_album gallery),
%w(personal_book writing_book),
%w(personal_conference writing_conference),
%w(personal_experience experience),
%w(personal_honor honor),
%w(personal_journal writing_journal),
%w(personal_patent writing_patent),
%w(personal_project project),
%w(web_resource web_link)
]
module_apps.each{|value_array| migrate_category(value_array[0], value_array[1], value_array[2])}
end
end
def migrate_category(app_key, model_name, category_name=nil)
category_name = model_name unless category_name
# # coll_cat = @db["#{category_name}_categories"]
# # categories = coll_cat.find if coll_cat
module_app = ModuleApp.where(key: app_key)[0]
if module_app.has_category
categories = "#{category_name}_categories".classify.constantize.admin_manager_all rescue nil
categories = "#{category_name}_categories".classify.constantize.all if categories.blank?
categories.each do |category|
new_category = module_app.categories.build
new_category.title_translations = category['title']
new_category.disable = category['disable']
new_category.save
model_name.classify.constantize.where("#{category_name}_category_id" => category['_id']).each do |object|
if object.id.is_a?(String)
object.destroy
else
object.category = new_category.id
object.remove_attribute("#{category_name}_category_id")
object.save
end
end
if object_auths = ObjectAuth.where(obj_authable_type: "#{category_name.classify}Category")
object_auths.each do |object_auth|
case object_auth.title
when 'fact_check'
new_object_auth = new_category.get_object_auth_by_title("approval_#{module_app.key}")
else
new_object_auth = new_category.get_object_auth_by_title("category_#{module_app.key}")
end
object_auth.auth_users.each do |user|
new_object_auth.add_user_to_privilege_list(user)
end
object_auth.destroy
end
end
category.destroy
end
end
end
task :migrate_tags => :environment do
migrate_tags
end
task :fix_tagged_ids => :environment do
fix_tagged_ids
end
def migrate_categories(args = nil)
if args && args[:app_key] && args[:model_name]
migrate_category(args[:app_key], args[:model_name], args[:category_name])
else
MODULE_APPS.each{|value_array| migrate_category(value_array[0], value_array[1], value_array[2])}
end
end
def migrate_category(app_key, model_name, category_name = nil)
@db ||= Mongoid.database
category_name = "#{model_name}_category" unless category_name
collection_category = @db[category_name.pluralize]
categories = collection_category.find.entries if collection_category
collection_model = @db[model_name.pluralize]
collection_buffer_category = @db['buffer_categories']
collection_prototype_auth = @db['prototype_auths']
if categories.present?
module_app = ModuleApp.where(key: app_key).first
if module_app.try(:has_category)
categories.each do |category|
new_category = module_app.categories.build
new_category.title_translations = category['title']
new_category.disable = category['disable']
new_category.save
collection_model.find("#{category_name}_id" => category['_id']).each do |object|
object['category_id'] = new_category.id
object.delete("#{category_name}_id")
collection_model.save object
collection_buffer_category.save ({ '_type' => 'BufferCategory', 'category_id' => new_category.id, 'categorizable_type' => model_name.camelize, 'categorizable_id' => object['_id'] })
end
object_auths = collection_prototype_auth.find(_type: 'ObjectAuth', obj_authable_id: category['_id'], '$or' => [{privilege_user_ids: {'$not' => {'$size' => 0}}}, {role_ids: {'$not' => {'$size' => 0}}}, {sub_role_ids: {'$not' => {'$size' => 0}}}]).entries
if object_auths.present?
object_auths.each do |object_auth|
if object_auth['title'].eql?('fact_check')
authorization = new_category.auth_approval || new_category.create_auth_approval(module_app_id: module_app.id, title: "category_approval_#{module_app.key}")
else
authorization = new_category.auth_sub_manager || new_category.create_auth_sub_manager(module_app_id: module_app.id, title: "category_authorization_#{module_app.key}")
end
add_users(object_auth, authorization)
collection_prototype_auth.remove(object_auth)
end
end
end
collection_category.drop
collection_prototype_auth.remove(obj_authable_type: category_name.classify)
end
else
collection_category.drop
collection_prototype_auth.remove(obj_authable_type: category_name.classify)
end
end
def fix_tagged_ids
Tag.all.each do |tag|
tags = Tag.where(_type: 'Tag')
tags.each do |tag|
module_app = ModuleApp.find(tag.module_tag_id)
new_tag = module_app.module_tags.build
new_tag.name_translations = tag['name']
new_tag.is_default = tag['is_default']
new_tag.save
n_tag = new_tag.tag
n_tag.cloud_view_count = tag['cloud_view_count']
n_tag.view_count = tag['view_count']
n_tag.save
tag.taggings.each do |tagging|
tagged_ids = tagging.taggable.tagged_ids
unless tagged_ids.include?(tag.id.to_s)
tagged_ids << tag.id.to_s
tagging.taggable.update_attribute(:tagged_ids, tagged_ids)
end
tagging.taggable.taggings.create(tag_id: n_tag.id)
end
tag.destroy
end
end
def migrate_tags
@db ||= Mongoid.database
tags = Tag.where(_type: 'Tag').entries
tags.each_with_index do |tag, i|
unless tag.tag_lease
if module_app = ModuleApp.find(tag[:module_tag_id])
new_tag = module_app.module_tags.build
new_tag.name_translations = tag['name']
new_tag.is_default = tag['is_default']
new_tag.save
n_tag = new_tag.tag
n_tag.cloud_view_count = tag['cloud_view_count']
n_tag.view_count = tag['view_count']
n_tag.save
tag.taggings.each do |tagging|
tagged_ids = tagging.taggable.tagged_ids
unless tagged_ids.include?(tag.id.to_s)
tagged_ids << tag.id.to_s
tagging.taggable.update_attribute(:tagged_ids, tagged_ids)
end
tagging.taggable.taggings.create(tag_id: n_tag.id)
end
end
tag.destroy
end
task :change_auth_naming => :environment do
ObjectAuth.where(title: /submit_/).each do |auth|
auth.update_attribute(:title, auth.title.gsub('submit_', 'category_'))
end
old_tags = Tag.where(_type: {'$ne' => 'Tag'}).delete
@db = Mongoid.database
@db['proto_tags'].drop
end
def migrate_approval_on_object
@db ||= Mongoid.database
collection_prototype_auth = @db['prototype_auths']
object_auths = collection_prototype_auth.find({_type: 'ObjectAuth', obj_authable_type: {'$in' => ["AdBanner", "PageContext"]}, '$or' => [{privilege_user_ids: {'$not' => {'$size' => 0}}}, {role_ids: {'$not' => {'$size' => 0}}}, {sub_role_ids: {'$not' => {'$size' => 0}}}]}).entries
object_auths.each do |object_auth|
case object_auth['obj_authable_type']
when 'AdBanner'
module_app = ModuleApp.where(key: 'ad_banner').first
when 'PageContext'
module_app = ModuleApp.where(key: 'page_content').first
end
if module_app
object = object_auth['obj_authable_type'].constantize.find(object_auth['obj_authable_id']) rescue nil
if object
authorization = object.create_auth_sub_manager(module_app_id: module_app.id, title: "#{object_auth['obj_authable_type'].underscore}_authorization_#{module_app.key}")
add_users(object_auth, authorization) if authorization
end
end
collection_prototype_auth.remove(object_auth)
end
collection_prototype_auth.remove(obj_authable_type: {'$in' => ["AdBanner", "PageContext"]})
end
def add_users(object_auth, authorization)
if authorization
if object_auth['role_ids'].present?
roles = Role.find(object_auth['role_ids']) rescue nil
authorization.add_roles(roles) if roles
end
if object_auth['sub_role_ids'].present?
sub_roles = SubRole.find(object_auth['sub_role_ids']) rescue nil
authorization.add_sub_roles(sub_roles) if sub_roles
end
if object_auth['privilege_user_ids'].present?
users = User.find(object_auth['privilege_user_ids']) rescue nil
authorization.add_users(users) if users
end
end
end
def migrate_managers
@db ||= Mongoid.database
collection_app_manager = @db['app_managers']
app_managers = collection_app_manager.find(managing_app_id: {'$not' => {'$size' => 0}}).entries
app_managers.each do |app_manager|
module_app = ModuleApp.find(app_manager['managing_app_id']) rescue nil
user = User.find(app_manager['user_id']) rescue nil
if module_app && user
authorization = module_app.auth_manager || module_app.create_auth_manager(module_app_id: module_app.id, title: module_app.key)
authorization.add_users(user)
end
end
collection_app_manager.drop
end
task :reset_user_position => :environment do
@@ -3,12 +3,6 @@ en:
ad_banner:
ad_banner: Ad Banner
banner: Banner
banner_name: Banner Name
banner_name_note: Banner Name only english
ste: Transition Interval
ste_note: Please enter the number of seconds
best_size: Best Size
effect: Effect
all: All
categories: Categories
add: Add
@@ -3,12 +3,6 @@ zh_tw:
ad_banner:
ad_banner: 廣告輪播
banner: 橫幅
banner_name: 橫幅名稱
banner_name_note: 橫幅名稱只能為英文
ste: 轉換間隔時間
ste_note: 請輸入秒數
best_size: 最佳尺寸
effect: 效果
all: 全部
categories: 類別
add: 新增
+1 -3
View File
@@ -11,9 +11,7 @@ module AdBanner
update_info 'some update_info'
taggable
authorizable do
authorizable_on('AdBanner')
end
authorizable
# front_end do
# app_page 'bulletins'
@@ -9,33 +9,27 @@ class Panel::Ask::FrontEnd::AskQuestionsController < OrbitWidgetController
def index
@ask_question = AskQuestion.new
@categories = @module_app.categories.enabled
end
def create
@ask_question = AskQuestion.new(params[:ask_question])
if gotcha_valid? && @ask_question.save
@acknowledgement = AskAcknowledgement.last
@acknowledgement = AskAcknowledgement.last
@ask_acknowledgement = AskAcknowledgement.first || AskAcknowlegement.new
#@ask_question.save
#redirect_to root_path
AskAdmin.all.each do |ask_admin|
AskMailer.notice(ask_admin, @ask_question).deliver
Resque.enqueue(SendAskNoticeMail, ask_admin.id, @ask_question.id)
end
# Render to create.js.erb
# redirect_to panel_ask_front_end_thank_you_path
respond_to do |format|
format.js
end
else
# Render to index.js.erb
respond_to do |format|
format.js { render :index }
# format.js { render :thank_you, notice: 'Your question has been successfully sent.' }
end
end
end
def thank_you
@acknowledgement = AskAcknowledgement.last
@item = Page.find(params[:page_id]) rescue nil
@@ -35,7 +35,7 @@ $(document).ready(function(){
<div class="control-group">
<%= f.label :ask_category_id, class: 'control-label required' %>
<div class="controls">
<%= f.select :category_id, @categories.collect{|t| [ t.title, t.id ]} %>
<%= f.collection_select :ask_category_id, AskCategory.all, :id, :name %>
</div>
</div>
<div class="control-group">
@@ -1 +0,0 @@
window.location.href = "<%= panel_ask_front_end_sorry_path %>";
@@ -1 +0,0 @@
<h3><%= t(:ask_fail, :scope => :ask) %> !</h3>
-2
View File
@@ -19,10 +19,8 @@ Rails.application.routes.draw do
namespace :front_end do
match "ask_questions/thank_you" => "ask_questions#thank_you", :as => 'thank_you'
match "ask_questions/sorry" => "ask_questions#sorry", :as => 'sorry'
resources :ask_questions
end
end
end