Merge branch 'fix_it'

Conflicts:
	app/assets/javascripts/page_edit.js
	app/assets/javascripts/rss.js
	app/assets/stylesheets/admin.css.erb
	app/assets/stylesheets/admin_back_end.css.erb
	app/controllers/admin/app_auths_controller.rb
	app/controllers/admin/module_apps_controller.rb
	app/controllers/admin/users_controller.rb
	app/controllers/application_controller.rb
	app/models/app_auth.rb
	app/models/user/user.rb
	app/views/admin/app_auths/index.html.erb
	app/views/admin/attributes/_attribute_field.html.erb
	app/views/admin/designs/_new.html.erb
	app/views/admin/designs/new.html.erb
	app/views/admin/infos/_form.html.erb
	app/views/admin/module_apps/_app_selector.html.erb
	app/views/admin/module_apps/index.html.erb
	app/views/admin/pages/_form.html.erb
	app/views/admin/roles/_form.html.erb
	app/views/admin/roles/_sub_role.html.erb
	app/views/admin/users/_form.html.erb
	app/views/admin/users/_show_sub_role.html.erb
	app/views/admin/users/_sub_role.html.erb
	app/views/admin/users/edit.html.erb
	app/views/admin/users/index.html.erb
	app/views/admin/users/new.html.erb
	app/views/admin/users/show.html.erb
	app/views/layouts/admin.html.erb
	lib/fraisier/layout.html
	lib/parsers/parser_back_end.rb
	lib/parsers/parser_layout.rb
	lib/tasks/dev.rake
	spec/models/app_auth_basic.rb
	vendor/built_in_modules/NewBlog/.gitignore
	vendor/built_in_modules/NewBlog/Gemfile
	vendor/built_in_modules/NewBlog/Gemfile.lock
	vendor/built_in_modules/NewBlog/MIT-LICENSE
	vendor/built_in_modules/NewBlog/NewBlog.gemspec
	vendor/built_in_modules/NewBlog/README.rdoc
	vendor/built_in_modules/NewBlog/Rakefile
	vendor/built_in_modules/NewBlog/app/assets/images/NewBlog/.gitkeep
	vendor/built_in_modules/NewBlog/app/assets/javascripts/NewBlog/.gitkeep
	vendor/built_in_modules/NewBlog/app/assets/stylesheets/NewBlog/.gitkeep
	vendor/built_in_modules/NewBlog/app/assets/stylesheets/NewBlog/application.css
	vendor/built_in_modules/NewBlog/app/assets/stylesheets/NewBlog/production.css
	vendor/built_in_modules/NewBlog/app/controllers/.gitkeep
	vendor/built_in_modules/NewBlog/app/controllers/application_controller.rb
	vendor/built_in_modules/NewBlog/app/controllers/panel/blog/back_end/posts_controller.rb
	vendor/built_in_modules/NewBlog/app/helpers/.gitkeep
	vendor/built_in_modules/NewBlog/app/helpers/application_helper.rb
	vendor/built_in_modules/NewBlog/app/mailers/.gitkeep
	vendor/built_in_modules/NewBlog/app/models/.gitkeep
	vendor/built_in_modules/NewBlog/app/models/comment.rb
	vendor/built_in_modules/NewBlog/app/models/post.rb
	vendor/built_in_modules/NewBlog/app/views/.gitkeep
	vendor/built_in_modules/NewBlog/app/views/layouts/application.html.erb
	vendor/built_in_modules/NewBlog/app/views/layouts/edit_view.html.erb
	vendor/built_in_modules/NewBlog/app/views/layouts/production.html.erb
	vendor/built_in_modules/NewBlog/app/views/panel/blog/back_end/posts/_form.html.erb
	vendor/built_in_modules/NewBlog/app/views/panel/blog/back_end/posts/index.html.erb
	vendor/built_in_modules/NewBlog/app/views/panel/blog/back_end/posts/latest_post.html.erb
	vendor/built_in_modules/NewBlog/app/views/panel/blog/back_end/posts/new.html.erb
	vendor/built_in_modules/NewBlog/app/views/panel/blog/back_end/posts/show.html.erb
	vendor/built_in_modules/NewBlog/app/views/panel/blog/front_end/posts/show.html.erb
	vendor/built_in_modules/NewBlog/app/views/panel/blog/widget/posts/index.html.erb
	vendor/built_in_modules/NewBlog/app/views/panel/blog/widget/posts/latest_post.html.erb
	vendor/built_in_modules/NewBlog/config/locales/en.yml
	vendor/built_in_modules/NewBlog/lib/NewBlog.rb
	vendor/built_in_modules/NewBlog/lib/NewBlog/engine.rb
	vendor/built_in_modules/NewBlog/lib/NewBlog/version.rb
	vendor/built_in_modules/NewBlog/lib/tasks/NewBlog_tasks.rake
	vendor/built_in_modules/NewBlog/script/rails
	vendor/built_in_modules/NewBlog/test/NewBlog_test.rb
	vendor/built_in_modules/NewBlog/test/dummy/Rakefile
	vendor/built_in_modules/NewBlog/test/dummy/app/assets/javascripts/application.js
	vendor/built_in_modules/NewBlog/test/dummy/app/assets/stylesheets/application.css
	vendor/built_in_modules/NewBlog/test/dummy/app/controllers/application_controller.rb
	vendor/built_in_modules/NewBlog/test/dummy/app/helpers/application_helper.rb
	vendor/built_in_modules/NewBlog/test/dummy/app/mailers/.gitkeep
	vendor/built_in_modules/NewBlog/test/dummy/app/models/.gitkeep
	vendor/built_in_modules/NewBlog/test/dummy/app/views/layouts/application.html.erb
	vendor/built_in_modules/NewBlog/test/dummy/config.ru
	vendor/built_in_modules/NewBlog/test/dummy/config/application.rb
	vendor/built_in_modules/NewBlog/test/dummy/config/boot.rb
	vendor/built_in_modules/NewBlog/test/dummy/config/database.yml
	vendor/built_in_modules/NewBlog/test/dummy/config/environment.rb
	vendor/built_in_modules/NewBlog/test/dummy/config/environments/development.rb
	vendor/built_in_modules/NewBlog/test/dummy/config/environments/production.rb
	vendor/built_in_modules/NewBlog/test/dummy/config/environments/test.rb
	vendor/built_in_modules/NewBlog/test/dummy/config/initializers/backtrace_silencers.rb
	vendor/built_in_modules/NewBlog/test/dummy/config/initializers/inflections.rb
	vendor/built_in_modules/NewBlog/test/dummy/config/initializers/mime_types.rb
	vendor/built_in_modules/NewBlog/test/dummy/config/initializers/secret_token.rb
	vendor/built_in_modules/NewBlog/test/dummy/config/initializers/session_store.rb
	vendor/built_in_modules/NewBlog/test/dummy/config/initializers/wrap_parameters.rb
	vendor/built_in_modules/NewBlog/test/dummy/config/locales/en.yml
	vendor/built_in_modules/NewBlog/test/dummy/config/mongoid.yml
	vendor/built_in_modules/NewBlog/test/dummy/config/routes.rb
	vendor/built_in_modules/NewBlog/test/dummy/lib/assets/.gitkeep
	vendor/built_in_modules/NewBlog/test/dummy/log/.gitkeep
	vendor/built_in_modules/NewBlog/test/dummy/public/404.html
	vendor/built_in_modules/NewBlog/test/dummy/public/422.html
	vendor/built_in_modules/NewBlog/test/dummy/public/500.html
	vendor/built_in_modules/NewBlog/test/dummy/public/favicon.ico
	vendor/built_in_modules/NewBlog/test/dummy/script/rails
	vendor/built_in_modules/NewBlog/test/integration/navigation_test.rb
	vendor/built_in_modules/NewBlog/test/test_helper.rb
	vendor/built_in_modules/blog/app/controllers/application_controller.rb
	vendor/built_in_modules/blog/app/controllers/panel/blog/posts_controller.rb
	vendor/built_in_modules/blog/app/helpers/application_helper.rb
	vendor/built_in_modules/blog/app/models/comment.rb
	vendor/built_in_modules/blog/app/models/post.rb
	vendor/built_in_modules/blog/app/views/layouts/application.html.erb
	vendor/built_in_modules/blog/app/views/panel/blog/posts/_form.html.erb
	vendor/built_in_modules/blog/app/views/panel/blog/posts/index.html.erb
	vendor/built_in_modules/blog/app/views/panel/blog/posts/show.html.erb
	vendor/built_in_modules/blog/config/initializers/backtrace_silencers.rb
	vendor/built_in_modules/blog/config/initializers/inflections.rb
	vendor/built_in_modules/blog/config/initializers/mime_types.rb
	vendor/built_in_modules/blog/public/404.html
	vendor/built_in_modules/blog/public/422.html
	vendor/built_in_modules/blog/public/500.html
	vendor/built_in_modules/blog/public/favicon.ico
	vendor/built_in_modules/blog/public/stylesheets/.gitkeep
	vendor/built_in_modules/blog/script/rails
	vendor/built_in_modules/blog/vendor/plugins/.gitkeep
	vendor/built_in_modules/new_blog/.gitignore
	vendor/built_in_modules/new_blog/Gemfile
	vendor/built_in_modules/new_blog/Gemfile.lock
	vendor/built_in_modules/new_blog/MIT-LICENSE
	vendor/built_in_modules/new_blog/README.rdoc
	vendor/built_in_modules/new_blog/Rakefile
	vendor/built_in_modules/new_blog/app/assets/images/NewBlog/.gitkeep
	vendor/built_in_modules/new_blog/app/assets/javascripts/NewBlog/.gitkeep
	vendor/built_in_modules/new_blog/app/assets/stylesheets/NewBlog/.gitkeep
	vendor/built_in_modules/new_blog/app/assets/stylesheets/NewBlog/application.css
	vendor/built_in_modules/new_blog/app/assets/stylesheets/NewBlog/production.css
	vendor/built_in_modules/new_blog/app/controllers/.gitkeep
	vendor/built_in_modules/new_blog/app/controllers/application_controller.rb
	vendor/built_in_modules/new_blog/app/controllers/panel/new_blog/back_end/posts_controller.rb
	vendor/built_in_modules/new_blog/app/helpers/.gitkeep
	vendor/built_in_modules/new_blog/app/mailers/.gitkeep
	vendor/built_in_modules/new_blog/app/models/.gitkeep
	vendor/built_in_modules/new_blog/app/models/comment.rb
	vendor/built_in_modules/new_blog/app/models/post.rb
	vendor/built_in_modules/new_blog/app/views/.gitkeep
	vendor/built_in_modules/new_blog/app/views/layouts/application.html.erb
	vendor/built_in_modules/new_blog/app/views/layouts/edit_view.html.erb
	vendor/built_in_modules/new_blog/app/views/layouts/production.html.erb
	vendor/built_in_modules/new_blog/app/views/panel/new_blog/back_end/posts/_form.html.erb
	vendor/built_in_modules/new_blog/app/views/panel/new_blog/back_end/posts/index.html.erb
	vendor/built_in_modules/new_blog/app/views/panel/new_blog/back_end/posts/latest_post.html.erb
	vendor/built_in_modules/new_blog/app/views/panel/new_blog/back_end/posts/new.html.erb
	vendor/built_in_modules/new_blog/app/views/panel/new_blog/back_end/posts/show.html.erb
	vendor/built_in_modules/new_blog/app/views/panel/new_blog/front_end/posts/show.html.erb
	vendor/built_in_modules/new_blog/app/views/panel/new_blog/widget/posts/index.html.erb
	vendor/built_in_modules/new_blog/app/views/panel/new_blog/widget/posts/latest_post.html.erb
	vendor/built_in_modules/new_blog/config/locales/en.yml
	vendor/built_in_modules/new_blog/lib/new_blog/version.rb
	vendor/built_in_modules/new_blog/lib/tasks/NewBlog_tasks.rake
	vendor/built_in_modules/new_blog/new_blog.gemspec
	vendor/built_in_modules/new_blog/script/rails
	vendor/built_in_modules/new_blog/test/NewBlog_test.rb
	vendor/built_in_modules/new_blog/test/dummy/Rakefile
	vendor/built_in_modules/new_blog/test/dummy/app/assets/javascripts/application.js
	vendor/built_in_modules/new_blog/test/dummy/app/assets/stylesheets/application.css
	vendor/built_in_modules/new_blog/test/dummy/app/controllers/application_controller.rb
	vendor/built_in_modules/new_blog/test/dummy/app/helpers/application_helper.rb
	vendor/built_in_modules/new_blog/test/dummy/app/mailers/.gitkeep
	vendor/built_in_modules/new_blog/test/dummy/app/models/.gitkeep
	vendor/built_in_modules/new_blog/test/dummy/app/views/layouts/application.html.erb
	vendor/built_in_modules/new_blog/test/dummy/config.ru
	vendor/built_in_modules/new_blog/test/dummy/config/application.rb
	vendor/built_in_modules/new_blog/test/dummy/config/boot.rb
	vendor/built_in_modules/new_blog/test/dummy/config/database.yml
	vendor/built_in_modules/new_blog/test/dummy/config/environment.rb
	vendor/built_in_modules/new_blog/test/dummy/config/environments/development.rb
	vendor/built_in_modules/new_blog/test/dummy/config/environments/production.rb
	vendor/built_in_modules/new_blog/test/dummy/config/environments/test.rb
	vendor/built_in_modules/new_blog/test/dummy/config/initializers/backtrace_silencers.rb
	vendor/built_in_modules/new_blog/test/dummy/config/initializers/inflections.rb
	vendor/built_in_modules/new_blog/test/dummy/config/initializers/mime_types.rb
	vendor/built_in_modules/new_blog/test/dummy/config/initializers/secret_token.rb
	vendor/built_in_modules/new_blog/test/dummy/config/initializers/session_store.rb
	vendor/built_in_modules/new_blog/test/dummy/config/initializers/wrap_parameters.rb
	vendor/built_in_modules/new_blog/test/dummy/config/locales/en.yml
	vendor/built_in_modules/new_blog/test/dummy/config/mongoid.yml
	vendor/built_in_modules/new_blog/test/dummy/config/routes.rb
	vendor/built_in_modules/new_blog/test/dummy/lib/assets/.gitkeep
	vendor/built_in_modules/new_blog/test/dummy/log/.gitkeep
	vendor/built_in_modules/new_blog/test/dummy/public/404.html
	vendor/built_in_modules/new_blog/test/dummy/public/422.html
	vendor/built_in_modules/new_blog/test/dummy/public/500.html
	vendor/built_in_modules/new_blog/test/dummy/public/favicon.ico
	vendor/built_in_modules/new_blog/test/dummy/script/rails
	vendor/built_in_modules/new_blog/test/integration/navigation_test.rb
	vendor/built_in_modules/new_blog/test/test_helper.rb
	vendor/plugins/NewBlog/.gitignore
	vendor/plugins/NewBlog/Gemfile
	vendor/plugins/NewBlog/Gemfile.lock
	vendor/plugins/NewBlog/MIT-LICENSE
	vendor/plugins/NewBlog/NewBlog.gemspec
	vendor/plugins/NewBlog/README.rdoc
	vendor/plugins/NewBlog/Rakefile
	vendor/plugins/NewBlog/app/assets/images/NewBlog/.gitkeep
	vendor/plugins/NewBlog/app/assets/javascripts/NewBlog/.gitkeep
	vendor/plugins/NewBlog/app/assets/stylesheets/NewBlog/.gitkeep
	vendor/plugins/NewBlog/app/assets/stylesheets/NewBlog/application.css
	vendor/plugins/NewBlog/app/assets/stylesheets/NewBlog/production.css
	vendor/plugins/NewBlog/app/controllers/.gitkeep
	vendor/plugins/NewBlog/app/helpers/.gitkeep
	vendor/plugins/NewBlog/app/mailers/.gitkeep
	vendor/plugins/NewBlog/app/models/.gitkeep
	vendor/plugins/NewBlog/app/views/.gitkeep
	vendor/plugins/NewBlog/app/views/layouts/edit_view.html.erb
	vendor/plugins/NewBlog/app/views/layouts/production.html.erb
	vendor/plugins/NewBlog/app/views/panel/blog/posts/index.html.erb
	vendor/plugins/NewBlog/app/views/panel/blog/posts/latest_post.html.erb
	vendor/plugins/NewBlog/app/views/panel/blog/posts/new.html.erb
	vendor/plugins/NewBlog/app/views/panel/blog/posts/show.html.erb
	vendor/plugins/NewBlog/app/views/panel/blog/posts/widget_index.html.erb
	vendor/plugins/NewBlog/app/views/panel/blog/posts/widget_latest_post.html.erb
	vendor/plugins/NewBlog/config/locales/en.yml
	vendor/plugins/NewBlog/lib/NewBlog/version.rb
	vendor/plugins/NewBlog/lib/tasks/NewBlog_tasks.rake
	vendor/plugins/NewBlog/script/rails
	vendor/plugins/NewBlog/test/NewBlog_test.rb
	vendor/plugins/NewBlog/test/dummy/Rakefile
	vendor/plugins/NewBlog/test/dummy/app/assets/javascripts/application.js
	vendor/plugins/NewBlog/test/dummy/app/assets/stylesheets/application.css
	vendor/plugins/NewBlog/test/dummy/app/controllers/application_controller.rb
	vendor/plugins/NewBlog/test/dummy/app/mailers/.gitkeep
	vendor/plugins/NewBlog/test/dummy/app/models/.gitkeep
	vendor/plugins/NewBlog/test/dummy/app/views/layouts/application.html.erb
	vendor/plugins/NewBlog/test/dummy/config.ru
	vendor/plugins/NewBlog/test/dummy/config/application.rb
	vendor/plugins/NewBlog/test/dummy/config/boot.rb
	vendor/plugins/NewBlog/test/dummy/config/database.yml
	vendor/plugins/NewBlog/test/dummy/config/environment.rb
	vendor/plugins/NewBlog/test/dummy/config/environments/development.rb
	vendor/plugins/NewBlog/test/dummy/config/environments/production.rb
	vendor/plugins/NewBlog/test/dummy/config/environments/test.rb
	vendor/plugins/NewBlog/test/dummy/config/initializers/secret_token.rb
	vendor/plugins/NewBlog/test/dummy/config/initializers/session_store.rb
	vendor/plugins/NewBlog/test/dummy/config/initializers/wrap_parameters.rb
	vendor/plugins/NewBlog/test/dummy/config/locales/en.yml
	vendor/plugins/NewBlog/test/dummy/config/mongoid.yml
	vendor/plugins/NewBlog/test/dummy/config/routes.rb
	vendor/plugins/NewBlog/test/integration/navigation_test.rb
	vendor/plugins/NewBlog/test/test_helper.rb
This commit is contained in:
chris2tof 2012-01-12 18:15:43 +08:00
commit 4be97f6ea6
121 changed files with 534 additions and 346 deletions

View File

@ -6,7 +6,7 @@ $("#page_design_id").live('change', function() {
$.getScript($(this).attr('rel') + '/' + $(this).val() + '/reload_themes');
});
$("#page_module_app").live('change', function() {
$("#page_module_app_id").live('change', function() {
var app_id = $(this).val();
if(app_id!=''){
$.getScript($(this).attr('rel') + '/' + $(this).val() + '/reload_frontend_pages',function(data, textStatus){
@ -16,6 +16,6 @@ $("#page_module_app").live('change', function() {
});
}
else{
$("#app_page_url").remove();
$("#app_page_url").children().remove();
}
});

View File

@ -392,7 +392,6 @@ modalWindow : function(settings,callbackFn){
tempwidth=maxwidth;
}else{tempwidth="auto";}
$rss("body").append('<div class="rgmask" id="rgsheath" style="height:'+rgmaskHeight+'px"></div>');
$rss("#rgsheath").css({background: "#000", width: "100%", position: "fixed", top: 0, left: 0,opacity:0.9,'z-index':199});
$rss("body").append('<div id="rgWindow"></div>');

View File

@ -4,14 +4,15 @@ class Admin::AppAuthsController < ApplicationController
before_filter :is_admin?
def index
@user_roles = UserRole.all.entries
apps = Purchase.where(:type =>"App")
@app_auth_data = apps.entries.map do |app|
app_c = eval(app.app_controller)
obj = app_c.new
obj_auth = obj.send "auth"
[:app_obj => app,:auth_field => obj_auth]
end
# @roles = Role.all.entries
# apps = Purchase.where(:type =>"App")
# @app_auth_data = apps.entries.map do |app|
# app_c = eval(app.app_controller)
# obj = app_c.new
# obj_auth = obj.send "auth"
# [:app_obj => app,:auth_field => obj_auth]
# end
@module_apps = ModuleApp.all
end
end

View File

@ -1,9 +1,33 @@
class Admin::ModuleAppsController < ApplicationController
layout "admin"
def reload_frontend_pages
@module_app = ModuleApp.find(params[:id])
respond_to do |format|
format.js {}
def index
@module_apps = ModuleApp.all.entries
end
def reload_frontend_pages
@module_app = ModuleApp.find(params[:id])
respond_to do |format|
format.js {}
end
end
def edit
@module_app = ModuleApp.find(params[:id])
end
def update
@module_app = ModuleApp.find(params[:id])
unless params['module_app']['enable_frontend'].nil?
@module_app.update_attribute('enable_frontend',params['module_app']['enable_frontend'])
@module_app.save!
end
@attribute = @module_app
respond_to do |format|
format.html { redirect_to :action => :index }
format.js { render 'admin/attributes/toggle_enable' }
end
end
end
end

View File

@ -28,7 +28,7 @@ class Admin::PagePartsController < ApplicationController
@partial = 'edit_text'
@part_locale = params[:part_locale] || I18n.locale.to_s
when 'module'
@plugins=[{:module=>"Blog",:widgets=>[{:name=>"Blog",:path=>"panel/blog/widget_latest_post"},{:name=>"Blog",:path=>"panel/blog/widget_index"}]}]
@plugins=[{:module=>"Blog",:widgets=>[{:name=>"Blog",:path=>"panel/new_blog/widget_latest_post"},{:name=>"Blog",:path=>"panel/new_blog/widget_index"}]}]
when 'snippet'
end
end

View File

@ -32,6 +32,7 @@ class Admin::PagesController < ApplicationController
@i18n_variable = @item.i18n_variable
@designs = Design.all.entries
@design = @item.design
@app_frontend_urls = @item.module_app.app_pages
end
def create

View File

@ -5,9 +5,16 @@ class ApplicationController < ActionController::Base
helper :all
before_filter :set_locale, :set_site
def front_end_available(module_app_title='')
app_controller = ModuleApp.first(conditions: {:title => module_app_title} )
unless app_controller.enable_frontend?
render :nothing
end
end
def get_all_app_engines
ary = ["vender/plugins/NewBlog"]
ary = ["vender/plugins/new_blog"]
app_engines = ary.collect{|t|
Rails::Engine.find t
}

View File

@ -0,0 +1,4 @@
class ObitFrontendComponentController< ApplicationController
before_filter {|c| c.front_end_available(@app_title)}
layout 'production'
end

View File

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

View File

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

View File

@ -0,0 +1,6 @@
module Admin::AppAuthHelper
def on_off_switch(attribute,attribute_type)
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
end

View File

@ -15,55 +15,72 @@ class AppAuth
has_and_belongs_to_many :roles
has_and_belongs_to_many :sub_roles
attr_protected :roles,:sub_roles,:privilege_users,:blocked_users,:users
def add_role role
add_operation(:roles,role)
end
def add_sub_role role
add_operation(:sub_roles,role)
end
def remove_role role
remove_operation(:roles,role)
end
def remove_sub_role role
remove_operation(:sub_roles,role)
end
def add_user_to_black_list user
unless self.blocked_users.include?(user)
self.blocked_users << user
self.save!
else
false #should put error message for user existed in list already
end
add_operation(:blocked_users,user)
end
def remove_user_from_black_list user
if self.blocked_users.include? user
self.blocked_users.delete user
remove_operation(:blocked_users,user)
end
def add_user_to_privilege_list user
add_operation(:privilege_users,user)
end
def remove_user_from_privilege_list user
remove_operation(:privilege_users,user)
end
def remove_operation(item,obj)
if (self.send item).include? obj
(self.send item).delete obj
self.save!
else
false #should put error message for user not existed in list
end
end
end
def add_user_to_privilege_list user
unless self.privilege_users.include? user
self.privilege_users << user
def add_operation(item,obj)
unless (self.send item).include?(obj)
(self.send item) << obj
self.save!
else
false #should put error message for user existed in list already
end
end
def remove_user_from_privilege_list user
if self.privilege_users.include? user
self.privilege_users.delete user
self.save!
else
false #should put error message for user not existed in list
end
end
def auth_users
if self.all?
User.all.entries
else
ary= self.roles.collect do |role|
role.users
ary=[]
[:roles,:sub_roles].each do |t_role|
ary += (self.send t_role).collect do |role|
role.users
end
end
ary << self.privilege_users
ary.flatten!
ary.flatten!.uniq
end
end

View File

@ -9,6 +9,14 @@ class ModuleApp
field :intro
field :update_info
field :create_date
field :enable_frontend,type: Boolean
field :app_pages ,type: Array
field :widgets ,type: Array
has_one :app_auth,dependent: :delete
field :app_pages ,type: Array

View File

@ -19,7 +19,10 @@ class User
accepts_nested_attributes_for :attribute_values, :allow_destroy => true
def avb_apps
query = AppAuth.any_of({all: true},{privilege_user_ids: self.id},{roles: self.role.id}).excludes(blocked_user_ids: self.id)
sub_role_ids_ary=self.sub_roles.collect{|t| t.id}
query1 = AppAuth.any_in({sub_role_ids: sub_role_ids_ary}).excludes(blocked_user_ids: self.id)
query2 = AppAuth.any_of({all: true},{privilege_user_ids: self.id},{role_ids: self.role.id}).excludes(blocked_user_ids: self.id)
(query1 + query2).uniq
end
def name

View File

@ -1,32 +1,52 @@
<% content_for :secondary do %>
<div id='user_list'>
<div class="role_list">
<h1>User Role</h1>
<ul class="list">
<% @roles.each do |role| %>
<li class="set_1"><%= link_to content_tag(:span, "Role") %></li>
<% end -%>
</ul>
</div>
</div>
<% end -%>
<h1><%= t('admin.list_app_auths') %></h1>
<table>
<tr>
<th><%= t('admin.app.name') %></th>
<th><%= t('admin.description') %></th>
</tr>
<% @app_auth_data.each do |app| %>
<tr>
<td><%= app[0][:app_obj].title %></td>
<% app[0][:auth_field].each do |unit| %>
<td>
<%= render :partial => "auth_unit",:locals => {:unit => unit } %>
</td>
<%end%>
</tr>
<% #render 'side_bar' %>
<% end %>
</table>
<div class="main_list">
<%= flash_messages %>
<div class="button_bar up">
<% #link_to t('admin.new_user'), new_admin_user_path, :class => 'new' %>
</div>
<table>
<thead>
<tr>
<td><%= t('admin.app.title') %></td>
<td><%= t('admin.app.description') %></td>
<td><%= t('admin.app.use_status') %></td>
<td><%= t('admin.app.autdor') %></td>
<td><%= t('admin.app.organization') %></td>
<td><%= t('admin.app.version') %></td>
<td class="action"><%= t('admin.action') %></td>
</tr>
</thead>
<tbody>
<% @module_apps.each do |module_app| %>
<tr class="have" id="attribute_<%= module_app.id %>" class="have <%= "#{module_app.enable_frontend? ? 'disable' : ''}" %>">
<td class="name"><%= module_app.title %></td>
<td class="name"><%= module_app.intro %></td>
<td>
<% attribute_type = "module_app" %>
<% attribute = module_app %>
<%= link_to t(:enable), admin_module_app_path(attribute, :authenticity_token => form_authenticity_token, :module_app => {:enable_frontend => true}), :remote => true, :method => :put, :id => "disable_#{attribute.id}", :style => "display:#{attribute.enable_frontend ? 'none' : ''}", :class => 'switch' %>
<%= link_to t(:disable), admin_module_app_path(attribute, :authenticity_token => form_authenticity_token, :module_app => {:enable_frontend => false}), :remote => true, :method => :put, :id => "enable_#{attribute.id}", :style => "display:#{attribute.enable_frontend ? '' : 'none'}", :class => 'switch' %>
</td>
<td class="email"><%= module_app.author %></td>
<td class="email"><%= module_app.organization %></td>
<td class="admin"><%= module_app.version %></td>
<td class="action">
<%= link_to t(:show), admin_module_app_path(module_app), :class => 'show' %>
<%= link_to t(:edit), edit_admin_module_app_path(module_app), :class => 'edit' %>
<%= link_to t(:delete), admin_module_app_path(module_app), :class => 'delete', :confirm => t('sure?'), :method => :delete %>
</td>
</tr>
<tr>
<td colspan="5"></td>
</tr>
<% end %>
</tbody>
</table>
<div class="button_bar">
<%# link_to t('admin.new_user'), new_admin_user_path, :class => 'new' %>
</div>
</div>

View File

@ -38,7 +38,7 @@
<%= f.hidden_field :to_save, :value => true %>
<% end %>
<% else %>
<%= File.basename (@design.default_css.file.url) %>
<%= File.basename (@design.default_css.file.url) rescue "" %>
<% end %>
</p>
<p>

View File

@ -1,6 +1,6 @@
<h1><%= t('admin.new_design') %></h1>
<%= form_for :design, :url => admin_designs_path do |f| %>
<%= form_for @design, :url => admin_design_path(@design),:html => {:multipart => true} do |f| %>
<%= f.error_messages %>
<%= render :partial => "form", :locals => { :f => f } %>

View File

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

View File

@ -33,7 +33,7 @@
<p>
<%= t('admin.module_app') %>
<%= render :partial => "admin/module_apps/app_selector", :locals => { :f => f } %>
<span id="app_page_url"></span>
<span id="app_page_url"><%= select('page','app_frontend_url', @app_frontend_urls ) rescue ''%> </span>
</p>
<p>
<%= f.label :is_published, "#{t('admin.is_published')} ?" %>

View File

@ -1,59 +1,59 @@
<div class="info_input">
<table border="0" cellspacing="0" cellpadding="0">
<thead class="list_head">
<tr>
<td><%= t('admin.key') %></td>
<% @site_valid_locales.each do |locale| %>
<td><%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %></td>
<% end %>
</tr>
</thead>
<tbody>
<tr class="list_item">
<td><%= sub_role.new_record? ? (f.text_field :key, {:style => "width:150px"}) : sub_role.key %></td>
<%= f.fields_for :i18n_variable, (sub_role.new_record? ? sub_role.build_i18n_variable : sub_role.i18n_variable) do |f| %>
<% @site_valid_locales.each do |locale| %>
<td><%= f.text_field locale, :style => "width:150px" %></td>
<% end %>
<div class="info_input">
<table border="0" cellspacing="0" cellpadding="0">
<thead class="list_head">
<tr>
<td><%= t('admin.key') %></td>
<% @site_valid_locales.each do |locale| %>
<td><%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %></td>
<% end %>
</tr>
</thead>
<tbody>
<tr class="list_item">
<td><%= sub_role.new_record? ? (f.text_field :key, {:style => "width:150px"}) : sub_role.key %></td>
<%= f.fields_for :i18n_variable, (sub_role.new_record? ? sub_role.build_i18n_variable : sub_role.i18n_variable) do |f| %>
<% @site_valid_locales.each do |locale| %>
<td><%= f.text_field locale, :style => "width:150px" %></td>
<% end %>
<% end %>
</tr>
</tbody>
</table>
<div class="group">
<h2>Attributes</h2>
<div class="info_input">
<table class="sub_role_attributes" border="0" cellspacing="0" cellpadding="0">
<thead class="list_head">
<tr>
<td><%= t('admin.key') %></td>
<td><%= t('admin.multilingual') %></td>
<% @site_valid_locales.each do |locale| %>
<td><%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %></td>
<% end %>
<td><%= t('admin.type')%></td>
<td>&nbsp;</td>
</tr>
</thead>
<tfoot>
<tr>
<td colspan="6">
<div id='add_attribute'>
<%= hidden_field_tag 'attribute_field_count', sub_role.attribute_fields.count %>
<a href="#" class="add"><%= t(:add) %></a>
<%= hidden_field_tag 'sub_role_temp_id', (i rescue 'new_sub_roles') %>
</div>
</td>
</tr>
</tfoot>
<tbody>
<% sub_role.attribute_fields.each do |attribute_field| %>
<%= render :partial => 'attribute_field', :object => attribute_field, :locals => {:f => f} %>
<% end %>
</tr>
</tbody>
</table>
<div class="group">
<h2>Attributes</h2>
<div class="info_input">
<table class="sub_role_attributes" border="0" cellspacing="0" cellpadding="0">
<thead class="list_head">
<tr>
<td><%= t('admin.key') %></td>
<td><%= t('admin.multilingual') %></td>
<% @site_valid_locales.each do |locale| %>
<td><%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %></td>
<% end %>
<td><%= t('admin.type')%></td>
<td>&nbsp;</td>
</tr>
</thead>
<tfoot>
<tr>
<td colspan="6">
<div id='add_attribute'>
<%= hidden_field_tag 'attribute_field_count', sub_role.attribute_fields.count %>
<a href="#" class="add"><%= t(:add) %></a>
<%= hidden_field_tag 'sub_role_temp_id', (i rescue 'new_sub_roles') %>
</div>
</td>
</tr>
</tfoot>
<tbody>
<% sub_role.attribute_fields.each do |attribute_field| %>
<%= render :partial => 'attribute_field', :object => attribute_field, :locals => {:f => f} %>
<% end %>
</tbody>
</table>
</div>
</tbody>
</table>
</div>
</div>
</div>
<% content_for :page_specific_javascript do %>
<script>

View File

@ -1,39 +1,39 @@
<div id="sub_role_<%= sub_role.id %>" class="group" <%= raw(' style="display: none;"') unless @user.sub_role_ids.include?(sub_role.id) %>>
<h2><%= sub_role.i18n_variable[I18n.locale] %></h2>
<div class="info_input">
<table border="0" cellspacing="0" cellpadding="0">
<thead class="list_head">
<tr>
<td><%= t("admin.key") %></td>
<% @site_valid_locales.each do |locale| %>
<td><%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %></td>
<% end %>
</tr>
</thead>
<tbody>
<% sub_role.get_enabled_attribute_fields.each do |attr| %>
<h2><%= sub_role.i18n_variable[I18n.locale] %></h2>
<div class="info_input">
<table border="0" cellspacing="0" cellpadding="0">
<thead class="list_head">
<tr>
<td><%= t("admin.key") %></td>
<% @site_valid_locales.each do |locale| %>
<td><%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %></td>
<% end %>
</tr>
</thead>
<tbody>
<% sub_role.get_enabled_attribute_fields.each do |attr| %>
<%= f.fields_for :attribute_values, @user.get_value_from_field_id(attr.id) do |f| %>
<tr class="list_item">
<td><%= attr.i18n_variable[I18n.locale] %></td>
<% if attr["locale"] && attr["markup"] == 'text_field' %>
<% @site_valid_locales.each do |locale| %>
<td><%= f.text_field locale %></td>
<% end %>
<% else %>
<td colspan=<%= @site_valid_locales.size %>>
<% if attr["markup"] == "text_field" %>
<%= f.text_field :non_locale %>
<% elsif attr["markup"] == "select" %>
<%= f.select :non_locale, options_for_select(attr["options"], value['non_locale']) %>
<% end -%>
</td>
<% end -%>
<%= f.hidden_field :attribute_field_id, :value => attr.id %>
<%= f.hidden_field :key, :value => attr.key %>
</tr>
<tr class="list_item">
<td><%= attr.i18n_variable[I18n.locale] %></td>
<% if attr["locale"] && attr["markup"] == 'text_field' %>
<% @site_valid_locales.each do |locale| %>
<td><%= f.text_field locale %></td>
<% end %>
<% else %>
<td colspan=<%= @site_valid_locales.size %>>
<% if attr["markup"] == "text_field" %>
<%= f.text_field :non_locale %>
<% elsif attr["markup"] == "select" %>
<%= f.select :non_locale, options_for_select(attr["options"], value['non_locale']) %>
<% end -%>
</td>
<% end -%>
<%= f.hidden_field :attribute_field_id, :value => attr.id %>
<%= f.hidden_field :key, :value => attr.key %>
</tr>
<% end %>
<% end %>
</tbody>
</table>
<% end %>
</tbody>
</table>
</div>
</div>
</div>

View File

@ -2,7 +2,7 @@
<%= render 'side_bar' %>
<% end %>
<div id="profile" class="clear">>
<div id="profile" class="clear">
<%= form_for @user, :url => admin_user_path(@user), :html => { :multipart => true } do |f| %>
<%= f.error_messages %>
<%= render :partial => 'form', :locals => { :f => f } %>

Binary file not shown.

View File

@ -26,8 +26,8 @@
<div id="main_content" class="content">
<r:content name='content_1' main='true'>
</r:content>
<div class="dymanic_load" path="/panel/blog/widget/latest_post"></div>
<div class="dymanic_load" path="/panel/blog/widget/"></div>
<div class="dymanic_load" path="/panel/new_blog/widget/latest_post"></div>
<div class="dymanic_load" path="/panel/new_blog/widget/"></div>
</div>
<div id="footer" class="footer">

View File

@ -84,7 +84,7 @@ module ParserBackEnd
c.define_tag 'content' do |tag|
ret = ''
if (tag.attributes["main"] == "true" && !page.module_app.nil?)
# ret << "<div id='appfrontend' class='dymanic_load' path='#{page.app_frontend_url}'></div>"
ret << "<div id='appfrontend' class='dymanic_load' path='#{page.app_frontend_url}'></div>"
else
part = page.page_parts.detect{ |p| p.name.to_s == tag.attr['name'].to_s }
ret << "<div id='#{tag.attr['name']}' part_id='#{part.id}' class='editable' style='border:solid 1px; margin:5px; padding:5px;'>"

View File

@ -40,5 +40,4 @@ module ParserLayout
}
}
end
end

View File

@ -118,7 +118,7 @@ namespace :dev do
home = Page.create!( :i18n_variable_id => var_10.id, :design_id => design_1.id, :name => 'home', :is_published => true, :theme_id => theme.id )
home.page_parts.create!( :name => 'content_1', :content => File.open("#{Rails.root}/lib/template/home.page").read, :kind => 'text', :i18n_variable_id => var_13.id )
ModuleApp.create.from_json(File.open("#{Rails.root}/vendor/built_in_modules/NewBlog/NewBlog.json").read).save
ModuleApp.create.from_json(File.open("#{Rails.root}/vendor/built_in_modules/new_blog/new_blog.json").read).save
Post.create(:title=>"1st post",:body=>"Long long time ago.....")
Post.create(:title=>"2ec post",:body=>"And?.....")

View File

@ -6,129 +6,210 @@ describe AppAuth do
before do
User.all.destroy
UserRole.all.destroy
Role.all.destroy
SubRole.all.destroy
AppAuth.all.destroy
ModuleApp.all.destroy
#Create some fixtures of Main Role
main_role_key = ["Stud","Teacher","Staff"]
@new_main_role_list = main_role_key.each do |role|
new_role = UserRole.new :key => role
new_role = Role.new :key => role
new_role.save
end
#Create Some SubRoles
sub_role_key = ["graduated_school","undergraduated_school","TA","Senior"]
@new_main_role_list = sub_role_key.each do |role|
new_role = SubRole.new :key => role
new_role.save
end
#Create some users of User
user_emails = ["a_good_stud","a_bad_stud","a_teacher","a_staff"]
user_emails = ["a_good_ug_stud_1","a_good_ug_stud_2","a_bad_ug_stud","a_good_g_stud","a_bad_g_stud","a_teacher","a_staff"]
user_emails.each do |user_email|
email=user_email+"@rulingcom.com"
new_user = User.new :email=> email
new_user.save
end
@stud_MRK = UserRole.first(conditions:{key:"Stud"})
@teacher_MRK = UserRole.first(conditions:{key:"Teacher"})
@staff_MRK = UserRole.first(conditions:{key:"Staff"})
@good_stu = User.first(conditions:{email:"a_good_stud@rulingcom.com"})
@bad_stu = User.first(conditions:{email:"a_bad_stud@rulingcom.com"})
#MRK = Member Role Key SRK=Sub Role Key
@stud_MRK = Role.first(conditions:{key:"Stud"})
@teacher_MRK = Role.first(conditions:{key:"Teacher"})
@staff_MRK = Role.first(conditions:{key:"Staff"})
@graduated_SRK = SubRole.first(conditions:{key:"graduated_school"})
@under_graduated_SRK = SubRole.first(conditions:{key:"undergraduated_school"})
@ta_SRK = SubRole.first(conditions:{key:"TA"})
@senior_SRK = SubRole.first(conditions:{key:"Senior"})
@stud_MRK.sub_roles += [@graduated,@under_graduated,@ta]
@stud_MRK.save!
@teacher_MRK.sub_roles = [@senior]
@teacher_MRK.save!
@good_ug_stu_1 = User.first(conditions:{email:"a_good_ug_stud_1@rulingcom.com"})
@good_ug_stu_2 = User.first(conditions:{email:"a_good_ug_stud_2@rulingcom.com"})
@bad_ug_stu = User.first(conditions:{email:"a_bad_ug_stud@rulingcom.com"})
@good_g_stu = User.first(conditions:{email:"a_good_g_stud@rulingcom.com"})
@bad_g_stu = User.first(conditions:{email:"a_bad_g_stud@rulingcom.com"})
@teacher = User.first(conditions:{email:"a_teacher@rulingcom.com"})
@staff = User.first(conditions:{email:"a_staff@rulingcom.com"})
#setting Roles for users
@good_stu.user_role = @stud_MRK
@bad_stu.user_role = @stud_MRK
@teacher.user_role = @teacher_MRK
@staff.user_role = @staff_MRK
@good_g_stu.role = @stud_MRK
@bad_g_stu.role = @stud_MRK
@good_ug_stu_1.role = @stud_MRK
@good_ug_stu_2.role = @stud_MRK
@bad_ug_stu.role = @stud_MRK
@good_g_stu.sub_roles = [@graduated_SRK,@ta_SRK]
@bad_g_stu.sub_roles << @graduated_SRK
@good_ug_stu_1.sub_roles << @under_graduated_SRK
@good_ug_stu_2.sub_roles << @under_graduated_SRK
@bad_ug_stu.sub_roles << @under_graduated_SRK
@good_stu.save!
@bad_stu.save!
@teacher.role = @teacher_MRK
@staff.role = @staff_MRK
@good_g_stu.save!
@bad_g_stu.save!
@good_ug_stu_1.save!
@good_ug_stu_2.save!
@bad_ug_stu.save!
@teacher.save!
@staff.save!
end
describe "Testing basic structure" do
describe "Starting a ClassBulletin Auth for teacher , staff and ta" do
before do
@app_auth = AppAuth.new()
#all stud has access right
@app_auth.user_roles << @stud_MRK
@bulletin_app_auth = AppAuth.new()
#all teacher and staff has access right
@bulletin_app_auth.roles = [@teacher_MRK,@staff_MRK]
#all person with TA sub_role has access right
@bulletin_app_auth.sub_roles << @ta_SRK
#a_bad_stud add to block to app_auth
@app_auth.blocked_users << @bad_stu
#a_bad_ug_stud add to block to bulletin_app_auth
#@bulletin_app_auth.blocked_users << @bad_ug_stu
#all teacher has access right
@app_auth.user_roles << @teacher_MRK
# @bulletin_app_auth.roles << @teacher_MRK
@app_auth.privilege_users << @staff
@app_auth.save!
# @bulletin_app_auth.privilege_users << @staff
@bulletin_app_auth.save!
end
context "Should just initialize all obj that is needed" do
it "Testing @app_auth init result" do
@app_auth.user_roles.should have(2).item
it "Testing @bulletin_app_auth init result" do
@bulletin_app_auth.roles.should have(2).item #teacher staff
@bulletin_app_auth.sub_roles.should have(1).item #ta
end
it "@app_auth should have UserRoles: Stud , Teacher " do
key_ary = @app_auth.user_roles.collect do |role|
it "@bulletin_app_auth should have Roles: Staff , Teacher " do
key_ary = @bulletin_app_auth.roles.collect do |role|
role.key
end
key_ary.should == ["Stud","Teacher"]
key_ary.sort.should == ["Staff","Teacher"].sort
end
it "@app_auth should have one Privialage user which is belongs to Staff" do
p_user_ary = @app_auth.privilege_users.collect do |p_user|
p_user.user_role.key
end
p_user_ary.should include("Staff")
it "bulletin_app_auth should have 3 auth users" do
user_ary = [@teacher,@staff,@good_g_stu]
@bulletin_app_auth.auth_users.sort.should == user_ary.sort
check_user_has_app user_ary
end
it "@app_auth should have one student listed at blocklist" do
@bad_stu = User.first(conditions:{email:"a_bad_stud@rulingcom.com"})
@app_auth.blocked_users.should have(1).item
@app_auth.blocked_users.should include(@bad_stu)
it "Adding a undergraduate stud into app_auth by privilege list" do
user_ary = [@teacher,@staff,@good_g_stu,@good_ug_stu_1]
@bulletin_app_auth.add_user_to_privilege_list @good_ug_stu_1
@bulletin_app_auth.auth_users.sort.should == user_ary.sort
check_user_has_app user_ary
end
it "Adding all graudated-stud into app_auth" do
user_ary = [@teacher,@staff,@good_g_stu,@bad_g_stu]
@bulletin_app_auth.add_sub_role @graduated_SRK
@bulletin_app_auth.auth_users.sort.should == user_ary.sort
check_user_has_app user_ary
end
it "Blocking bad-graduate student" do
user_ary =[@teacher,@staff,@good_g_stu]
@bulletin_app_auth.add_sub_role @graduated_SRK
@bulletin_app_auth.add_user_to_black_list @bad_g_stu
@bulletin_app_auth.auth_users_after_block_list.sort.should == user_ary.sort
check_user_has_app user_ary
end
it "Removing all graudated-stud from app_auth" do
user_ary =[@teacher,@staff,@good_g_stu]
@bulletin_app_auth.add_sub_role @graduated_SRK
@bulletin_app_auth.remove_sub_role @graduated_SRK
@bulletin_app_auth.auth_users.sort.should == user_ary.sort
check_user_has_app user_ary
end
# it "@bulletin_app_auth should have one Privialage user which is belongs to Staff" do
# p_user_ary = @bulletin_app_auth.privilege_users.collect do |p_user|
# p_user.roles.key
# end
# p_user_ary.should include("Staff")
# end
# it "@bulletin_app_auth should have one student listed at blocklist" do
# @bad_stu = User.first(conditions:{email:"a_bad_g_stud@rulingcom.com"})
# @bulletin_app_auth.blocked_users.should have(1).item
# @bulletin_app_auth.blocked_users.should include(@bad_stu)
# end
it "[Development #1]-1.Authorizing roles: roles + blocklist" do
@good_stu = User.first(conditions:{email:"a_good_stud@rulingcom.com"})
@teacher = User.first(conditions:{email:"a_teacher@rulingcom.com"})
@staff = User.first(conditions:{email:"a_staff@rulingcom.com"})
ary = [@good_stu,@teacher,@staff]
@app_auth.auth_users_after_block_list.should == ary
end
it "[Development #1]-2.Authorizing single users: list of users [new_user1~2]" do
user_emails = ["new_user1","new_user2","new_user3","new_user4"]
user_emails.each do |user_email|
email=user_email+"@rulingcom.com"
new_user = User.new :email=> email
new_user.save
# it "[Development #1]-1.Authorizing roles: roles + blocklist" do
# @good_stu = User.first(conditions:{email:"a_good_g_stud@rulingcom.com"})
# @teacher = User.first(conditions:{email:"a_teacher@rulingcom.com"})
# @staff = User.first(conditions:{email:"a_staff@rulingcom.com"})
# ary = [@good_stu,@teacher,@staff]
# @bulletin_app_auth.auth_users_after_block_list.should == ary
# end
#
# it "[Development #1]-2.Authorizing single users: list of users [new_user1~2]" do
# user_emails = ["new_user1","new_user2","new_user3","new_user4"]
# user_emails.each do |user_email|
# email=user_email+"@rulingcom.com"
# new_user = User.new :email=> email
# new_user.save
# end
# user1= User.first(conditions:{email:"new_user1@rulingcom.com"})
# user2= User.first(conditions:{email:"new_user2@rulingcom.com"})
# user3= User.first(conditions:{email:"new_user3@rulingcom.com"})
# user4= User.first(conditions:{email:"new_user4@rulingcom.com"})
#
# @bulletin_app_auth.privilege_users << user1
# @bulletin_app_auth.privilege_users << user2
#
# @bulletin_app_auth.auth_users_after_block_list.should include(user1,user2)
# @bulletin_app_auth.auth_users_after_block_list.should_not include(user3,user4)
#
# end
#
# it "[Development #1]-3.Authorizing roles and single users: roles + blocklist + list of users" do
# @bulletin_app_auth.auth_users.should have(7).item
# end
#
# it "[Development #1]-4.Authorizing all: blocklist" do
# @bad_stu = User.first(conditions:{email:"a_bad_g_stud@rulingcom.com"})
# @new_bulletin_app_auth = (AppAuth.new :all => true)
# @new_bulletin_app_auth.blocked_users << @bad_stu
#
# @new_bulletin_app_auth.auth_users.should == User.all.entries
# @new_bulletin_app_auth.auth_users_after_block_list.should_not include(@bad_stu)
# @new_bulletin_app_auth.save!
# end
def check_user_has_app(user_ary)
user_ary.each do |user|
user.avb_apps.should include(@bulletin_app_auth)
end
user1= User.first(conditions:{email:"new_user1@rulingcom.com"})
user2= User.first(conditions:{email:"new_user2@rulingcom.com"})
user3= User.first(conditions:{email:"new_user3@rulingcom.com"})
user4= User.first(conditions:{email:"new_user4@rulingcom.com"})
@app_auth.privilege_users << user1
@app_auth.privilege_users << user2
@app_auth.auth_users_after_block_list.should include(user1,user2)
@app_auth.auth_users_after_block_list.should_not include(user3,user4)
end
it "[Development #1]-3.Authorizing roles and single users: roles + blocklist + list of users" do
@app_auth.auth_users.should have(4).item
end
it "[Development #1]-4.Authorizing all: blocklist" do
@bad_stu = User.first(conditions:{email:"a_bad_stud@rulingcom.com"})
@new_app_auth = (AppAuth.new :all => true)
@new_app_auth.blocked_users << @bad_stu
@new_app_auth.auth_users.should == User.all.entries
@new_app_auth.auth_users_after_block_list.should_not include(@bad_stu)
@new_app_auth.save!
end
end
end

View File

@ -1,7 +0,0 @@
class Panel::Blog::FrontEnd::CommentsController < ApplicationController
def create
@post = Post.find(params[:post_id])
@comment = @post.comments.create!(params[:comment])
redirect_to panel_blog_front_end_post_url(@post)
end
end

View File

@ -1,17 +0,0 @@
class Panel::Blog::FrontEnd::PostsController < ApplicationController
layout 'production'
# GET /posts
# GET /posts.xml
def index
@posts = Post.all
end
def show
@post = Post.find(params[:id])
end
end

View File

@ -1,8 +0,0 @@
<h1><%= t('blog.editing_post') %></h1>
<%= form_for @post, :url => panel_blog_back_end_post_path(@post) do |f| %>
<%= render :partial => 'form', :locals => {:f => f} %>
<% end %>
<%= link_to t('blog.show'), panel_blog_back_end_post_path(@post) %> |
<%= link_back %>

View File

@ -1,5 +0,0 @@
require "NewBlog/engine"
module NewBlog
end

View File

@ -1,6 +0,0 @@
module NewBlog
class Engine < Rails::Engine
isolate_namespace NewBlog
PrototypeR4::Application::Orbit_Apps << "NewBlog"
end
end

View File

@ -1,2 +0,0 @@
module ApplicationHelper
end

View File

@ -1,25 +0,0 @@
<h1><%= t('blog.list_post') %></h1>
<table>
<tr>
<th><%= t('blog.title') %></th>
<th><%= t('blog.body') %></th>
<th></th>
<th></th>
<th></th>
</tr>
<% @posts.each do |post| %>
<tr>
<td><%= post.title %></td>
<td><%= post.body %></td>
<td><%= link_to t('blog.show'), panel_blog_post_path(post) %></td>
<td><%= link_to t('blog.edit'), edit_panel_blog_post_path(post) %></td>
<td><%= link_to t('blog.delete'), panel_blog_post_path(post), :confirm => t('blog.sure?'), :method => :delete %></td>
</tr>
<% end %>
</table>
<br />
<%= link_to t('blog.new_post'), new_panel_blog_back_end_post_path %>

View File

@ -1,4 +1,4 @@
class Panel::Blog::BackEnd::PostsController < ApplicationController
class Panel::NewBlog::BackEnd::PostsController < ApplicationController
layout 'admin'
@ -45,7 +45,7 @@ class Panel::Blog::BackEnd::PostsController < ApplicationController
respond_to do |format|
if @post.save
format.html { redirect_to(panel_blog_post_url(@post), :notice => t('blog.create_post_success')) }
format.html { redirect_to(panel_new_blog_post_url(@post), :notice => t('blog.create_post_success')) }
format.xml { render :xml => @post, :status => :created, :location => @post }
else
format.html { render :action => "new" }
@ -61,7 +61,7 @@ class Panel::Blog::BackEnd::PostsController < ApplicationController
respond_to do |format|
if @post.update_attributes(params[:post])
format.html { redirect_to(panel_blog_post_url(@post), :notice => t('blog.update_post_success')) }
format.html { redirect_to(panel_new_blog_post_url(@post), :notice => t('blog.update_post_success')) }
format.xml { head :ok }
else
format.html { render :action => "edit" }
@ -77,7 +77,7 @@ class Panel::Blog::BackEnd::PostsController < ApplicationController
@post.destroy
respond_to do |format|
format.html { redirect_to(panel_blog_posts_url) }
format.html { redirect_to(panel_new_blog_posts_url) }
format.xml { head :ok }
end
end

View File

@ -0,0 +1,7 @@
class Panel::NewBlog::FrontEnd::CommentsController < ObitFrontendController
def create
@post = Post.find(params[:post_id])
@comment = @post.comments.create!(params[:comment])
redirect_to panel_new_blog_front_end_post_url(@post)
end
end

View File

@ -0,0 +1,21 @@
class Panel::NewBlog::FrontEnd::PostsController < ObitFrontendController
def initialize
super
@app_title = NewBlog::MOUDLEAPP_TITLE
end
# GET /posts
# GET /posts.xml
def index
@posts = Post.all
end
def show
@post = Post.find(params[:id])
end
end

View File

@ -1,7 +1,12 @@
class Panel::Blog::Widget::PostsController < ApplicationController
class Panel::NewBlog::Widget::PostsController < ObitWidgetController
layout 'production'
def initialize
super
@app_title = NewBlog::MOUDLEAPP_TITLE
end
# GET /posts
# GET /posts.xml
def index

View File

@ -0,0 +1,6 @@
module ApplicationHelper
def check_show_frontend
front_end_available(NewBlog::MOUDLEAPP_TITLE)
end
end

View File

@ -0,0 +1,5 @@
module NewBlogHelper
def self.check_show_frontend
ApplicationController.front_end_available(NewBlog::MOUDLEAPP_TITLE)
end
end

View File

@ -0,0 +1,8 @@
<h1><%= t('blog.editing_post') %></h1>
<%= form_for @post, :url => panel_new_blog_back_end_post_path(@post) do |f| %>
<%= render :partial => 'form', :locals => {:f => f} %>
<% end %>
<%= link_to t('blog.show'), panel_new_blog_back_end_post_path(@post) %> |
<%= link_back %>

View File

@ -1,6 +1,6 @@
<% content_for :secondary do %>
<ul class="list">
<li><%= link_to t('blog.new_post'), new_panel_blog_back_end_post_path, :class => 'seclink1' %></li>
<li><%= link_to t('blog.new_post'), new_panel_new_blog_back_end_post_path, :class => 'seclink1' %></li>
</ul>
<% end -%>
@ -21,9 +21,9 @@
<tr>
<td><%= post.title %></td>
<td><%= truncate(post.body,:length=>15) %></td>
<td><%= link_to t('blog.show'), panel_blog_back_end_post_path(post) %></td>
<td><%= link_to t('blog.edit'), edit_panel_blog_back_end_post_path(post) %></td>
<td><%= link_to t('blog.delete'), panel_blog_back_end_post_path(post), :confirm => t('blog.sure?'), :method => :delete %></td>
<td><%= link_to t('blog.show'), panel_new_blog_back_end_post_path(post) %></td>
<td><%= link_to t('blog.edit'), edit_panel_new_blog_back_end_post_path(post) %></td>
<td><%= link_to t('blog.delete'), panel_new_blog_back_end_post_path(post), :confirm => t('blog.sure?'), :method => :delete %></td>
</tr>
<% end %>
</table>

View File

@ -1,4 +1,4 @@
<%=stylesheet_link_tag "NewBlog/application"%>
<%=stylesheet_link_tag "new_blog/application"%>
<h2><%=@post.title%></h2>
<p>
<%= @post.body%>

View File

@ -1,12 +1,12 @@
<% content_for :secondary do %>
<ul class="list">
<li><%= link_to t('blog.index'), panel_blog_back_end_posts_path, :class => 'seclink2' %></li>
<li><%= link_to t('blog.index'), panel_new_blog_back_end_posts_path, :class => 'seclink2' %></li>
</ul>
<% end -%>
<%= flash_messages %>
<h1><%= t('blog.new_post') %></h1>
<%= form_for @post, :url => panel_blog_back_end_posts_path do |f| %>
<%= form_for @post, :url => panel_new_blog_back_end_posts_path do |f| %>
<%= render :partial => 'form', :locals => {:f => f} %>
<% end %>

View File

@ -18,7 +18,7 @@
</p>
<% end %>
<%= form_for Comment.new, :url => panel_blog_front_end_comments_path do |f| %>
<%= form_for Comment.new, :url => panel_new_blog_front_end_comments_path do |f| %>
<p>
<%= f.label :name, "Author" %><br />
@ -34,5 +34,5 @@
<% end %>
<%= link_to t('blog.edit'), edit_panel_blog_back_end_post_path(@post) %> |
<%= link_to t('blog.edit'), edit_panel_new_blog_back_end_post_path(@post) %> |
<%= link_back %>

View File

@ -2,6 +2,6 @@
<%= post_frontend.title %><br />
<p>
<%= truncate(post_frontend.body,:length=>25) %>
<%= link_to 'Read more...',panel_blog_front_end_post_path(post_frontend) %>
<%= link_to 'Read more...',panel_new_blog_front_end_post_path(post_frontend) %>
</p>
</div>

View File

@ -1,6 +1,6 @@
<% content_for :secondary do %>
<ul class="list">
<li><%= link_to t('blog.new_post'), new_panel_blog_back_end_post_path, :class => 'seclink1' %></li>
<li><%= link_to t('blog.new_post'), new_panel_new_blog_back_end_post_path, :class => 'seclink1' %></li>
</ul>
<% end -%>

View File

@ -18,7 +18,7 @@
</p>
<% end %>
<%= form_for Comment.new, :url => panel_blog_front_end_comments_path do |f| %>
<%= form_for Comment.new, :url => panel_new_blog_front_end_comments_path do |f| %>
<p>
<%= f.label :name, "Author" %><br />

View File

@ -1,4 +1,4 @@
<%=stylesheet_link_tag "NewBlog/application"%>
<%=stylesheet_link_tag "new_blog/application"%>
<div class="widget_index">
<table>
<tr>
@ -8,7 +8,7 @@
<% @posts.each do |post| %>
<tr>
<td><%= link_to post.title,panel_blog_front_end_post_path(post) %></td>
<td><%= link_to post.title,panel_new_blog_front_end_post_path(post) %></td>
<td><%= post.body.truncate(14) %></td>
</tr>
<% end %>

View File

@ -1,4 +1,4 @@
<%=stylesheet_link_tag "NewBlog/application"%>
<%=stylesheet_link_tag "new_blog/application"%>
<div class="widget_latest_post">
<h2><%= @post.title %> </h2>
<p>

View File

@ -0,0 +1,18 @@
# module NewBlog
# class MyEngine < Rails::Engine
# # Add a load path for this specific Engine
# # config.autoload_paths << File.expand_path("../lib/some/path", __FILE__)
# put "ABC"
# PrototypeR4::Application::Orbit_Apps << "NewBlog"
#
# # initializer "my_engine.add_middleware" do |app|
# # app.middleware.use MyEngine::Middleware
# # end
# end
#
# end
module NewBlog
VERSION = "0.0.1"
MOUDLEAPP_TITLE = "NewBlog"
end
# PrototypeR4::Application::Orbit_Apps << "NewBlog"

View File

@ -1,7 +1,7 @@
Rails.application.routes.draw do
namespace :panel do
namespace :blog do
namespace :new_blog do
namespace :back_end do
root :to => "posts#index"
resources :posts

View File

@ -0,0 +1,5 @@
require "new_blog/engine"
module NewBlog
end

View File

@ -0,0 +1,5 @@
module NewBlog
class Engine < Rails::Engine
isolate_namespace new_blog
end
end

View File

@ -6,5 +6,7 @@
"intro": "A simple blog……",
"update_info": "Some info",
"create_date": "11-11-2011",
"app_pages": ["/panel/blog/front_end/"]
"app_pages": ["/panel/new_blog/front_end/"],
"widgets": ["/panel/new_blog/widget/latest_post","/panel/new_blog/widget/"],
"enable_frontend": false
}

Some files were not shown because too many files have changed in this diff Show More